X-Git-Url: http://git.bitcoin.ninja/index.cgi?p=ldk-c-bindings;a=blobdiff_plain;f=lightning-c-bindings%2Finclude%2Flightning.h;h=8b6468cb4dd62e524269446a2e72364cecefa9e1;hp=9b2fefef3187d1a115850889294d35d36d1bf06a;hb=a21177846ed75d66f68a1603f768410f07a65791;hpb=95615c72597d5684e4314dae6e1e01170cd1a435 diff --git a/lightning-c-bindings/include/lightning.h b/lightning-c-bindings/include/lightning.h index 9b2fefe..8b6468c 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.20.0 */ +/* Generated with cbindgen:0.24.3 */ /* Warning, this file is autogenerated by cbindgen. Don't modify this manually. */ @@ -47,78 +47,93 @@ typedef enum LDKCOption_NoneZ { } LDKCOption_NoneZ; /** - * An error enum representing a failure to persist a channel monitor update. + * An enum representing the status of a channel monitor update persistence. */ -typedef enum LDKChannelMonitorUpdateErr { +typedef enum LDKChannelMonitorUpdateStatus { + /** + * The update has been durably persisted and all copies of the relevant [`ChannelMonitor`] + * have been updated. + * + * This includes performing any `fsync()` calls required to ensure the update is guaranteed to + * be available on restart even if the application crashes. + */ + LDKChannelMonitorUpdateStatus_Completed, /** * Used to indicate a temporary failure (eg connection to a watchtower or remote backup of * our state failed, but is expected to succeed at some point in the future). * * Such a failure will \"freeze\" a channel, preventing us from revoking old states or - * submitting new commitment transactions to the counterparty. Once the update(s) that failed - * have been successfully applied, a [`MonitorEvent::UpdateCompleted`] event should be returned - * via [`Watch::release_pending_monitor_events`] which will then restore the channel to an - * operational state. - * - * Note that a given ChannelManager will *never* re-generate a given ChannelMonitorUpdate. If - * you return a TemporaryFailure you must ensure that it is written to disk safely before - * writing out the latest ChannelManager state. + * submitting new commitment transactions to the counterparty. Once the update(s) which failed + * have been successfully applied, a [`MonitorEvent::Completed`] can be used to restore the + * channel to an operational state. * - * Even when a channel has been \"frozen\" updates to the ChannelMonitor can continue to occur - * (eg if an inbound HTLC which we forwarded was claimed upstream resulting in us attempting - * to claim it on this channel) and those updates must be applied wherever they can be. At - * least one such updated ChannelMonitor must be persisted otherwise PermanentFailure should - * be returned to get things on-chain ASAP using only the in-memory copy. Obviously updates to - * the channel which would invalidate previous ChannelMonitors are not made when a channel has - * been \"frozen\". + * Note that a given [`ChannelManager`] will *never* re-generate a [`ChannelMonitorUpdate`]. + * If you return this error you must ensure that it is written to disk safely before writing + * the latest [`ChannelManager`] state, or you should return [`PermanentFailure`] instead. * - * Note that even if updates made after TemporaryFailure succeed you must still provide a - * [`MonitorEvent::UpdateCompleted`] to ensure you have the latest monitor and re-enable - * normal channel operation. Note that this is normally generated through a call to - * [`ChainMonitor::channel_monitor_updated`]. + * Even when a channel has been \"frozen\", updates to the [`ChannelMonitor`] can continue to + * occur (e.g. if an inbound HTLC which we forwarded was claimed upstream, resulting in us + * attempting to claim it on this channel) and those updates must still be persisted. * - * Note that the update being processed here will not be replayed for you when you return a - * [`MonitorEvent::UpdateCompleted`] event via [`Watch::release_pending_monitor_events`], so - * you must store the update itself on your own local disk prior to returning a - * TemporaryFailure. You may, of course, employ a journaling approach, storing only the - * ChannelMonitorUpdate on disk without updating the monitor itself, replaying the journal at - * reload-time. + * No updates to the channel will be made which could invalidate other [`ChannelMonitor`]s + * until a [`MonitorEvent::Completed`] is provided, even if you return no error on a later + * monitor update for the same channel. * * For deployments where a copy of ChannelMonitors and other local state are backed up in a * remote location (with local copies persisted immediately), it is anticipated that all - * updates will return TemporaryFailure until the remote copies could be updated. + * updates will return [`InProgress`] until the remote copies could be updated. * - * [`ChainMonitor::channel_monitor_updated`]: chainmonitor::ChainMonitor::channel_monitor_updated + * [`PermanentFailure`]: ChannelMonitorUpdateStatus::PermanentFailure + * [`InProgress`]: ChannelMonitorUpdateStatus::InProgress + * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager */ - LDKChannelMonitorUpdateErr_TemporaryFailure, + LDKChannelMonitorUpdateStatus_InProgress, /** - * Used to indicate no further channel monitor updates will be allowed (eg we've moved on to a - * different watchtower and cannot update with all watchtowers that were previously informed - * of this channel). + * Used to indicate no further channel monitor updates will be allowed (likely a disk failure + * or a remote copy of this [`ChannelMonitor`] is no longer reachable and thus not updatable). + * + * When this is returned, [`ChannelManager`] will force-close the channel but *not* broadcast + * our current commitment transaction. This avoids a dangerous case where a local disk failure + * (e.g. the Linux-default remounting of the disk as read-only) causes [`PermanentFailure`]s + * for all monitor updates. If we were to broadcast our latest commitment transaction and then + * restart, we could end up reading a previous [`ChannelMonitor`] and [`ChannelManager`], + * revoking our now-broadcasted state before seeing it confirm and losing all our funds. * - * At reception of this error, ChannelManager will force-close the channel and return at - * least a final ChannelMonitorUpdate::ChannelForceClosed which must be delivered to at - * least one ChannelMonitor copy. Revocation secret MUST NOT be released and offchain channel - * update must be rejected. + * Note that this is somewhat of a tradeoff - if the disk is really gone and we may have lost + * the data permanently, we really should broadcast immediately. If the data can be recovered + * with manual intervention, we'd rather close the channel, rejecting future updates to it, + * and broadcast the latest state only if we have HTLCs to claim which are timing out (which + * we do as long as blocks are connected). * - * This failure may also signal a failure to update the local persisted copy of one of - * the channel monitor instance. + * In order to broadcast the latest local commitment transaction, you'll need to call + * [`ChannelMonitor::get_latest_holder_commitment_txn`] and broadcast the resulting + * transactions once you've safely ensured no further channel updates can be generated by your + * [`ChannelManager`]. * - * Note that even when you fail a holder commitment transaction update, you must store the - * update to ensure you can claim from it in case of a duplicate copy of this ChannelMonitor - * broadcasts it (e.g distributed channel-monitor deployment) + * Note that at least one final [`ChannelMonitorUpdate`] may still be provided, which must + * still be processed by a running [`ChannelMonitor`]. This final update will mark the + * [`ChannelMonitor`] as finalized, ensuring no further updates (e.g. revocation of the latest + * commitment transaction) are allowed. + * + * Note that even if you return a [`PermanentFailure`] due to unavailability of secondary + * [`ChannelMonitor`] copies, you should still make an attempt to store the update where + * possible to ensure you can claim HTLC outputs on the latest commitment transaction + * broadcasted later. * * In case of distributed watchtowers deployment, the new version must be written to disk, as * state may have been stored but rejected due to a block forcing a commitment broadcast. This * storage is used to claim outputs of rejected state confirmed onchain by another watchtower, * lagging behind on block processing. + * + * [`PermanentFailure`]: ChannelMonitorUpdateStatus::PermanentFailure + * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager */ - LDKChannelMonitorUpdateErr_PermanentFailure, + LDKChannelMonitorUpdateStatus_PermanentFailure, /** * Must be last for serialization purposes */ - LDKChannelMonitorUpdateErr_Sentinel, -} LDKChannelMonitorUpdateErr; + LDKChannelMonitorUpdateStatus_Sentinel, +} LDKChannelMonitorUpdateStatus; /** * An enum that represents the speed at which we want a transaction to confirm used for feerate @@ -340,6 +355,10 @@ typedef enum LDKSecp256k1Error { * Bad secret key */ LDKSecp256k1Error_InvalidSecretKey, + /** + * Bad shared secret. + */ + LDKSecp256k1Error_InvalidSharedSecret, /** * Bad recovery id */ @@ -348,14 +367,18 @@ typedef enum LDKSecp256k1Error { * Invalid tweak for add_assign or mul_assign */ LDKSecp256k1Error_InvalidTweak, - /** - * tweak_add_check failed on an xonly public key - */ - LDKSecp256k1Error_TweakCheckFailed, /** * Didn't pass enough memory to context creation with preallocated memory */ LDKSecp256k1Error_NotEnoughMemory, + /** + * Bad set of public keys. + */ + LDKSecp256k1Error_InvalidPublicKeySum, + /** + * The only valid parity values are 0 or 1. + */ + LDKSecp256k1Error_InvalidParityValue, /** * Must be last for serialization purposes */ @@ -459,6 +482,77 @@ typedef struct LDKStr { bool chars_is_owned; } LDKStr; +/** + * Represents a scalar value between zero and the secp256k1 curve order, in big endian. + */ +typedef struct LDKBigEndianScalar { + /** + * The bytes of the scalar value. + */ + uint8_t big_endian_bytes[32]; +} LDKBigEndianScalar; + +/** + * Arbitrary 32 bytes, which could represent one of a few different things. You probably want to + * look up the corresponding function in rust-lightning's docs. + */ +typedef struct LDKThirtyTwoBytes { + /** + * The thirty-two bytes + */ + uint8_t data[32]; +} LDKThirtyTwoBytes; + +/** + * Represents an error returned from the bech32 library during validation of some bech32 data + */ +typedef enum LDKBech32Error_Tag { + /** + * String does not contain the separator character + */ + LDKBech32Error_MissingSeparator, + /** + * The checksum does not match the rest of the data + */ + LDKBech32Error_InvalidChecksum, + /** + * The data or human-readable part is too long or too short + */ + LDKBech32Error_InvalidLength, + /** + * Some part of the string contains an invalid character + */ + LDKBech32Error_InvalidChar, + /** + * Some part of the data has an invalid value + */ + LDKBech32Error_InvalidData, + /** + * The bit conversion failed due to a padding issue + */ + LDKBech32Error_InvalidPadding, + /** + * The whole string must be of one case + */ + LDKBech32Error_MixedCase, + /** + * Must be last for serialization purposes + */ + LDKBech32Error_Sentinel, +} LDKBech32Error_Tag; + +typedef struct LDKBech32Error { + LDKBech32Error_Tag tag; + union { + struct { + uint32_t invalid_char; + }; + struct { + uint8_t invalid_data; + }; + }; +} LDKBech32Error; + /** * A serialized transaction, in (pointer, length) form. * @@ -522,6 +616,222 @@ typedef struct LDKTxOut { uint64_t value; } LDKTxOut; +/** + * Represents a valid secp256k1 public key serialized in "compressed form" as a 33 byte array. + */ +typedef struct LDKPublicKey { + /** + * The bytes of the public key + */ + uint8_t compressed_form[33]; +} LDKPublicKey; + +/** + * A dynamically-allocated array of crate::c_types::PublicKeys of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_PublicKeyZ { + /** + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + */ + struct LDKPublicKey *data; + /** + * The number of elements pointed to by `data`. + */ + uintptr_t datalen; +} LDKCVec_PublicKeyZ; + + + +/** + * Onion messages can be sent and received to blinded routes, which serve to hide the identity of + * the recipient. + */ +typedef struct MUST_USE_STRUCT LDKBlindedRoute { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeBlindedRoute *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; +} LDKBlindedRoute; + +/** + * The contents of CResult_BlindedRouteNoneZ + */ +typedef union LDKCResult_BlindedRouteNoneZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKBlindedRoute *result; + /** + * Note that this value is always NULL, as there are no contents in the Err variant + */ + void *err; +} LDKCResult_BlindedRouteNoneZPtr; + +/** + * A CResult_BlindedRouteNoneZ represents the result of a fallible operation, + * containing a crate::lightning::onion_message::blinded_route::BlindedRoute on success and a () on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_BlindedRouteNoneZ { + /** + * The contents of this CResult_BlindedRouteNoneZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_BlindedRouteNoneZPtr contents; + /** + * Whether this CResult_BlindedRouteNoneZ represents a success state. + */ + bool result_ok; +} LDKCResult_BlindedRouteNoneZ; + +/** + * An error in decoding a message or struct. + */ +typedef enum LDKDecodeError_Tag { + /** + * A version byte specified something we don't know how to handle. + * Includes unknown realm byte in an OnionHopData packet + */ + LDKDecodeError_UnknownVersion, + /** + * Unknown feature mandating we fail to parse message (eg TLV with an even, unknown type) + */ + LDKDecodeError_UnknownRequiredFeature, + /** + * Value was invalid, eg a byte which was supposed to be a bool was something other than a 0 + * or 1, a public key/private key/signature was invalid, text wasn't UTF-8, TLV was + * syntactically incorrect, etc + */ + LDKDecodeError_InvalidValue, + /** + * Buffer too short + */ + LDKDecodeError_ShortRead, + /** + * A length descriptor in the packet didn't describe the later data correctly + */ + LDKDecodeError_BadLengthDescriptor, + /** + * Error from std::io + */ + LDKDecodeError_Io, + /** + * The message included zlib-compressed values, which we don't support. + */ + LDKDecodeError_UnsupportedCompression, + /** + * Must be last for serialization purposes + */ + LDKDecodeError_Sentinel, +} LDKDecodeError_Tag; + +typedef struct MUST_USE_STRUCT LDKDecodeError { + LDKDecodeError_Tag tag; + union { + struct { + enum LDKIOError io; + }; + }; +} LDKDecodeError; + +/** + * The contents of CResult_BlindedRouteDecodeErrorZ + */ +typedef union LDKCResult_BlindedRouteDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKBlindedRoute *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_BlindedRouteDecodeErrorZPtr; + +/** + * A CResult_BlindedRouteDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::onion_message::blinded_route::BlindedRoute 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_BlindedRouteDecodeErrorZ { + /** + * The contents of this CResult_BlindedRouteDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_BlindedRouteDecodeErrorZPtr contents; + /** + * Whether this CResult_BlindedRouteDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_BlindedRouteDecodeErrorZ; + + + +/** + * Used to construct the blinded hops portion of a blinded route. These hops cannot be identified + * by outside observers and thus can be used to hide the identity of the recipient. + */ +typedef struct MUST_USE_STRUCT LDKBlindedHop { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeBlindedHop *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKBlindedHop; + +/** + * The contents of CResult_BlindedHopDecodeErrorZ + */ +typedef union LDKCResult_BlindedHopDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKBlindedHop *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + struct LDKDecodeError *err; +} LDKCResult_BlindedHopDecodeErrorZPtr; + +/** + * A CResult_BlindedHopDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::onion_message::blinded_route::BlindedHop on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_BlindedHopDecodeErrorZ { + /** + * The contents of this CResult_BlindedHopDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_BlindedHopDecodeErrorZPtr contents; + /** + * Whether this CResult_BlindedHopDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_BlindedHopDecodeErrorZ; + /** * The contents of CResult_NoneNoneZ */ @@ -557,7 +867,7 @@ typedef struct 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). + * [BOLT 3](https://github.com/lightning/bolts/blob/dcbf8583976df087c79c3ce0b535311212e6812d/03-transactions.md#efficient-per-commitment-secret-storage). * * Allows us to keep track of all of the revocation secrets of our counterparty in just 50*32 bytes * or so. @@ -577,26 +887,6 @@ typedef struct MUST_USE_STRUCT LDKCounterpartyCommitmentSecrets { 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 */ @@ -673,16 +963,6 @@ typedef struct LDKCResult_SecretKeyErrorZ { bool result_ok; } LDKCResult_SecretKeyErrorZ; -/** - * Represents a valid secp256k1 public key serialized in "compressed form" as a 33 byte array. - */ -typedef struct LDKPublicKey { - /** - * The bytes of the public key - */ - uint8_t compressed_form[33]; -} LDKPublicKey; - /** * The contents of CResult_PublicKeyErrorZ */ @@ -1398,7 +1678,7 @@ typedef struct LDKCResult_CVec_SignatureZNoneZ { /** * A script pubkey for shutting down a channel as defined by [BOLT #2]. * - * [BOLT #2]: https://github.com/lightningnetwork/lightning-rfc/blob/master/02-peer-protocol.md + * [BOLT #2]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md */ typedef struct MUST_USE_STRUCT LDKShutdownScript { /** @@ -1501,37 +1781,45 @@ typedef struct LDKCResult_ShutdownScriptInvalidShutdownScriptZ { bool result_ok; } LDKCResult_ShutdownScriptInvalidShutdownScriptZ; + + /** - * The contents of CResult_NoneErrorZ + * Represents the compressed public key of a node */ -typedef union LDKCResult_NoneErrorZPtr { +typedef struct MUST_USE_STRUCT LDKNodeId { /** - * 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; + LDKnativeNodeId *inner; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. - */ - enum LDKIOError *err; -} LDKCResult_NoneErrorZPtr; + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKNodeId; + + /** - * A CResult_NoneErrorZ represents the result of a fallible operation, - * containing a () on success and a crate::c_types::IOError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. + * Proposed use of a channel passed as a parameter to [`Score::channel_penalty_msat`]. */ -typedef struct LDKCResult_NoneErrorZ { +typedef struct MUST_USE_STRUCT LDKChannelUsage { /** - * The contents of this CResult_NoneErrorZ, 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_NoneErrorZPtr contents; + LDKnativeChannelUsage *inner; /** - * Whether this CResult_NoneErrorZ 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_NoneErrorZ; + bool is_owned; +} LDKChannelUsage; @@ -1553,6 +1841,184 @@ typedef struct MUST_USE_STRUCT LDKRouteHop { bool is_owned; } LDKRouteHop; +/** + * A dynamically-allocated array of crate::lightning::routing::router::RouteHops of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_RouteHopZ { + /** + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + */ + struct LDKRouteHop *data; + /** + * The number of elements pointed to by `data`. + */ + uintptr_t datalen; +} LDKCVec_RouteHopZ; + +/** + * An interface used to score payment channels for path finding. + * + *\tScoring is in terms of fees willing to be paid in order to avoid routing through a channel. + */ +typedef struct LDKScore { + /** + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. + */ + void *this_arg; + /** + * Returns the fee in msats willing to be paid to avoid routing `send_amt_msat` through the + * given channel in the direction from `source` to `target`. + * + * The channel's capacity (less any other MPP parts that are also being considered for use in + * the same payment) is given by `capacity_msat`. It may be determined from various sources + * such as a chain data, network gossip, or invoice hints. For invoice hints, a capacity near + * [`u64::max_value`] is given to indicate sufficient capacity for the invoice's full amount. + * Thus, implementations should be overflow-safe. + */ + uint64_t (*channel_penalty_msat)(const void *this_arg, uint64_t short_channel_id, const struct LDKNodeId *NONNULL_PTR source, const struct LDKNodeId *NONNULL_PTR target, struct LDKChannelUsage usage); + /** + * Handles updating channel penalties after failing to route through a channel. + */ + void (*payment_path_failed)(void *this_arg, 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); + /** + * Handles updating channel penalties after a probe over the given path failed. + */ + void (*probe_failed)(void *this_arg, struct LDKCVec_RouteHopZ path, uint64_t short_channel_id); + /** + * Handles updating channel penalties after a probe over the given path succeeded. + */ + void (*probe_successful)(void *this_arg, struct LDKCVec_RouteHopZ path); + /** + * Serialize the object into a byte array + */ + struct LDKCVec_u8Z (*write)(const void *this_arg); + /** + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + */ + void (*free)(void *this_arg); +} LDKScore; + +/** + * A scorer that is accessed under a lock. + * + * Needed so that calls to [`Score::channel_penalty_msat`] in [`find_route`] can be made while + * having shared ownership of a scorer but without requiring internal locking in [`Score`] + * implementations. Internal locking would be detrimental to route finding performance and could + * result in [`Score::channel_penalty_msat`] returning a different value for the same channel. + * + * [`find_route`]: crate::routing::router::find_route + */ +typedef struct LDKLockableScore { + /** + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. + */ + void *this_arg; + /** + * Returns the locked scorer. + */ + struct LDKScore (*lock)(const void *this_arg); + /** + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + */ + void (*free)(void *this_arg); +} LDKLockableScore; + +/** + * Refers to a scorer that is accessible under lock and also writeable to disk + * + * We need this trait to be able to pass in a scorer to `lightning-background-processor` that will enable us to + * use the Persister to persist it. + */ +typedef struct LDKWriteableScore { + /** + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. + */ + void *this_arg; + /** + * Implementation of LockableScore for this object. + */ + struct LDKLockableScore LockableScore; + /** + * Serialize the object into a byte array + */ + struct LDKCVec_u8Z (*write)(const void *this_arg); + /** + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + */ + void (*free)(void *this_arg); +} LDKWriteableScore; + +/** + * An enum which can either contain a crate::lightning::routing::scoring::WriteableScore or not + */ +typedef enum LDKCOption_WriteableScoreZ_Tag { + /** + * When we're in this state, this COption_WriteableScoreZ contains a crate::lightning::routing::scoring::WriteableScore + */ + LDKCOption_WriteableScoreZ_Some, + /** + * When we're in this state, this COption_WriteableScoreZ contains nothing + */ + LDKCOption_WriteableScoreZ_None, + /** + * Must be last for serialization purposes + */ + LDKCOption_WriteableScoreZ_Sentinel, +} LDKCOption_WriteableScoreZ_Tag; + +typedef struct LDKCOption_WriteableScoreZ { + LDKCOption_WriteableScoreZ_Tag tag; + union { + struct { + struct LDKWriteableScore some; + }; + }; +} LDKCOption_WriteableScoreZ; + +/** + * The contents of CResult_NoneErrorZ + */ +typedef union LDKCResult_NoneErrorZPtr { + /** + * Note that this value is always NULL, as there are no contents in the OK variant + */ + void *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + enum LDKIOError *err; +} LDKCResult_NoneErrorZPtr; + +/** + * A CResult_NoneErrorZ represents the result of a fallible operation, + * containing a () on success and a crate::c_types::IOError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_NoneErrorZ { + /** + * The contents of this CResult_NoneErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_NoneErrorZPtr contents; + /** + * Whether this CResult_NoneErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_NoneErrorZ; + /** * The contents of CResult_RouteHopDecodeErrorZ */ @@ -1586,22 +2052,6 @@ typedef struct LDKCResult_RouteHopDecodeErrorZ { bool result_ok; } LDKCResult_RouteHopDecodeErrorZ; -/** - * A dynamically-allocated array of crate::lightning::routing::router::RouteHops of arbitrary size. - * This corresponds to std::vector in C++ - */ -typedef struct LDKCVec_RouteHopZ { - /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - */ - struct LDKRouteHop *data; - /** - * The number of elements pointed to by `data`. - */ - uintptr_t datalen; -} LDKCVec_RouteHopZ; - /** * A dynamically-allocated array of crate::c_types::derived::CVec_RouteHopZs of arbitrary size. * This corresponds to std::vector in C++ @@ -1677,8 +2127,8 @@ typedef struct LDKCResult_RouteDecodeErrorZ { /** * Parameters needed to find a [`Route`]. * - * Passed to [`find_route`] and also provided in [`Event::PaymentPathFailed`] for retrying a failed - * payment path. + * Passed to [`find_route`] and [`build_route_from_hops`], but also provided in + * [`Event::PaymentPathFailed`] for retrying a failed payment path. * * [`Event::PaymentPathFailed`]: crate::util::events::Event::PaymentPathFailed */ @@ -1793,6 +2243,22 @@ typedef struct LDKCOption_u64Z { }; } LDKCOption_u64Z; +/** + * A dynamically-allocated array of u64s of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_u64Z { + /** + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + */ + uint64_t *data; + /** + * The number of elements pointed to by `data`. + */ + uintptr_t datalen; +} LDKCVec_u64Z; + /** @@ -2038,277 +2504,94 @@ typedef struct LDKCResult_RouteLightningErrorZ { } LDKCResult_RouteLightningErrorZ; /** - * The contents of CResult_TxOutAccessErrorZ + * 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 union LDKCResult_TxOutAccessErrorZPtr { - /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. - */ - struct LDKTxOut *result; +typedef enum LDKPaymentPurpose_Tag { /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * Information for receiving a payment that we generated an invoice for. */ - enum LDKAccessError *err; -} LDKCResult_TxOutAccessErrorZPtr; - -/** - * A CResult_TxOutAccessErrorZ represents the result of a fallible operation, - * containing a crate::c_types::TxOut on success and a crate::lightning::chain::AccessError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_TxOutAccessErrorZ { + LDKPaymentPurpose_InvoicePayment, /** - * The contents of this CResult_TxOutAccessErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * Because this is a spontaneous payment, the payer generated their own preimage rather than us + * (the payee) providing a preimage. */ - union LDKCResult_TxOutAccessErrorZPtr contents; + LDKPaymentPurpose_SpontaneousPayment, /** - * Whether this CResult_TxOutAccessErrorZ represents a success state. + * Must be last for serialization purposes */ - bool result_ok; -} LDKCResult_TxOutAccessErrorZ; + LDKPaymentPurpose_Sentinel, +} LDKPaymentPurpose_Tag; -/** - * A tuple of 2 elements. See the individual fields for the types contained. - */ -typedef struct LDKC2Tuple_usizeTransactionZ { - /** - * The element at position 0 - */ - uintptr_t a; +typedef struct LDKPaymentPurpose_LDKInvoicePayment_Body { /** - * The element at position 1 - */ - struct LDKTransaction b; -} LDKC2Tuple_usizeTransactionZ; - -/** - * A dynamically-allocated array of crate::c_types::derived::C2Tuple_usizeTransactionZs of arbitrary size. - * This corresponds to std::vector in C++ - */ -typedef struct LDKCVec_C2Tuple_usizeTransactionZZ { - /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - */ - struct LDKC2Tuple_usizeTransactionZ *data; - /** - * The number of elements pointed to by `data`. - */ - uintptr_t datalen; -} LDKCVec_C2Tuple_usizeTransactionZZ; - -/** - * Arbitrary 32 bytes, which could represent one of a few different things. You probably want to - * look up the corresponding function in rust-lightning's docs. - */ -typedef struct LDKThirtyTwoBytes { - /** - * The thirty-two bytes - */ - uint8_t data[32]; -} LDKThirtyTwoBytes; - -/** - * A dynamically-allocated array of crate::c_types::ThirtyTwoBytess of arbitrary size. - * This corresponds to std::vector in C++ - */ -typedef struct LDKCVec_TxidZ { - /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - */ - struct LDKThirtyTwoBytes *data; - /** - * The number of elements pointed to by `data`. - */ - uintptr_t datalen; -} LDKCVec_TxidZ; - -/** - * The contents of CResult_NoneChannelMonitorUpdateErrZ - */ -typedef union LDKCResult_NoneChannelMonitorUpdateErrZPtr { - /** - * Note that this value is always NULL, as there are no contents in the OK variant - */ - void *result; - /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. - */ - enum LDKChannelMonitorUpdateErr *err; -} LDKCResult_NoneChannelMonitorUpdateErrZPtr; - -/** - * A CResult_NoneChannelMonitorUpdateErrZ represents the result of a fallible operation, - * containing a () on success and a crate::lightning::chain::ChannelMonitorUpdateErr on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_NoneChannelMonitorUpdateErrZ { - /** - * The contents of this CResult_NoneChannelMonitorUpdateErrZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. - */ - union LDKCResult_NoneChannelMonitorUpdateErrZPtr contents; - /** - * Whether this CResult_NoneChannelMonitorUpdateErrZ represents a success state. - */ - bool result_ok; -} LDKCResult_NoneChannelMonitorUpdateErrZ; - - - -/** - * Simple structure sent back by `chain::Watch` when an HTLC from a forward channel is detected on - * chain. Used to update the corresponding HTLC in the backward channel. Failing to pass the - * preimage claim backward will lead to loss of funds. - */ -typedef struct MUST_USE_STRUCT LDKHTLCUpdate { - /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. - */ - LDKnativeHTLCUpdate *inner; - /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. - */ - bool is_owned; -} LDKHTLCUpdate; - - - -/** - * A reference to a transaction output. - * - * Differs from bitcoin::blockdata::transaction::OutPoint as the index is a u16 instead of u32 - * due to LN's restrictions on index values. Should reduce (possibly) unsafe conversions this way. - */ -typedef struct MUST_USE_STRUCT LDKOutPoint { - /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. - */ - LDKnativeOutPoint *inner; - /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. - */ - bool is_owned; -} LDKOutPoint; - -/** - * An event to be processed by the ChannelManager. - */ -typedef enum LDKMonitorEvent_Tag { - /** - * A monitor event containing an HTLCUpdate. - */ - LDKMonitorEvent_HTLCEvent, - /** - * A monitor event that the Channel's commitment transaction was confirmed. - */ - LDKMonitorEvent_CommitmentTxConfirmed, - /** - * Indicates a [`ChannelMonitor`] update has completed. See - * [`ChannelMonitorUpdateErr::TemporaryFailure`] for more information on how this is used. + * 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`]. * - * [`ChannelMonitorUpdateErr::TemporaryFailure`]: super::ChannelMonitorUpdateErr::TemporaryFailure - */ - LDKMonitorEvent_UpdateCompleted, - /** - * Indicates a [`ChannelMonitor`] update has failed. See - * [`ChannelMonitorUpdateErr::PermanentFailure`] for more information on how this is used. + * [`ChannelManager::create_inbound_payment`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment + * [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds * - * [`ChannelMonitorUpdateErr::PermanentFailure`]: super::ChannelMonitorUpdateErr::PermanentFailure - */ - LDKMonitorEvent_UpdateFailed, - /** - * Must be last for serialization purposes - */ - LDKMonitorEvent_Sentinel, -} LDKMonitorEvent_Tag; - -typedef struct LDKMonitorEvent_LDKUpdateCompleted_Body { - /** - * The funding outpoint of the [`ChannelMonitor`] that was updated + * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None */ - struct LDKOutPoint funding_txo; + struct LDKThirtyTwoBytes payment_preimage; /** - * The Update ID from [`ChannelMonitorUpdate::update_id`] which was applied or - * [`ChannelMonitor::get_latest_update_id`]. + * 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`]. * - * Note that this should only be set to a given update's ID if all previous updates for the - * same [`ChannelMonitor`] have been applied and persisted. + * [`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 */ - uint64_t monitor_update_id; -} LDKMonitorEvent_LDKUpdateCompleted_Body; + struct LDKThirtyTwoBytes payment_secret; +} LDKPaymentPurpose_LDKInvoicePayment_Body; -typedef struct MUST_USE_STRUCT LDKMonitorEvent { - LDKMonitorEvent_Tag tag; +typedef struct MUST_USE_STRUCT LDKPaymentPurpose { + LDKPaymentPurpose_Tag tag; union { + LDKPaymentPurpose_LDKInvoicePayment_Body invoice_payment; struct { - struct LDKHTLCUpdate htlc_event; - }; - struct { - struct LDKOutPoint commitment_tx_confirmed; - }; - LDKMonitorEvent_LDKUpdateCompleted_Body update_completed; - struct { - struct LDKOutPoint update_failed; + struct LDKThirtyTwoBytes spontaneous_payment; }; }; -} LDKMonitorEvent; +} LDKPaymentPurpose; /** - * A dynamically-allocated array of crate::lightning::chain::channelmonitor::MonitorEvents of arbitrary size. - * This corresponds to std::vector in C++ + * The contents of CResult_PaymentPurposeDecodeErrorZ */ -typedef struct LDKCVec_MonitorEventZ { +typedef union LDKCResult_PaymentPurposeDecodeErrorZPtr { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKMonitorEvent *data; + struct LDKPaymentPurpose *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_MonitorEventZ; + struct LDKDecodeError *err; +} LDKCResult_PaymentPurposeDecodeErrorZPtr; /** - * An enum which can either contain a crate::c_types::derived::C2Tuple_usizeTransactionZ or not + * A CResult_PaymentPurposeDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::util::events::PaymentPurpose on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef enum LDKCOption_C2Tuple_usizeTransactionZZ_Tag { - /** - * When we're in this state, this COption_C2Tuple_usizeTransactionZZ contains a crate::c_types::derived::C2Tuple_usizeTransactionZ - */ - LDKCOption_C2Tuple_usizeTransactionZZ_Some, +typedef struct LDKCResult_PaymentPurposeDecodeErrorZ { /** - * When we're in this state, this COption_C2Tuple_usizeTransactionZZ contains nothing + * The contents of this CResult_PaymentPurposeDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - LDKCOption_C2Tuple_usizeTransactionZZ_None, + union LDKCResult_PaymentPurposeDecodeErrorZPtr contents; /** - * Must be last for serialization purposes + * Whether this CResult_PaymentPurposeDecodeErrorZ represents a success state. */ - LDKCOption_C2Tuple_usizeTransactionZZ_Sentinel, -} LDKCOption_C2Tuple_usizeTransactionZZ_Tag; - -typedef struct LDKCOption_C2Tuple_usizeTransactionZZ { - LDKCOption_C2Tuple_usizeTransactionZZ_Tag tag; - union { - struct { - struct LDKC2Tuple_usizeTransactionZ some; - }; - }; -} LDKCOption_C2Tuple_usizeTransactionZZ; + bool result_ok; +} LDKCResult_PaymentPurposeDecodeErrorZ; /** * The reason the channel was closed. See individual variants more details. @@ -2347,16 +2630,24 @@ typedef enum LDKClosureReason_Tag { */ 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. + * The peer disconnected prior to funding completing. In this case the spec mandates that we + * forget the channel entirely - we can attempt again if the peer reconnects. + * + * This includes cases where we restarted prior to funding completion, including prior to the + * initial [`ChannelMonitor`] persistence completing. + * + * In LDK versions prior to 0.0.107 this could also occur if we were unable to connect to the + * peer because of mutual incompatibility between us and our channel counterparty. + * + * [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor */ LDKClosureReason_DisconnectedPeer, /** - * Closure generated from `ChannelManager::read` if the ChannelMonitor is newer than - * the ChannelManager deserialized. + * Closure generated from `ChannelManager::read` if the [`ChannelMonitor`] is newer than + * the [`ChannelManager`] deserialized. + * + * [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor + * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager */ LDKClosureReason_OutdatedChannelManager, /** @@ -2451,72 +2742,199 @@ typedef struct LDKCResult_COption_ClosureReasonZDecodeErrorZ { bool result_ok; } LDKCResult_COption_ClosureReasonZDecodeErrorZ; - - /** - * A channel_update message to be sent or received from a peer + * Intended destination of a failed HTLC as indicated in [`Event::HTLCHandlingFailed`]. */ -typedef struct MUST_USE_STRUCT LDKChannelUpdate { +typedef enum LDKHTLCDestination_Tag { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * We tried forwarding to a channel but failed to do so. An example of such an instance is when + * there is insufficient capacity in our outbound channel. */ - LDKnativeChannelUpdate *inner; + LDKHTLCDestination_NextHopChannel, /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * Scenario where we are unsure of the next node to forward the HTLC to. */ - bool is_owned; -} LDKChannelUpdate; - -/** - * Update to the [`NetworkGraph`] based on payment failure information conveyed via the Onion - * return packet by a node along the route. See [BOLT #4] for details. - * - * [BOLT #4]: https://github.com/lightningnetwork/lightning-rfc/blob/master/04-onion-routing.md - */ -typedef enum LDKNetworkUpdate_Tag { + LDKHTLCDestination_UnknownNextHop, /** - * An error indicating a `channel_update` messages should be applied via - * [`NetworkGraph::update_channel`]. + * Failure scenario where an HTLC may have been forwarded to be intended for us, + * but is invalid for some reason, so we reject it. + * + * Some of the reasons may include: + * * HTLC Timeouts + * * Expected MPP amount to claim does not equal HTLC total + * * Claimable amount does not match expected amount */ - LDKNetworkUpdate_ChannelUpdateMessage, + LDKHTLCDestination_FailedPayment, /** - * An error indicating only that a channel has been closed, which should be applied via - * [`NetworkGraph::close_channel_from_update`]. + * Must be last for serialization purposes */ - LDKNetworkUpdate_ChannelClosed, + LDKHTLCDestination_Sentinel, +} LDKHTLCDestination_Tag; + +typedef struct LDKHTLCDestination_LDKNextHopChannel_Body { /** - * An error indicating only that a node has failed, which should be applied via - * [`NetworkGraph::fail_node`]. + * The `node_id` of the next node. For backwards compatibility, this field is + * marked as optional, versions prior to 0.0.110 may not always be able to provide + * counterparty node information. + * + * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None */ - LDKNetworkUpdate_NodeFailure, + struct LDKPublicKey node_id; /** - * Must be last for serialization purposes + * The outgoing `channel_id` between us and the next node. */ - LDKNetworkUpdate_Sentinel, -} LDKNetworkUpdate_Tag; + struct LDKThirtyTwoBytes channel_id; +} LDKHTLCDestination_LDKNextHopChannel_Body; -typedef struct LDKNetworkUpdate_LDKChannelUpdateMessage_Body { +typedef struct LDKHTLCDestination_LDKUnknownNextHop_Body { /** - * The update to apply via [`NetworkGraph::update_channel`]. + * Short channel id we are requesting to forward an HTLC to. */ - struct LDKChannelUpdate msg; -} LDKNetworkUpdate_LDKChannelUpdateMessage_Body; + uint64_t requested_forward_scid; +} LDKHTLCDestination_LDKUnknownNextHop_Body; -typedef struct LDKNetworkUpdate_LDKChannelClosed_Body { +typedef struct LDKHTLCDestination_LDKFailedPayment_Body { /** - * The short channel id of the closed channel. - */ - uint64_t short_channel_id; - /** - * Whether the channel should be permanently removed or temporarily disabled until a new - * `channel_update` message is received. + * The payment hash of the payment we attempted to process. */ - bool is_permanent; -} LDKNetworkUpdate_LDKChannelClosed_Body; + struct LDKThirtyTwoBytes payment_hash; +} LDKHTLCDestination_LDKFailedPayment_Body; + +typedef struct MUST_USE_STRUCT LDKHTLCDestination { + LDKHTLCDestination_Tag tag; + union { + LDKHTLCDestination_LDKNextHopChannel_Body next_hop_channel; + LDKHTLCDestination_LDKUnknownNextHop_Body unknown_next_hop; + LDKHTLCDestination_LDKFailedPayment_Body failed_payment; + }; +} LDKHTLCDestination; + +/** + * An enum which can either contain a crate::lightning::util::events::HTLCDestination or not + */ +typedef enum LDKCOption_HTLCDestinationZ_Tag { + /** + * When we're in this state, this COption_HTLCDestinationZ contains a crate::lightning::util::events::HTLCDestination + */ + LDKCOption_HTLCDestinationZ_Some, + /** + * When we're in this state, this COption_HTLCDestinationZ contains nothing + */ + LDKCOption_HTLCDestinationZ_None, + /** + * Must be last for serialization purposes + */ + LDKCOption_HTLCDestinationZ_Sentinel, +} LDKCOption_HTLCDestinationZ_Tag; + +typedef struct LDKCOption_HTLCDestinationZ { + LDKCOption_HTLCDestinationZ_Tag tag; + union { + struct { + struct LDKHTLCDestination some; + }; + }; +} LDKCOption_HTLCDestinationZ; + +/** + * The contents of CResult_COption_HTLCDestinationZDecodeErrorZ + */ +typedef union LDKCResult_COption_HTLCDestinationZDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKCOption_HTLCDestinationZ *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_HTLCDestinationZDecodeErrorZPtr; + +/** + * A CResult_COption_HTLCDestinationZDecodeErrorZ represents the result of a fallible operation, + * containing a crate::c_types::derived::COption_HTLCDestinationZ on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_COption_HTLCDestinationZDecodeErrorZ { + /** + * The contents of this CResult_COption_HTLCDestinationZDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_COption_HTLCDestinationZDecodeErrorZPtr contents; + /** + * Whether this CResult_COption_HTLCDestinationZDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_COption_HTLCDestinationZDecodeErrorZ; + + + +/** + * A channel_update message to be sent or received from a peer + */ +typedef struct MUST_USE_STRUCT LDKChannelUpdate { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeChannelUpdate *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKChannelUpdate; + +/** + * Update to the [`NetworkGraph`] based on payment failure information conveyed via the Onion + * return packet by a node along the route. See [BOLT #4] for details. + * + * [BOLT #4]: https://github.com/lightning/bolts/blob/master/04-onion-routing.md + */ +typedef enum LDKNetworkUpdate_Tag { + /** + * An error indicating a `channel_update` messages should be applied via + * [`NetworkGraph::update_channel`]. + */ + LDKNetworkUpdate_ChannelUpdateMessage, + /** + * An error indicating that a channel failed to route a payment, which should be applied via + * [`NetworkGraph::channel_failed`]. + */ + LDKNetworkUpdate_ChannelFailure, + /** + * An error indicating that a node failed to route a payment, which should be applied via + * [`NetworkGraph::node_failed_permanent`] if permanent. + */ + LDKNetworkUpdate_NodeFailure, + /** + * Must be last for serialization purposes + */ + LDKNetworkUpdate_Sentinel, +} LDKNetworkUpdate_Tag; + +typedef struct LDKNetworkUpdate_LDKChannelUpdateMessage_Body { + /** + * The update to apply via [`NetworkGraph::update_channel`]. + */ + struct LDKChannelUpdate msg; +} LDKNetworkUpdate_LDKChannelUpdateMessage_Body; + +typedef struct LDKNetworkUpdate_LDKChannelFailure_Body { + /** + * The short channel id of the closed channel. + */ + uint64_t short_channel_id; + /** + * Whether the channel should be permanently removed or temporarily disabled until a new + * `channel_update` message is received. + */ + bool is_permanent; +} LDKNetworkUpdate_LDKChannelFailure_Body; typedef struct LDKNetworkUpdate_LDKNodeFailure_Body { /** @@ -2534,17 +2952,17 @@ typedef struct MUST_USE_STRUCT LDKNetworkUpdate { LDKNetworkUpdate_Tag tag; union { LDKNetworkUpdate_LDKChannelUpdateMessage_Body channel_update_message; - LDKNetworkUpdate_LDKChannelClosed_Body channel_closed; + LDKNetworkUpdate_LDKChannelFailure_Body channel_failure; LDKNetworkUpdate_LDKNodeFailure_Body node_failure; }; } LDKNetworkUpdate; /** - * An enum which can either contain a crate::lightning::routing::network_graph::NetworkUpdate or not + * An enum which can either contain a crate::lightning::routing::gossip::NetworkUpdate or not */ typedef enum LDKCOption_NetworkUpdateZ_Tag { /** - * When we're in this state, this COption_NetworkUpdateZ contains a crate::lightning::routing::network_graph::NetworkUpdate + * When we're in this state, this COption_NetworkUpdateZ contains a crate::lightning::routing::gossip::NetworkUpdate */ LDKCOption_NetworkUpdateZ_Some, /** @@ -2568,6 +2986,29 @@ typedef struct LDKCOption_NetworkUpdateZ { +/** + * A reference to a transaction output. + * + * Differs from bitcoin::blockdata::transaction::OutPoint as the index is a u16 instead of u32 + * due to LN's restrictions on index values. Should reduce (possibly) unsafe conversions this way. + */ +typedef struct MUST_USE_STRUCT LDKOutPoint { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeOutPoint *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKOutPoint; + + + /** * Information about a spendable output to a P2WSH script. See * SpendableOutputDescriptor::DelayedPaymentOutput for more details on how to spend this. @@ -2711,62 +3152,34 @@ typedef struct LDKCVec_SpendableOutputDescriptorZ { uintptr_t datalen; } LDKCVec_SpendableOutputDescriptorZ; + + /** - * 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. + * 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 enum LDKPaymentPurpose_Tag { - /** - * Information for receiving a payment that we generated an invoice for. - */ - LDKPaymentPurpose_InvoicePayment, - /** - * Because this is a spontaneous payment, the payer generated their own preimage rather than us - * (the payee) providing a preimage. - */ - LDKPaymentPurpose_SpontaneousPayment, - /** - * Must be last for serialization purposes - */ - LDKPaymentPurpose_Sentinel, -} LDKPaymentPurpose_Tag; - -typedef struct LDKPaymentPurpose_LDKInvoicePayment_Body { +typedef struct MUST_USE_STRUCT LDKChannelTypeFeatures { /** - * 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 + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - struct LDKThirtyTwoBytes payment_preimage; + LDKnativeChannelTypeFeatures *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 + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - struct LDKThirtyTwoBytes payment_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; + bool is_owned; +} LDKChannelTypeFeatures; /** * An Event which you should probably take some action in response to. @@ -2788,8 +3201,9 @@ typedef enum LDKEvent_Tag { */ LDKEvent_FundingGenerationReady, /** - * Indicates we've received money! Just gotta dig out that payment preimage and feed it to - * [`ChannelManager::claim_funds`] to get it.... + * Indicates we've received (an offer of) 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. @@ -2805,6 +3219,23 @@ typedef enum LDKEvent_Tag { * [`ChannelManager::fail_htlc_backwards`]: crate::ln::channelmanager::ChannelManager::fail_htlc_backwards */ LDKEvent_PaymentReceived, + /** + * Indicates a payment has been claimed and we've received money! + * + * This most likely occurs when [`ChannelManager::claim_funds`] has been called in response + * to an [`Event::PaymentReceived`]. However, if we previously crashed during a + * [`ChannelManager::claim_funds`] call you may see this event without a corresponding + * [`Event::PaymentReceived`] event. + * + * # Note + * LDK will not stop an inbound payment from being paid multiple times, so multiple + * `PaymentReceived` events may be generated for the same payment. If you then call + * [`ChannelManager::claim_funds`] twice for the same [`Event::PaymentReceived`] you may get + * multiple `PaymentClaimed` events. + * + * [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds + */ + LDKEvent_PaymentClaimed, /** * 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). @@ -2813,6 +3244,24 @@ typedef enum LDKEvent_Tag { * event. In this situation, you SHOULD treat this payment as having succeeded. */ LDKEvent_PaymentSent, + /** + * 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 + */ + LDKEvent_PaymentFailed, + /** + * 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. + */ + LDKEvent_PaymentPathSuccessful, /** * Indicates an outbound HTLC we sent failed. Probably some intermediary node dropped * something. You may wish to retry with a different route. @@ -2824,16 +3273,13 @@ typedef enum LDKEvent_Tag { */ LDKEvent_PaymentPathFailed, /** - * 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 + * Indicates that a probe payment we sent returned successful, i.e., only failed at the destination. */ - LDKEvent_PaymentFailed, + LDKEvent_ProbeSuccessful, + /** + * Indicates that a probe payment we sent failed at an intermediary node on the path. + */ + LDKEvent_ProbeFailed, /** * Used to indicate that [`ChannelManager::process_pending_htlc_forwards`] should be called at * a time in the future. @@ -2855,7 +3301,8 @@ typedef enum LDKEvent_Tag { */ LDKEvent_PaymentForwarded, /** - * Used to indicate that a channel with the given `channel_id` is in the process of closure. + * Used to indicate that a previously opened channel with the given `channel_id` is in the + * process of closure. */ LDKEvent_ChannelClosed, /** @@ -2863,27 +3310,35 @@ typedef enum LDKEvent_Tag { * inputs for another purpose. */ LDKEvent_DiscardFunding, - /** - * 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. - */ - LDKEvent_PaymentPathSuccessful, /** * Indicates a request to open a new channel by a peer. * * To accept the request, call [`ChannelManager::accept_inbound_channel`]. To reject the - * request, call [`ChannelManager::force_close_channel`]. + * request, call [`ChannelManager::force_close_without_broadcasting_txn`]. * * The event is only triggered when a new open channel request is received and the * [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. * * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel - * [`ChannelManager::force_close_channel`]: crate::ln::channelmanager::ChannelManager::force_close_channel + * [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn * [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels */ LDKEvent_OpenChannelRequest, + /** + * Indicates that the HTLC was accepted, but could not be processed when or after attempting to + * forward it. + * + * Some scenarios where this event may be sent include: + * * Insufficient capacity in the outbound channel + * * While waiting to forward the HTLC, the channel it is meant to be forwarded through closes + * * When an unknown SCID is requested for forwarding a payment. + * * Claiming an amount for an MPP payment that exceeds the HTLC total + * * The HTLC has timed out + * + * This event, however, does not get generated if an HTLC fails to meet the forwarding + * requirements (i.e. insufficient fees paid, or a CLTV that is too soon). + */ + LDKEvent_HTLCHandlingFailed, /** * Must be last for serialization purposes */ @@ -2893,9 +3348,18 @@ typedef enum LDKEvent_Tag { typedef struct LDKEvent_LDKFundingGenerationReady_Body { /** * The random channel_id we picked which you'll need to pass into - * ChannelManager::funding_transaction_generated. + * [`ChannelManager::funding_transaction_generated`]. + * + * [`ChannelManager::funding_transaction_generated`]: crate::ln::channelmanager::ChannelManager::funding_transaction_generated */ struct LDKThirtyTwoBytes temporary_channel_id; + /** + * The counterparty's node_id, which you'll need to pass back into + * [`ChannelManager::funding_transaction_generated`]. + * + * [`ChannelManager::funding_transaction_generated`]: crate::ln::channelmanager::ChannelManager::funding_transaction_generated + */ + struct LDKPublicKey counterparty_node_id; /** * The value, in satoshis, that the output should have. */ @@ -2922,7 +3386,7 @@ typedef struct LDKEvent_LDKPaymentReceived_Body { /** * The value, in thousandths of a satoshi, that this payment is for. */ - uint64_t amt; + uint64_t amount_msat; /** * 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. @@ -2930,12 +3394,29 @@ typedef struct LDKEvent_LDKPaymentReceived_Body { struct LDKPaymentPurpose purpose; } LDKEvent_LDKPaymentReceived_Body; -typedef struct LDKEvent_LDKPaymentSent_Body { +typedef struct LDKEvent_LDKPaymentClaimed_Body { /** - * The id returned by [`ChannelManager::send_payment`] and used with - * [`ChannelManager::retry_payment`]. - * - * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment + * The payment hash of the claimed payment. 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 amount_msat; + /** + * The purpose of this claimed payment, i.e. whether the payment was for an invoice or a + * spontaneous payment. + */ + struct LDKPaymentPurpose purpose; +} LDKEvent_LDKPaymentClaimed_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 @@ -2967,6 +3448,49 @@ typedef struct LDKEvent_LDKPaymentSent_Body { struct LDKCOption_u64Z fee_paid_msat; } LDKEvent_LDKPaymentSent_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_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_LDKPaymentPathFailed_Body { /** * The id returned by [`ChannelManager::send_payment`] and used with @@ -2990,16 +3514,15 @@ typedef struct LDKEvent_LDKPaymentPathFailed_Body { * 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; + bool payment_failed_permanently; /** * 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. + * account the update. * - * [`NetworkGraph`]: crate::routing::network_graph::NetworkGraph - * [`NetGraphMsgHandler`]: crate::routing::network_graph::NetGraphMsgHandler + * [`NetworkGraph`]: crate::routing::gossip::NetworkGraph */ struct LDKCOption_NetworkUpdateZ network_update; /** @@ -3029,6 +3552,10 @@ typedef struct LDKEvent_LDKPaymentPathFailed_Body { /** * The channel responsible for the failed payment path. * + * Note that for route hints or for the first hop in a path this may be an SCID alias and + * may not refer to a channel in the public network graph. These aliases may also collide + * with channels in the public network graph. + * * If this is `Some`, then the corresponding channel should be avoided when the payment is * retried. May be `None` for older [`Event`] serializations. */ @@ -3046,23 +3573,51 @@ typedef struct LDKEvent_LDKPaymentPathFailed_Body { struct LDKRouteParameters retry; } LDKEvent_LDKPaymentPathFailed_Body; -typedef struct LDKEvent_LDKPaymentFailed_Body { +typedef struct LDKEvent_LDKProbeSuccessful_Body { /** - * The id returned by [`ChannelManager::send_payment`] and used with - * [`ChannelManager::retry_payment`] and [`ChannelManager::abandon_payment`]. + * The id returned by [`ChannelManager::send_probe`]. * - * [`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 + * [`ChannelManager::send_probe`]: crate::ln::channelmanager::ChannelManager::send_probe */ struct LDKThirtyTwoBytes payment_id; /** - * The hash that was given to [`ChannelManager::send_payment`]. + * The hash generated by [`ChannelManager::send_probe`]. * - * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment + * [`ChannelManager::send_probe`]: crate::ln::channelmanager::ChannelManager::send_probe */ struct LDKThirtyTwoBytes payment_hash; -} LDKEvent_LDKPaymentFailed_Body; + /** + * The payment path that was successful. + */ + struct LDKCVec_RouteHopZ path; +} LDKEvent_LDKProbeSuccessful_Body; + +typedef struct LDKEvent_LDKProbeFailed_Body { + /** + * The id returned by [`ChannelManager::send_probe`]. + * + * [`ChannelManager::send_probe`]: crate::ln::channelmanager::ChannelManager::send_probe + */ + struct LDKThirtyTwoBytes payment_id; + /** + * The hash generated by [`ChannelManager::send_probe`]. + * + * [`ChannelManager::send_probe`]: crate::ln::channelmanager::ChannelManager::send_probe + */ + struct LDKThirtyTwoBytes payment_hash; + /** + * The payment path that failed. + */ + struct LDKCVec_RouteHopZ path; + /** + * The channel responsible for the failed probe. + * + * Note that for route hints or for the first hop in a path this may be an SCID alias and + * may not refer to a channel in the public network graph. These aliases may also collide + * with channels in the public network graph. + */ + struct LDKCOption_u64Z short_channel_id; +} LDKEvent_LDKProbeFailed_Body; typedef struct LDKEvent_LDKPendingHTLCsForwardable_Body { /** @@ -3082,6 +3637,20 @@ typedef struct LDKEvent_LDKSpendableOutputs_Body { } LDKEvent_LDKSpendableOutputs_Body; typedef struct LDKEvent_LDKPaymentForwarded_Body { + /** + * The incoming channel between the previous node and us. This is only `None` for events + * generated or serialized by versions prior to 0.0.107. + * + * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + */ + struct LDKThirtyTwoBytes prev_channel_id; + /** + * The outgoing channel between the next node and us. This is only `None` for events + * generated or serialized by versions prior to 0.0.107. + * + * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + */ + struct LDKThirtyTwoBytes next_channel_id; /** * The fee, in milli-satoshis, which was earned as a result of the payment. * @@ -3112,11 +3681,15 @@ typedef struct LDKEvent_LDKChannelClosed_Body { */ struct LDKThirtyTwoBytes channel_id; /** - * 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. + * 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; /** @@ -3136,45 +3709,28 @@ typedef struct LDKEvent_LDKDiscardFunding_Body { 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. + * back to the ChannelManager through [`ChannelManager::accept_inbound_channel`] to accept, + * or through [`ChannelManager::force_close_without_broadcasting_txn`] to reject. * * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel - * [`ChannelManager::force_close_channel`]: crate::ln::channelmanager::ChannelManager::force_close_channel + * [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn */ struct LDKThirtyTwoBytes temporary_channel_id; /** * The node_id of the counterparty requesting to open the channel. + * + * When responding to the request, the `counterparty_node_id` should be passed + * back to the `ChannelManager` through [`ChannelManager::accept_inbound_channel`] to + * accept the request, or through [`ChannelManager::force_close_without_broadcasting_txn`] to reject the + * request. + * + * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel + * [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn */ struct LDKPublicKey counterparty_node_id; /** @@ -3185,23 +3741,56 @@ typedef struct LDKEvent_LDKOpenChannelRequest_Body { * 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. + * + * Furthermore, note that if [`ChannelTypeFeatures::supports_zero_conf`] returns true on this type, + * the resulting [`ChannelManager`] will not be readable by versions of LDK prior to + * 0.0.107. Channels setting this type also need to get manually accepted via + * [`crate::ln::channelmanager::ChannelManager::accept_inbound_channel_from_trusted_peer_0conf`], + * or will be rejected otherwise. + * + * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager + */ + struct LDKChannelTypeFeatures channel_type; } LDKEvent_LDKOpenChannelRequest_Body; +typedef struct LDKEvent_LDKHTLCHandlingFailed_Body { + /** + * The channel over which the HTLC was received. + */ + struct LDKThirtyTwoBytes prev_channel_id; + /** + * Destination of the HTLC that failed to be processed. + */ + struct LDKHTLCDestination failed_next_destination; +} LDKEvent_LDKHTLCHandlingFailed_Body; + typedef struct MUST_USE_STRUCT LDKEvent { LDKEvent_Tag tag; union { LDKEvent_LDKFundingGenerationReady_Body funding_generation_ready; LDKEvent_LDKPaymentReceived_Body payment_received; + LDKEvent_LDKPaymentClaimed_Body payment_claimed; LDKEvent_LDKPaymentSent_Body payment_sent; - LDKEvent_LDKPaymentPathFailed_Body payment_path_failed; LDKEvent_LDKPaymentFailed_Body payment_failed; + LDKEvent_LDKPaymentPathSuccessful_Body payment_path_successful; + LDKEvent_LDKPaymentPathFailed_Body payment_path_failed; + LDKEvent_LDKProbeSuccessful_Body probe_successful; + LDKEvent_LDKProbeFailed_Body probe_failed; LDKEvent_LDKPendingHTLCsForwardable_Body pending_htl_cs_forwardable; LDKEvent_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_LDKHTLCHandlingFailed_Body htlc_handling_failed; }; } LDKEvent; @@ -3348,22 +3937,22 @@ typedef struct MUST_USE_STRUCT LDKFundingSigned { /** - * A funding_locked message to be sent or received from a peer + * A channel_ready message to be sent or received from a peer */ -typedef struct MUST_USE_STRUCT LDKFundingLocked { +typedef struct MUST_USE_STRUCT LDKChannelReady { /** * A pointer to the opaque Rust object. * Nearly everywhere, 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; + LDKnativeChannelReady *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; +} LDKChannelReady; @@ -3508,26 +4097,6 @@ typedef struct MUST_USE_STRUCT LDKChannelAnnouncement { -/** - * A node_announcement message to be sent or received from a peer - */ -typedef struct MUST_USE_STRUCT LDKNodeAnnouncement { - /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. - */ - LDKnativeNodeAnnouncement *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; -} LDKNodeAnnouncement; - - - /** * An error message to be sent or received from a peer */ @@ -3720,6 +4289,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). @@ -3745,9 +4336,9 @@ typedef enum LDKMessageSendEvent_Tag { */ LDKMessageSendEvent_SendFundingSigned, /** - * Used to indicate that a funding_locked message should be sent to the peer with the given node_id. + * Used to indicate that a channel_ready message should be sent to the peer with the given node_id. */ - LDKMessageSendEvent_SendFundingLocked, + LDKMessageSendEvent_SendChannelReady, /** * Used to indicate that an announcement_signatures message should be sent to the peer with the given node_id. */ @@ -3773,21 +4364,24 @@ typedef enum LDKMessageSendEvent_Tag { * Used to indicate that a channel_reestablish message should be sent to the peer with the given node_id. */ LDKMessageSendEvent_SendChannelReestablish, + /** + * Used to send a channel_announcement and channel_update to a specific peer, likely on + * initial connection to ensure our peers know about our channels. + */ + LDKMessageSendEvent_SendChannelAnnouncement, /** * Used to indicate that a channel_announcement and channel_update should be broadcast to all * peers (except the peer with node_id either msg.contents.node_id_1 or msg.contents.node_id_2). * - * Note that after doing so, you very likely (unless you did so very recently) want to call - * ChannelManager::broadcast_node_announcement to trigger a BroadcastNodeAnnouncement event. - * This ensures that any nodes which see our channel_announcement also have a relevant + * Note that after doing so, you very likely (unless you did so very recently) want to + * broadcast a node_announcement (e.g. via [`PeerManager::broadcast_node_announcement`]). This + * ensures that any nodes which see our channel_announcement also have a relevant * node_announcement, including relevant feature flags which may be important for routing * through or to us. + * + * [`PeerManager::broadcast_node_announcement`]: crate::ln::peer_handler::PeerManager::broadcast_node_announcement */ LDKMessageSendEvent_BroadcastChannelAnnouncement, - /** - * Used to indicate that a node_announcement should be broadcast to all peers. - */ - LDKMessageSendEvent_BroadcastNodeAnnouncement, /** * Used to indicate that a channel_update should be broadcast to all peers. */ @@ -3816,6 +4410,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 */ @@ -3866,16 +4465,16 @@ typedef struct LDKMessageSendEvent_LDKSendFundingSigned_Body { struct LDKFundingSigned msg; } LDKMessageSendEvent_LDKSendFundingSigned_Body; -typedef struct LDKMessageSendEvent_LDKSendFundingLocked_Body { +typedef struct LDKMessageSendEvent_LDKSendChannelReady_Body { /** * The node_id of the node which should receive these message(s) */ struct LDKPublicKey node_id; /** - * The funding_locked message which should be sent. + * The channel_ready message which should be sent. */ - struct LDKFundingLocked msg; -} LDKMessageSendEvent_LDKSendFundingLocked_Body; + struct LDKChannelReady msg; +} LDKMessageSendEvent_LDKSendChannelReady_Body; typedef struct LDKMessageSendEvent_LDKSendAnnouncementSignatures_Body { /** @@ -3943,7 +4542,11 @@ typedef struct LDKMessageSendEvent_LDKSendChannelReestablish_Body { struct LDKChannelReestablish msg; } LDKMessageSendEvent_LDKSendChannelReestablish_Body; -typedef struct LDKMessageSendEvent_LDKBroadcastChannelAnnouncement_Body { +typedef struct LDKMessageSendEvent_LDKSendChannelAnnouncement_Body { + /** + * The node_id of the node which should receive this message + */ + struct LDKPublicKey node_id; /** * The channel_announcement which should be sent. */ @@ -3952,14 +4555,18 @@ typedef struct LDKMessageSendEvent_LDKBroadcastChannelAnnouncement_Body { * The followup channel_update which should be sent. */ struct LDKChannelUpdate update_msg; -} LDKMessageSendEvent_LDKBroadcastChannelAnnouncement_Body; +} LDKMessageSendEvent_LDKSendChannelAnnouncement_Body; -typedef struct LDKMessageSendEvent_LDKBroadcastNodeAnnouncement_Body { +typedef struct LDKMessageSendEvent_LDKBroadcastChannelAnnouncement_Body { /** - * The node_announcement which should be sent. + * The channel_announcement which should be sent. + */ + struct LDKChannelAnnouncement msg; + /** + * The followup channel_update which should be sent. */ - struct LDKNodeAnnouncement msg; -} LDKMessageSendEvent_LDKBroadcastNodeAnnouncement_Body; + struct LDKChannelUpdate update_msg; +} LDKMessageSendEvent_LDKBroadcastChannelAnnouncement_Body; typedef struct LDKMessageSendEvent_LDKBroadcastChannelUpdate_Body { /** @@ -4023,6 +4630,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 { @@ -4030,21 +4648,22 @@ typedef struct MUST_USE_STRUCT LDKMessageSendEvent { LDKMessageSendEvent_LDKSendOpenChannel_Body send_open_channel; LDKMessageSendEvent_LDKSendFundingCreated_Body send_funding_created; LDKMessageSendEvent_LDKSendFundingSigned_Body send_funding_signed; - LDKMessageSendEvent_LDKSendFundingLocked_Body send_funding_locked; + LDKMessageSendEvent_LDKSendChannelReady_Body send_channel_ready; LDKMessageSendEvent_LDKSendAnnouncementSignatures_Body send_announcement_signatures; LDKMessageSendEvent_LDKUpdateHTLCs_Body update_htl_cs; LDKMessageSendEvent_LDKSendRevokeAndACK_Body send_revoke_and_ack; LDKMessageSendEvent_LDKSendClosingSigned_Body send_closing_signed; LDKMessageSendEvent_LDKSendShutdown_Body send_shutdown; LDKMessageSendEvent_LDKSendChannelReestablish_Body send_channel_reestablish; + LDKMessageSendEvent_LDKSendChannelAnnouncement_Body send_channel_announcement; LDKMessageSendEvent_LDKBroadcastChannelAnnouncement_Body broadcast_channel_announcement; - LDKMessageSendEvent_LDKBroadcastNodeAnnouncement_Body broadcast_node_announcement; LDKMessageSendEvent_LDKBroadcastChannelUpdate_Body broadcast_channel_update; LDKMessageSendEvent_LDKSendChannelUpdate_Body send_channel_update; LDKMessageSendEvent_LDKHandleError_Body handle_error; LDKMessageSendEvent_LDKSendChannelRangeQuery_Body send_channel_range_query; LDKMessageSendEvent_LDKSendShortIdsQuery_Body send_short_ids_query; LDKMessageSendEvent_LDKSendReplyChannelRange_Body send_reply_channel_range; + LDKMessageSendEvent_LDKSendGossipTimestampFilter_Body send_gossip_timestamp_filter; }; } LDKMessageSendEvent; @@ -4064,229 +4683,370 @@ typedef struct LDKCVec_MessageSendEventZ { 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 + * The contents of CResult_TxOutAccessErrorZ */ -typedef union LDKCResult_FixedPenaltyScorerDecodeErrorZPtr { +typedef union LDKCResult_TxOutAccessErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKFixedPenaltyScorer *result; + struct LDKTxOut *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; + enum LDKAccessError *err; +} LDKCResult_TxOutAccessErrorZPtr; /** - * A CResult_FixedPenaltyScorerDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::routing::scoring::FixedPenaltyScorer on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_TxOutAccessErrorZ represents the result of a fallible operation, + * containing a crate::c_types::TxOut on success and a crate::lightning::chain::AccessError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_FixedPenaltyScorerDecodeErrorZ { +typedef struct LDKCResult_TxOutAccessErrorZ { /** - * The contents of this CResult_FixedPenaltyScorerDecodeErrorZ, accessible via either + * The contents of this CResult_TxOutAccessErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_FixedPenaltyScorerDecodeErrorZPtr contents; + union LDKCResult_TxOutAccessErrorZPtr contents; /** - * Whether this CResult_FixedPenaltyScorerDecodeErrorZ represents a success state. + * Whether this CResult_TxOutAccessErrorZ represents a success state. */ bool result_ok; -} LDKCResult_FixedPenaltyScorerDecodeErrorZ; +} LDKCResult_TxOutAccessErrorZ; + +/** + * A tuple of 2 elements. See the individual fields for the types contained. + */ +typedef struct LDKC2Tuple_usizeTransactionZ { + /** + * The element at position 0 + */ + uintptr_t a; + /** + * The element at position 1 + */ + struct LDKTransaction b; +} LDKC2Tuple_usizeTransactionZ; + +/** + * A dynamically-allocated array of crate::c_types::derived::C2Tuple_usizeTransactionZs of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_C2Tuple_usizeTransactionZZ { + /** + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + */ + struct LDKC2Tuple_usizeTransactionZ *data; + /** + * The number of elements pointed to by `data`. + */ + uintptr_t datalen; +} LDKCVec_C2Tuple_usizeTransactionZZ; + +/** + * A dynamically-allocated array of crate::c_types::ThirtyTwoBytess of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_TxidZ { + /** + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + */ + struct LDKThirtyTwoBytes *data; + /** + * The number of elements pointed to by `data`. + */ + uintptr_t datalen; +} LDKCVec_TxidZ; /** - * Parameters for configuring [`Scorer`]. + * Simple structure sent back by `chain::Watch` when an HTLC from a forward channel is detected on + * chain. Used to update the corresponding HTLC in the backward channel. Failing to pass the + * preimage claim backward will lead to loss of funds. */ -typedef struct MUST_USE_STRUCT LDKScoringParameters { +typedef struct MUST_USE_STRUCT LDKHTLCUpdate { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeScoringParameters *inner; + LDKnativeHTLCUpdate *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKScoringParameters; +} LDKHTLCUpdate; /** - * The contents of CResult_ScoringParametersDecodeErrorZ + * An event to be processed by the ChannelManager. */ -typedef union LDKCResult_ScoringParametersDecodeErrorZPtr { +typedef enum LDKMonitorEvent_Tag { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * A monitor event containing an HTLCUpdate. */ - struct LDKScoringParameters *result; + LDKMonitorEvent_HTLCEvent, /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * A monitor event that the Channel's commitment transaction was confirmed. */ - struct LDKDecodeError *err; -} LDKCResult_ScoringParametersDecodeErrorZPtr; + LDKMonitorEvent_CommitmentTxConfirmed, + /** + * Indicates a [`ChannelMonitor`] update has completed. See + * [`ChannelMonitorUpdateStatus::InProgress`] for more information on how this is used. + * + * [`ChannelMonitorUpdateStatus::InProgress`]: super::ChannelMonitorUpdateStatus::InProgress + */ + LDKMonitorEvent_Completed, + /** + * Indicates a [`ChannelMonitor`] update has failed. See + * [`ChannelMonitorUpdateStatus::PermanentFailure`] for more information on how this is used. + * + * [`ChannelMonitorUpdateStatus::PermanentFailure`]: super::ChannelMonitorUpdateStatus::PermanentFailure + */ + LDKMonitorEvent_UpdateFailed, + /** + * Must be last for serialization purposes + */ + LDKMonitorEvent_Sentinel, +} LDKMonitorEvent_Tag; + +typedef struct LDKMonitorEvent_LDKCompleted_Body { + /** + * The funding outpoint of the [`ChannelMonitor`] that was updated + */ + struct LDKOutPoint funding_txo; + /** + * The Update ID from [`ChannelMonitorUpdate::update_id`] which was applied or + * [`ChannelMonitor::get_latest_update_id`]. + * + * Note that this should only be set to a given update's ID if all previous updates for the + * same [`ChannelMonitor`] have been applied and persisted. + */ + uint64_t monitor_update_id; +} LDKMonitorEvent_LDKCompleted_Body; + +typedef struct MUST_USE_STRUCT LDKMonitorEvent { + LDKMonitorEvent_Tag tag; + union { + struct { + struct LDKHTLCUpdate htlc_event; + }; + struct { + struct LDKOutPoint commitment_tx_confirmed; + }; + LDKMonitorEvent_LDKCompleted_Body completed; + struct { + struct LDKOutPoint update_failed; + }; + }; +} LDKMonitorEvent; /** - * A 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`. + * A dynamically-allocated array of crate::lightning::chain::channelmonitor::MonitorEvents of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef struct LDKCResult_ScoringParametersDecodeErrorZ { +typedef struct LDKCVec_MonitorEventZ { /** - * The contents of this CResult_ScoringParametersDecodeErrorZ, 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_ScoringParametersDecodeErrorZPtr contents; + struct LDKMonitorEvent *data; /** - * Whether this CResult_ScoringParametersDecodeErrorZ represents a success state. + * The number of elements pointed to by `data`. */ - bool result_ok; -} LDKCResult_ScoringParametersDecodeErrorZ; + uintptr_t datalen; +} LDKCVec_MonitorEventZ; + +/** + * A tuple of 3 elements. See the individual fields for the types contained. + */ +typedef struct LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ { + /** + * The element at position 0 + */ + struct LDKOutPoint a; + /** + * The element at position 1 + */ + struct LDKCVec_MonitorEventZ b; + /** + * The element at position 2 + */ + struct LDKPublicKey c; +} LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ; + +/** + * A dynamically-allocated array of crate::c_types::derived::C3Tuple_OutPointCVec_MonitorEventZPublicKeyZs of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ { + /** + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + */ + struct LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *data; + /** + * The number of elements pointed to by `data`. + */ + uintptr_t datalen; +} LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ; /** - * [`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 + * [`Score`] implementation that uses a fixed penalty. */ -typedef struct MUST_USE_STRUCT LDKScorer { +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. */ - LDKnativeScorer *inner; + 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; -} LDKScorer; +} LDKFixedPenaltyScorer; /** - * The contents of CResult_ScorerDecodeErrorZ + * The contents of CResult_FixedPenaltyScorerDecodeErrorZ */ -typedef union LDKCResult_ScorerDecodeErrorZPtr { +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 LDKScorer *result; + struct LDKFixedPenaltyScorer *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_ScorerDecodeErrorZPtr; +} LDKCResult_FixedPenaltyScorerDecodeErrorZPtr; /** - * 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. + * 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_ScorerDecodeErrorZ { +typedef struct LDKCResult_FixedPenaltyScorerDecodeErrorZ { /** - * The contents of this CResult_ScorerDecodeErrorZ, accessible via either + * The contents of this CResult_FixedPenaltyScorerDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_ScorerDecodeErrorZPtr contents; + union LDKCResult_FixedPenaltyScorerDecodeErrorZPtr contents; /** - * Whether this CResult_ScorerDecodeErrorZ represents a success state. + * Whether this CResult_FixedPenaltyScorerDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_ScorerDecodeErrorZ; +} LDKCResult_FixedPenaltyScorerDecodeErrorZ; + +/** + * A tuple of 2 elements. See the individual fields for the types contained. + */ +typedef struct LDKC2Tuple_u64u64Z { + /** + * The element at position 0 + */ + uint64_t a; + /** + * The element at position 1 + */ + uint64_t b; +} LDKC2Tuple_u64u64Z; +/** + * An enum which can either contain a crate::c_types::derived::C2Tuple_u64u64Z or not + */ +typedef enum LDKCOption_C2Tuple_u64u64ZZ_Tag { + /** + * When we're in this state, this COption_C2Tuple_u64u64ZZ contains a crate::c_types::derived::C2Tuple_u64u64Z + */ + LDKCOption_C2Tuple_u64u64ZZ_Some, + /** + * When we're in this state, this COption_C2Tuple_u64u64ZZ contains nothing + */ + LDKCOption_C2Tuple_u64u64ZZ_None, + /** + * Must be last for serialization purposes + */ + LDKCOption_C2Tuple_u64u64ZZ_Sentinel, +} LDKCOption_C2Tuple_u64u64ZZ_Tag; +typedef struct LDKCOption_C2Tuple_u64u64ZZ { + LDKCOption_C2Tuple_u64u64ZZ_Tag tag; + union { + struct { + struct LDKC2Tuple_u64u64Z some; + }; + }; +} LDKCOption_C2Tuple_u64u64ZZ; /** - * Parameters for configuring [`ProbabilisticScorer`]. + * A dynamically-allocated array of crate::lightning::routing::gossip::NodeIds of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef struct MUST_USE_STRUCT LDKProbabilisticScoringParameters { +typedef struct LDKCVec_NodeIdZ { + /** + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + */ + struct LDKNodeId *data; + /** + * The number of elements pointed to by `data`. + */ + uintptr_t datalen; +} LDKCVec_NodeIdZ; + + + +/** + * 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 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. */ - LDKnativeProbabilisticScoringParameters *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; -} LDKProbabilisticScoringParameters; +} LDKRecord; /** - * The contents of CResult_ProbabilisticScoringParametersDecodeErrorZ + * A trait encapsulating the operations required of a logger */ -typedef union LDKCResult_ProbabilisticScoringParametersDecodeErrorZPtr { - /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. - */ - struct LDKProbabilisticScoringParameters *result; +typedef struct LDKLogger { /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is 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 LDKDecodeError *err; -} LDKCResult_ProbabilisticScoringParametersDecodeErrorZPtr; - -/** - * A CResult_ProbabilisticScoringParametersDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::routing::scoring::ProbabilisticScoringParameters on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_ProbabilisticScoringParametersDecodeErrorZ { + void *this_arg; /** - * The contents of this CResult_ProbabilisticScoringParametersDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * Logs the `Record` */ - union LDKCResult_ProbabilisticScoringParametersDecodeErrorZPtr contents; + void (*log)(const void *this_arg, const struct LDKRecord *NONNULL_PTR record); /** - * Whether this CResult_ProbabilisticScoringParametersDecodeErrorZ represents a success state. + * 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 result_ok; -} LDKCResult_ProbabilisticScoringParametersDecodeErrorZ; + void (*free)(void *this_arg); +} LDKLogger; @@ -4308,38 +5068,33 @@ typedef struct MUST_USE_STRUCT LDKNetworkGraph { bool is_owned; } LDKNetworkGraph; -/** - * A tuple of 2 elements. See the individual fields for the types contained. - */ -typedef struct LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ { - /** - * The element at position 0 - */ - struct LDKProbabilisticScoringParameters a; - /** - * The element at position 1 - */ - struct LDKNetworkGraph b; -} LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ; - /** * [`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. + * Channels are tracked with upper and lower liquidity bounds - when an HTLC fails at a channel, + * we learn that the upper-bound on the available liquidity is lower than the amount of the HTLC. + * When a payment is forwarded through a channel (but fails later in the route), we learn the + * lower-bound on the channel's available liquidity must be at least the value of the HTLC. * - * 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. + * These bounds are then used to determine a success probability using the formula from + * *Optimally Reliable & Cheap Payment Flows on the Lightning Network* by Rene Pickhardt + * and Stefan Richter [[1]] (i.e. `(upper_bound - payment_amount) / (upper_bound - lower_bound)`). * - * 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. + * This probability is combined with the [`liquidity_penalty_multiplier_msat`] and + * [`liquidity_penalty_amount_multiplier_msat`] parameters to calculate a concrete penalty in + * milli-satoshis. The penalties, when added across all hops, have the property of being linear in + * terms of the entire path's success probability. This allows the router to directly compare + * penalties for different paths. See the documentation of those parameters for the exact formulas. + * + * The liquidity bounds are decayed by halving them every [`liquidity_offset_half_life`]. + * + * Further, we track the history of our upper and lower liquidity bounds for each channel, + * allowing us to assign a second penalty (using [`historical_liquidity_penalty_multiplier_msat`] + * and [`historical_liquidity_penalty_amount_multiplier_msat`]) based on the same probability + * formula, but using the history of a channel rather than our latest estimates for the liquidity + * bounds. * * # Note * @@ -4347,6 +5102,11 @@ typedef struct LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ { * behavior. * * [1]: https://arxiv.org/abs/2107.05322 + * [`liquidity_penalty_multiplier_msat`]: ProbabilisticScoringParameters::liquidity_penalty_multiplier_msat + * [`liquidity_penalty_amount_multiplier_msat`]: ProbabilisticScoringParameters::liquidity_penalty_amount_multiplier_msat + * [`liquidity_offset_half_life`]: ProbabilisticScoringParameters::liquidity_offset_half_life + * [`historical_liquidity_penalty_multiplier_msat`]: ProbabilisticScoringParameters::historical_liquidity_penalty_multiplier_msat + * [`historical_liquidity_penalty_amount_multiplier_msat`]: ProbabilisticScoringParameters::historical_liquidity_penalty_amount_multiplier_msat */ typedef struct MUST_USE_STRUCT LDKProbabilisticScorer { /** @@ -4608,35 +5368,6 @@ typedef struct LDKCResult_InvoiceFeaturesDecodeErrorZ { bool result_ok; } LDKCResult_InvoiceFeaturesDecodeErrorZ; - - -/** - * Features used within the channel_type field in an OpenChannel message. - * - * A channel is always of some known \"type\", describing the transaction formats used and the exact - * semantics of our interaction with our peer. - * - * Note that because a channel is a specific type which is proposed by the opener and accepted by - * the counterparty, only required features are allowed here. - * - * This is serialized differently from other feature types - it is not prefixed by a length, and - * thus must only appear inside a TLV where its length is known in advance. - */ -typedef struct MUST_USE_STRUCT LDKChannelTypeFeatures { - /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. - */ - LDKnativeChannelTypeFeatures *inner; - /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. - */ - bool is_owned; -} LDKChannelTypeFeatures; - /** * The contents of CResult_ChannelTypeFeaturesDecodeErrorZ */ @@ -4671,2449 +5402,2343 @@ typedef struct LDKCResult_ChannelTypeFeaturesDecodeErrorZ { } LDKCResult_ChannelTypeFeaturesDecodeErrorZ; /** - * The contents of CResult_DelayedPaymentOutputDescriptorDecodeErrorZ + * The contents of CResult_NodeIdDecodeErrorZ */ -typedef union LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZPtr { +typedef union LDKCResult_NodeIdDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKDelayedPaymentOutputDescriptor *result; + struct LDKNodeId *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_DelayedPaymentOutputDescriptorDecodeErrorZPtr; +} LDKCResult_NodeIdDecodeErrorZPtr; /** - * A CResult_DelayedPaymentOutputDescriptorDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::chain::keysinterface::DelayedPaymentOutputDescriptor on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_NodeIdDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::routing::gossip::NodeId 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_DelayedPaymentOutputDescriptorDecodeErrorZ { +typedef struct LDKCResult_NodeIdDecodeErrorZ { /** - * The contents of this CResult_DelayedPaymentOutputDescriptorDecodeErrorZ, accessible via either + * The contents of this CResult_NodeIdDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZPtr contents; + union LDKCResult_NodeIdDecodeErrorZPtr contents; /** - * Whether this CResult_DelayedPaymentOutputDescriptorDecodeErrorZ represents a success state. + * Whether this CResult_NodeIdDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ; +} LDKCResult_NodeIdDecodeErrorZ; /** - * The contents of CResult_StaticPaymentOutputDescriptorDecodeErrorZ + * The contents of CResult_COption_NetworkUpdateZDecodeErrorZ */ -typedef union LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZPtr { +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 LDKStaticPaymentOutputDescriptor *result; + 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_StaticPaymentOutputDescriptorDecodeErrorZPtr; +} LDKCResult_COption_NetworkUpdateZDecodeErrorZPtr; /** - * A CResult_StaticPaymentOutputDescriptorDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::chain::keysinterface::StaticPaymentOutputDescriptor on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_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_StaticPaymentOutputDescriptorDecodeErrorZ { +typedef struct LDKCResult_COption_NetworkUpdateZDecodeErrorZ { /** - * The contents of this CResult_StaticPaymentOutputDescriptorDecodeErrorZ, accessible via either + * The contents of this CResult_COption_NetworkUpdateZDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZPtr contents; + union LDKCResult_COption_NetworkUpdateZDecodeErrorZPtr contents; /** - * Whether this CResult_StaticPaymentOutputDescriptorDecodeErrorZ represents a success state. + * Whether this CResult_COption_NetworkUpdateZDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ; +} LDKCResult_COption_NetworkUpdateZDecodeErrorZ; /** - * The contents of CResult_SpendableOutputDescriptorDecodeErrorZ + * The `Access` trait defines behavior for accessing chain data and state, such as blocks and + * UTXOs. */ -typedef union LDKCResult_SpendableOutputDescriptorDecodeErrorZPtr { +typedef struct LDKAccess { /** - * 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 LDKSpendableOutputDescriptor *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 transaction output of a funding transaction encoded by [`short_channel_id`]. + * Returns an error if `genesis_hash` is for a different chain or if such a transaction output + * is unknown. + * + * [`short_channel_id`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#definition-of-short_channel_id */ - struct LDKDecodeError *err; -} LDKCResult_SpendableOutputDescriptorDecodeErrorZPtr; + struct LDKCResult_TxOutAccessErrorZ (*get_utxo)(const void *this_arg, const uint8_t (*genesis_hash)[32], uint64_t short_channel_id); + /** + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + */ + void (*free)(void *this_arg); +} LDKAccess; /** - * A CResult_SpendableOutputDescriptorDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::chain::keysinterface::SpendableOutputDescriptor on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. + * An enum which can either contain a crate::lightning::chain::Access or not */ -typedef struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ { +typedef enum LDKCOption_AccessZ_Tag { /** - * The contents of this CResult_SpendableOutputDescriptorDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * When we're in this state, this COption_AccessZ contains a crate::lightning::chain::Access */ - union LDKCResult_SpendableOutputDescriptorDecodeErrorZPtr contents; + LDKCOption_AccessZ_Some, /** - * Whether this CResult_SpendableOutputDescriptorDecodeErrorZ represents a success state. + * When we're in this state, this COption_AccessZ contains nothing */ - bool result_ok; -} LDKCResult_SpendableOutputDescriptorDecodeErrorZ; + LDKCOption_AccessZ_None, + /** + * Must be last for serialization purposes + */ + LDKCOption_AccessZ_Sentinel, +} LDKCOption_AccessZ_Tag; + +typedef struct LDKCOption_AccessZ { + LDKCOption_AccessZ_Tag tag; + union { + struct { + struct LDKAccess some; + }; + }; +} LDKCOption_AccessZ; /** - * A dynamically-allocated array of crate::c_types::ThirtyTwoBytess of arbitrary size. - * This corresponds to std::vector in C++ + * The contents of CResult_boolLightningErrorZ */ -typedef struct LDKCVec_PaymentPreimageZ { +typedef union LDKCResult_boolLightningErrorZPtr { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKThirtyTwoBytes *data; + bool *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_PaymentPreimageZ; + struct LDKLightningError *err; +} LDKCResult_boolLightningErrorZPtr; /** - * A tuple of 2 elements. See the individual fields for the types contained. + * A CResult_boolLightningErrorZ represents the result of a fallible operation, + * containing a bool on success and a crate::lightning::ln::msgs::LightningError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKC2Tuple_SignatureCVec_SignatureZZ { +typedef struct LDKCResult_boolLightningErrorZ { /** - * The element at position 0 + * The contents of this CResult_boolLightningErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKSignature a; + union LDKCResult_boolLightningErrorZPtr contents; /** - * The element at position 1 + * Whether this CResult_boolLightningErrorZ represents a success state. */ - struct LDKCVec_SignatureZ b; -} LDKC2Tuple_SignatureCVec_SignatureZZ; + bool result_ok; +} LDKCResult_boolLightningErrorZ; /** - * The contents of CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ + * A tuple of 3 elements. See the individual fields for the types contained. */ -typedef union LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr { +typedef struct LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * The element at position 0 */ - struct LDKC2Tuple_SignatureCVec_SignatureZZ *result; + struct LDKChannelAnnouncement a; /** - * Note that this value is always NULL, as there are no contents in the Err variant + * The element at position 1 */ - void *err; -} LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr; + struct LDKChannelUpdate b; + /** + * The element at position 2 + */ + struct LDKChannelUpdate c; +} LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ; /** - * A CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ represents the result of a fallible operation, - * containing a crate::c_types::derived::C2Tuple_SignatureCVec_SignatureZZ on success and a () on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. + * An enum which can either contain a crate::c_types::derived::C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ or not */ -typedef struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { +typedef enum LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Tag { /** - * The contents of this CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * When we're in this state, this COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ contains a crate::c_types::derived::C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ */ - union LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr contents; + LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some, /** - * Whether this CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ represents a success state. + * When we're in this state, this COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ contains nothing */ - bool result_ok; -} LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ; + LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None, + /** + * Must be last for serialization purposes + */ + LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Sentinel, +} LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Tag; + +typedef struct LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ { + LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Tag tag; + union { + struct { + struct LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ some; + }; + }; +} LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ; /** - * The contents of CResult_SignatureNoneZ + * The contents of CResult_NoneLightningErrorZ */ -typedef union LDKCResult_SignatureNoneZPtr { +typedef union LDKCResult_NoneLightningErrorZPtr { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * Note that this value is always NULL, as there are no contents in the OK variant */ - struct LDKSignature *result; + void *result; /** - * Note that this value is always NULL, as there are no contents in the Err variant + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - void *err; -} LDKCResult_SignatureNoneZPtr; + struct LDKLightningError *err; +} LDKCResult_NoneLightningErrorZPtr; /** - * A CResult_SignatureNoneZ represents the result of a fallible operation, - * containing a crate::c_types::Signature on success and a () on failure. + * A CResult_NoneLightningErrorZ represents the result of a fallible operation, + * containing a () on success and a crate::lightning::ln::msgs::LightningError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_SignatureNoneZ { +typedef struct LDKCResult_NoneLightningErrorZ { /** - * The contents of this CResult_SignatureNoneZ, accessible via either + * The contents of this CResult_NoneLightningErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_SignatureNoneZPtr contents; + union LDKCResult_NoneLightningErrorZPtr contents; /** - * Whether this CResult_SignatureNoneZ represents a success state. + * Whether this CResult_NoneLightningErrorZ represents a success state. */ bool result_ok; -} LDKCResult_SignatureNoneZ; +} LDKCResult_NoneLightningErrorZ; + + /** - * A tuple of 2 elements. See the individual fields for the types contained. + * Details about one direction of a channel as received within a [`ChannelUpdate`]. */ -typedef struct LDKC2Tuple_SignatureSignatureZ { +typedef struct MUST_USE_STRUCT LDKChannelUpdateInfo { /** - * 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 LDKSignature a; + LDKnativeChannelUpdateInfo *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 LDKSignature b; -} LDKC2Tuple_SignatureSignatureZ; + bool is_owned; +} LDKChannelUpdateInfo; /** - * The contents of CResult_C2Tuple_SignatureSignatureZNoneZ + * The contents of CResult_ChannelUpdateInfoDecodeErrorZ */ -typedef union LDKCResult_C2Tuple_SignatureSignatureZNoneZPtr { +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 LDKC2Tuple_SignatureSignatureZ *result; + struct LDKChannelUpdateInfo *result; /** - * Note that this value is always NULL, as there are no contents in the Err variant + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - void *err; -} LDKCResult_C2Tuple_SignatureSignatureZNoneZPtr; - + struct LDKDecodeError *err; +} LDKCResult_ChannelUpdateInfoDecodeErrorZPtr; + /** - * 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. + * A CResult_ChannelUpdateInfoDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::routing::gossip::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_C2Tuple_SignatureSignatureZNoneZ { +typedef struct LDKCResult_ChannelUpdateInfoDecodeErrorZ { /** - * The contents of this CResult_C2Tuple_SignatureSignatureZNoneZ, accessible via either + * The contents of this CResult_ChannelUpdateInfoDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_C2Tuple_SignatureSignatureZNoneZPtr contents; + union LDKCResult_ChannelUpdateInfoDecodeErrorZPtr contents; /** - * Whether this CResult_C2Tuple_SignatureSignatureZNoneZ represents a success state. + * Whether this CResult_ChannelUpdateInfoDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_C2Tuple_SignatureSignatureZNoneZ; +} LDKCResult_ChannelUpdateInfoDecodeErrorZ; + + /** - * The contents of CResult_SecretKeyNoneZ + * Details about a channel (both directions). + * Received within a channel announcement. */ -typedef union LDKCResult_SecretKeyNoneZPtr { +typedef struct MUST_USE_STRUCT LDKChannelInfo { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeChannelInfo *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; +} LDKChannelInfo; + +/** + * The contents of CResult_ChannelInfoDecodeErrorZ + */ +typedef union LDKCResult_ChannelInfoDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKSecretKey *result; + struct LDKChannelInfo *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_SecretKeyNoneZPtr; + struct LDKDecodeError *err; +} LDKCResult_ChannelInfoDecodeErrorZPtr; /** - * A CResult_SecretKeyNoneZ represents the result of a fallible operation, - * containing a crate::c_types::SecretKey on success and a () on failure. + * A CResult_ChannelInfoDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::routing::gossip::ChannelInfo 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_SecretKeyNoneZ { +typedef struct LDKCResult_ChannelInfoDecodeErrorZ { /** - * The contents of this CResult_SecretKeyNoneZ, accessible via either + * The contents of this CResult_ChannelInfoDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_SecretKeyNoneZPtr contents; + union LDKCResult_ChannelInfoDecodeErrorZPtr contents; /** - * Whether this CResult_SecretKeyNoneZ represents a success state. + * Whether this CResult_ChannelInfoDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_SecretKeyNoneZ; +} LDKCResult_ChannelInfoDecodeErrorZ; /** - * This class tracks the per-transaction information needed to build a closing transaction and will - * actually build it and sign. - * - * This class can be used inside a signer implementation to generate a signature given the relevant - * secret key. + * Fees for routing via a given channel or a node */ -typedef struct MUST_USE_STRUCT LDKClosingTransaction { +typedef struct MUST_USE_STRUCT LDKRoutingFees { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeClosingTransaction *inner; + LDKnativeRoutingFees *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; -} LDKClosingTransaction; +} LDKRoutingFees; + +/** + * The contents of CResult_RoutingFeesDecodeErrorZ + */ +typedef union LDKCResult_RoutingFeesDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKRoutingFees *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_RoutingFeesDecodeErrorZPtr; + +/** + * A CResult_RoutingFeesDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::routing::gossip::RoutingFees on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_RoutingFeesDecodeErrorZ { + /** + * The contents of this CResult_RoutingFeesDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_RoutingFeesDecodeErrorZPtr contents; + /** + * Whether this CResult_RoutingFeesDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_RoutingFeesDecodeErrorZ; +/** + * A 4-byte byte array. + */ +typedef struct LDKFourBytes { + /** + * The four bytes + */ + uint8_t data[4]; +} LDKFourBytes; +/** + * A 16-byte byte array. + */ +typedef struct LDKSixteenBytes { + /** + * The sixteen bytes + */ + uint8_t data[16]; +} LDKSixteenBytes; /** - * The unsigned part of a channel_announcement + * A 12-byte byte array. */ -typedef struct MUST_USE_STRUCT LDKUnsignedChannelAnnouncement { +typedef struct LDKTwelveBytes { + /** + * The twelve bytes + */ + uint8_t data[12]; +} LDKTwelveBytes; + + + +/** + * Represents a hostname for serialization purposes. + * Only the character set and length will be validated. + * The character set consists of ASCII alphanumeric characters, hyphens, and periods. + * Its length is guaranteed to be representable by a single byte. + * This serialization is used by BOLT 7 hostnames. + */ +typedef struct MUST_USE_STRUCT LDKHostname { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeUnsignedChannelAnnouncement *inner; + LDKnativeHostname *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; -} LDKUnsignedChannelAnnouncement; +} LDKHostname; /** - * A trait to sign lightning channel transactions as described in BOLT 3. - * - * Signing services could be implemented on a hardware wallet. In this case, - * the current Sign would be a front-end on top of a communication - * channel connected to your secure device and lightning key material wouldn't - * reside on a hot server. Nevertheless, a this deployment would still need - * to trust the ChannelManager to avoid loss of funds as this latest component - * could ask to sign commitment transaction with HTLCs paying to attacker pubkeys. - * - * A more secure iteration would be to use hashlock (or payment points) to pair - * invoice/incoming HTLCs with outgoing HTLCs to implement a no-trust-ChannelManager - * at the price of more state and computation on the hardware wallet side. In the future, - * we are looking forward to design such interface. - * - * In any case, ChannelMonitor or fallback watchtowers are always going to be trusted - * to act, as liveness and breach reply correctness are always going to be hard requirements - * of LN security model, orthogonal of key management issues. + * An address which can be used to connect to a remote peer */ -typedef struct LDKBaseSign { +typedef enum LDKNetAddress_Tag { /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. + * An IPv4 address/port on which the peer is listening. */ - void *this_arg; + LDKNetAddress_IPv4, /** - * Gets the per-commitment point for a specific commitment number - * - * Note that the commitment number starts at (1 << 48) - 1 and counts backwards. + * An IPv6 address/port on which the peer is listening. */ - struct LDKPublicKey (*get_per_commitment_point)(const void *this_arg, uint64_t idx); + LDKNetAddress_IPv6, /** - * Gets the commitment secret for a specific commitment number as part of the revocation process - * - * An external signer implementation should error here if the commitment was already signed - * and should refuse to sign it in the future. - * - * May be called more than once for the same index. + * An old-style Tor onion address/port on which the peer is listening. * - * Note that the commitment number starts at (1 << 48) - 1 and counts backwards. + * This field is deprecated and the Tor network generally no longer supports V2 Onion + * addresses. Thus, the details are not parsed here. */ - struct LDKThirtyTwoBytes (*release_commitment_secret)(const void *this_arg, uint64_t idx); + LDKNetAddress_OnionV2, /** - * Validate the counterparty's signatures on the holder commitment transaction and HTLCs. - * - * This is required in order for the signer to make sure that releasing a commitment - * secret won't leave us without a broadcastable holder transaction. - * Policy checks should be implemented in this function, including checking the amount - * sent to us and checking the HTLCs. - * - * The preimages of outgoing HTLCs that were fulfilled since the last commitment are provided. - * A validating signer should ensure that an HTLC output is removed only when the matching - * preimage is provided, or when the value to holder is restored. - * - * NOTE: all the relevant preimages will be provided, but there may also be additional - * irrelevant or duplicate preimages. + * 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 LDKCResult_NoneNoneZ (*validate_holder_commitment)(const void *this_arg, const struct LDKHolderCommitmentTransaction *NONNULL_PTR holder_tx, struct LDKCVec_PaymentPreimageZ preimages); + LDKNetAddress_OnionV3, /** - * Gets the holder's channel public keys and basepoints + * A hostname/port on which the peer is listening. */ - struct LDKChannelPublicKeys pubkeys; + LDKNetAddress_Hostname, /** - * Fill in the pubkeys field as a reference to it will be given to Rust after this returns - * Note that this takes a pointer to this object, not the this_ptr like other methods do - * This function pointer may be NULL if pubkeys is filled in when this object is created and never needs updating. + * Must be last for serialization purposes */ - void (*set_pubkeys)(const struct LDKBaseSign*NONNULL_PTR ); + LDKNetAddress_Sentinel, +} LDKNetAddress_Tag; + +typedef struct LDKNetAddress_LDKIPv4_Body { /** - * Gets an arbitrary identifier describing the set of keys which are provided back to you in - * some SpendableOutputDescriptor types. This should be sufficient to identify this - * Sign object uniquely and lookup or re-derive its keys. + * The 4-byte IPv4 address */ - struct LDKThirtyTwoBytes (*channel_keys_id)(const void *this_arg); + struct LDKFourBytes addr; /** - * Create a signature for a counterparty's commitment transaction and associated HTLC transactions. - * - * Note that if signing fails or is rejected, the channel will be force-closed. - * - * Policy checks should be implemented in this function, including checking the amount - * sent to us and checking the HTLCs. - * - * The preimages of outgoing HTLCs that were fulfilled since the last commitment are provided. - * A validating signer should ensure that an HTLC output is removed only when the matching - * preimage is provided, or when the value to holder is restored. - * - * NOTE: all the relevant preimages will be provided, but there may also be additional - * irrelevant or duplicate preimages. + * The port on which the node is listening */ - struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ (*sign_counterparty_commitment)(const void *this_arg, const struct LDKCommitmentTransaction *NONNULL_PTR commitment_tx, struct LDKCVec_PaymentPreimageZ preimages); + uint16_t port; +} LDKNetAddress_LDKIPv4_Body; + +typedef struct LDKNetAddress_LDKIPv6_Body { /** - * Validate the counterparty's revocation. - * - * This is required in order for the signer to make sure that the state has moved - * forward and it is safe to sign the next counterparty commitment. + * The 16-byte IPv6 address */ - struct LDKCResult_NoneNoneZ (*validate_counterparty_revocation)(const void *this_arg, uint64_t idx, const uint8_t (*secret)[32]); + struct LDKSixteenBytes addr; /** - * Create a signatures for a holder's commitment transaction and its claiming HTLC transactions. - * This will only ever be called with a non-revoked commitment_tx. This will be called with the - * latest commitment_tx when we initiate a force-close. - * This will be called with the previous latest, just to get claiming HTLC signatures, if we are - * reacting to a ChannelMonitor replica that decided to broadcast before it had been updated to - * the latest. - * This may be called multiple times for the same transaction. - * - * An external signer implementation should check that the commitment has not been revoked. - * - * May return Err if key derivation fails. Callers, such as ChannelMonitor, will panic in such a case. - */ - struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ (*sign_holder_commitment_and_htlcs)(const void *this_arg, const struct LDKHolderCommitmentTransaction *NONNULL_PTR commitment_tx); - /** - * Create a signature for the given input in a transaction spending an HTLC transaction output - * or a commitment transaction `to_local` output when our counterparty broadcasts an old state. - * - * A justice transaction may claim multiple outputs at the same time if timelocks are - * similar, but only a signature for the input at index `input` should be signed for here. - * It may be called multiple times for same output(s) if a fee-bump is needed with regards - * to an upcoming timelock expiration. - * - * Amount is value of the output spent by this input, committed to in the BIP 143 signature. - * - * per_commitment_key is revocation secret which was provided by our counterparty when they - * revoked the state which they eventually broadcast. It's not a _holder_ secret key and does - * not allow the spending of any funds by itself (you need our holder revocation_secret to do - * so). + * The port on which the node is listening */ - struct LDKCResult_SignatureNoneZ (*sign_justice_revoked_output)(const void *this_arg, struct LDKTransaction justice_tx, uintptr_t input, uint64_t amount, const uint8_t (*per_commitment_key)[32]); + uint16_t port; +} LDKNetAddress_LDKIPv6_Body; + +typedef struct LDKNetAddress_LDKOnionV3_Body { /** - * Create a signature for the given input in a transaction spending a commitment transaction - * HTLC output when our counterparty broadcasts an old state. - * - * A justice transaction may claim multiple outputs at the same time if timelocks are - * similar, but only a signature for the input at index `input` should be signed for here. - * It may be called multiple times for same output(s) if a fee-bump is needed with regards - * to an upcoming timelock expiration. - * - * Amount is value of the output spent by this input, committed to in the BIP 143 signature. - * - * per_commitment_key is revocation secret which was provided by our counterparty when they - * revoked the state which they eventually broadcast. It's not a _holder_ secret key and does - * not allow the spending of any funds by itself (you need our holder revocation_secret to do - * so). - * - * htlc holds HTLC elements (hash, timelock), thus changing the format of the witness script - * (which is committed to in the BIP 143 signatures). + * The ed25519 long-term public key of the peer */ - struct LDKCResult_SignatureNoneZ (*sign_justice_revoked_htlc)(const void *this_arg, struct LDKTransaction justice_tx, uintptr_t input, uint64_t amount, const uint8_t (*per_commitment_key)[32], const struct LDKHTLCOutputInCommitment *NONNULL_PTR htlc); + struct LDKThirtyTwoBytes ed25519_pubkey; /** - * Create a signature for a claiming transaction for a HTLC output on a counterparty's commitment - * transaction, either offered or received. - * - * Such a transaction may claim multiples offered outputs at same time if we know the - * preimage for each when we create it, but only the input at index `input` should be - * signed for here. It may be called multiple times for same output(s) if a fee-bump is - * needed with regards to an upcoming timelock expiration. - * - * Witness_script is either a offered or received script as defined in BOLT3 for HTLC - * outputs. - * - * Amount is value of the output spent by this input, committed to in the BIP 143 signature. - * - * Per_commitment_point is the dynamic point corresponding to the channel state - * detected onchain. It has been generated by our counterparty and is used to derive - * channel state keys, which are then included in the witness script and committed to in the - * BIP 143 signature. + * The checksum of the pubkey and version, as included in the onion address */ - struct LDKCResult_SignatureNoneZ (*sign_counterparty_htlc_transaction)(const void *this_arg, struct LDKTransaction htlc_tx, uintptr_t input, uint64_t amount, struct LDKPublicKey per_commitment_point, const struct LDKHTLCOutputInCommitment *NONNULL_PTR htlc); + uint16_t checksum; /** - * Create a signature for a (proposed) closing transaction. - * - * Note that, due to rounding, there may be one \"missing\" satoshi, and either party may have - * chosen to forgo their output as dust. + * The version byte, as defined by the Tor Onion v3 spec. */ - struct LDKCResult_SignatureNoneZ (*sign_closing_transaction)(const void *this_arg, const struct LDKClosingTransaction *NONNULL_PTR closing_tx); + uint8_t version; /** - * 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. + * The port on which the node is listening */ - struct LDKCResult_C2Tuple_SignatureSignatureZNoneZ (*sign_channel_announcement)(const void *this_arg, const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR msg); + uint16_t port; +} LDKNetAddress_LDKOnionV3_Body; + +typedef struct LDKNetAddress_LDKHostname_Body { /** - * Set the counterparty static channel data, including basepoints, - * counterparty_selected/holder_selected_contest_delay and funding outpoint. - * This is done as soon as the funding outpoint is known. Since these are static channel data, - * they MUST NOT be allowed to change to different values once set. - * - * channel_parameters.is_populated() MUST be true. - * - * We bind holder_selected_contest_delay late here for API convenience. - * - * Will be called before any signatures are applied. + * The hostname on which the node is listening. */ - void (*ready_channel)(void *this_arg, const struct LDKChannelTransactionParameters *NONNULL_PTR channel_parameters); + struct LDKHostname hostname; /** - * 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); -} LDKBaseSign; + uint16_t port; +} LDKNetAddress_LDKHostname_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_LDKHostname_Body hostname; + }; +} LDKNetAddress; /** - * A cloneable signer. - * - * Although we require signers to be cloneable, it may be useful for developers to be able to use - * signers in an un-sized way, for example as `dyn BaseSign`. Therefore we separate the Clone trait, - * which implies Sized, into this derived trait. + * A dynamically-allocated array of crate::lightning::ln::msgs::NetAddresss of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef struct LDKSign { - /** - * 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 LDKCVec_NetAddressZ { /** - * Implementation of BaseSign for this object. + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - struct LDKBaseSign BaseSign; + struct LDKNetAddress *data; /** - * Serialize the object into a byte array + * The number of elements pointed to by `data`. */ - struct LDKCVec_u8Z (*write)(const void *this_arg); + uintptr_t datalen; +} LDKCVec_NetAddressZ; + + + +/** + * Information received in the latest node_announcement from this node. + */ +typedef struct MUST_USE_STRUCT LDKNodeAnnouncementInfo { /** - * Called, if set, after this Sign has been cloned into a duplicate object. - * The new Sign is provided, and should be mutated as needed to perform a - * deep copy of the object pointed to by this_arg or avoid any double-freeing. + * A pointer to the opaque Rust object. + * Nearly everywhere, 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 (*cloned)(struct LDKSign *NONNULL_PTR new_Sign); + LDKnativeNodeAnnouncementInfo *inner; /** - * Frees any resources associated with this object given its this_arg pointer. - * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - void (*free)(void *this_arg); -} LDKSign; + bool is_owned; +} LDKNodeAnnouncementInfo; /** - * The contents of CResult_SignDecodeErrorZ + * The contents of CResult_NodeAnnouncementInfoDecodeErrorZ */ -typedef union LDKCResult_SignDecodeErrorZPtr { +typedef union LDKCResult_NodeAnnouncementInfoDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKSign *result; + struct LDKNodeAnnouncementInfo *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_SignDecodeErrorZPtr; +} LDKCResult_NodeAnnouncementInfoDecodeErrorZPtr; /** - * A CResult_SignDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::chain::keysinterface::Sign on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_NodeAnnouncementInfoDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::routing::gossip::NodeAnnouncementInfo 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_SignDecodeErrorZ { +typedef struct LDKCResult_NodeAnnouncementInfoDecodeErrorZ { /** - * The contents of this CResult_SignDecodeErrorZ, accessible via either + * The contents of this CResult_NodeAnnouncementInfoDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_SignDecodeErrorZPtr contents; + union LDKCResult_NodeAnnouncementInfoDecodeErrorZPtr contents; /** - * Whether this CResult_SignDecodeErrorZ represents a success state. + * Whether this CResult_NodeAnnouncementInfoDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_SignDecodeErrorZ; +} LDKCResult_NodeAnnouncementInfoDecodeErrorZ; + -/** - * 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++ + * A user-defined name for a node, which may be used when displaying the node in a graph. + * + * Since node aliases are provided by third parties, they are a potential avenue for injection + * attacks. Care must be taken when processing. */ -typedef struct LDKCVec_u5Z { +typedef struct MUST_USE_STRUCT LDKNodeAlias { /** - * 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`. + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - 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. - */ -typedef struct LDKRecoverableSignature { + LDKnativeNodeAlias *inner; /** - * The bytes of the signature in "compact" form plus a "Recovery ID" which allows for - * recovery. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - uint8_t serialized_form[68]; -} LDKRecoverableSignature; + bool is_owned; +} LDKNodeAlias; /** - * The contents of CResult_RecoverableSignatureNoneZ + * The contents of CResult_NodeAliasDecodeErrorZ */ -typedef union LDKCResult_RecoverableSignatureNoneZPtr { +typedef union LDKCResult_NodeAliasDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKRecoverableSignature *result; + struct LDKNodeAlias *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_RecoverableSignatureNoneZPtr; + struct LDKDecodeError *err; +} LDKCResult_NodeAliasDecodeErrorZPtr; /** - * A CResult_RecoverableSignatureNoneZ represents the result of a fallible operation, - * containing a crate::c_types::RecoverableSignature on success and a () on failure. + * A CResult_NodeAliasDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::routing::gossip::NodeAlias 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_RecoverableSignatureNoneZ { +typedef struct LDKCResult_NodeAliasDecodeErrorZ { /** - * The contents of this CResult_RecoverableSignatureNoneZ, accessible via either + * The contents of this CResult_NodeAliasDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_RecoverableSignatureNoneZPtr contents; + union LDKCResult_NodeAliasDecodeErrorZPtr contents; /** - * Whether this CResult_RecoverableSignatureNoneZ represents a success state. + * Whether this CResult_NodeAliasDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_RecoverableSignatureNoneZ; +} LDKCResult_NodeAliasDecodeErrorZ; + + /** - * A dynamically-allocated array of crate::c_types::derived::CVec_u8Zs of arbitrary size. - * This corresponds to std::vector in C++ + * Details about a node in the network, known from the network announcement. */ -typedef struct LDKCVec_CVec_u8ZZ { +typedef struct MUST_USE_STRUCT LDKNodeInfo { /** - * 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 LDKCVec_u8Z *data; + LDKnativeNodeInfo *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_CVec_u8ZZ; + bool is_owned; +} LDKNodeInfo; /** - * The contents of CResult_CVec_CVec_u8ZZNoneZ + * The contents of CResult_NodeInfoDecodeErrorZ */ -typedef union LDKCResult_CVec_CVec_u8ZZNoneZPtr { +typedef union LDKCResult_NodeInfoDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKCVec_CVec_u8ZZ *result; + struct LDKNodeInfo *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_CVec_CVec_u8ZZNoneZPtr; + struct LDKDecodeError *err; +} LDKCResult_NodeInfoDecodeErrorZPtr; /** - * A CResult_CVec_CVec_u8ZZNoneZ represents the result of a fallible operation, - * containing a crate::c_types::derived::CVec_CVec_u8ZZ on success and a () on failure. + * A CResult_NodeInfoDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::routing::gossip::NodeInfo 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_CVec_CVec_u8ZZNoneZ { +typedef struct LDKCResult_NodeInfoDecodeErrorZ { /** - * The contents of this CResult_CVec_CVec_u8ZZNoneZ, accessible via either + * The contents of this CResult_NodeInfoDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_CVec_CVec_u8ZZNoneZPtr contents; + union LDKCResult_NodeInfoDecodeErrorZPtr contents; /** - * Whether this CResult_CVec_CVec_u8ZZNoneZ represents a success state. + * Whether this CResult_NodeInfoDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_CVec_CVec_u8ZZNoneZ; - - - -/** - * A simple implementation of Sign that just keeps the private keys in memory. - * - * This implementation performs no policy checks and is insufficient by itself as - * a secure external signer. - */ -typedef struct MUST_USE_STRUCT LDKInMemorySigner { - /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. - */ - LDKnativeInMemorySigner *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; -} LDKInMemorySigner; +} LDKCResult_NodeInfoDecodeErrorZ; /** - * The contents of CResult_InMemorySignerDecodeErrorZ + * The contents of CResult_NetworkGraphDecodeErrorZ */ -typedef union LDKCResult_InMemorySignerDecodeErrorZPtr { +typedef union LDKCResult_NetworkGraphDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKInMemorySigner *result; + struct LDKNetworkGraph *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_InMemorySignerDecodeErrorZPtr; +} LDKCResult_NetworkGraphDecodeErrorZPtr; /** - * A CResult_InMemorySignerDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::chain::keysinterface::InMemorySigner on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_NetworkGraphDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::routing::gossip::NetworkGraph 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_InMemorySignerDecodeErrorZ { +typedef struct LDKCResult_NetworkGraphDecodeErrorZ { /** - * The contents of this CResult_InMemorySignerDecodeErrorZ, accessible via either + * The contents of this CResult_NetworkGraphDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_InMemorySignerDecodeErrorZPtr contents; + union LDKCResult_NetworkGraphDecodeErrorZPtr contents; /** - * Whether this CResult_InMemorySignerDecodeErrorZ represents a success state. + * Whether this CResult_NetworkGraphDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_InMemorySignerDecodeErrorZ; +} LDKCResult_NetworkGraphDecodeErrorZ; /** - * A dynamically-allocated array of crate::c_types::TxOuts of arbitrary size. - * This corresponds to std::vector in C++ + * An enum which can either contain a crate::c_types::derived::CVec_NetAddressZ or not */ -typedef struct LDKCVec_TxOutZ { +typedef enum LDKCOption_CVec_NetAddressZZ_Tag { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * When we're in this state, this COption_CVec_NetAddressZZ contains a crate::c_types::derived::CVec_NetAddressZ */ - struct LDKTxOut *data; + LDKCOption_CVec_NetAddressZZ_Some, /** - * The number of elements pointed to by `data`. + * When we're in this state, this COption_CVec_NetAddressZZ contains nothing */ - uintptr_t datalen; -} LDKCVec_TxOutZ; + LDKCOption_CVec_NetAddressZZ_None, + /** + * Must be last for serialization purposes + */ + LDKCOption_CVec_NetAddressZZ_Sentinel, +} LDKCOption_CVec_NetAddressZZ_Tag; + +typedef struct LDKCOption_CVec_NetAddressZZ { + LDKCOption_CVec_NetAddressZZ_Tag tag; + union { + struct { + struct LDKCVec_NetAddressZ some; + }; + }; +} LDKCOption_CVec_NetAddressZZ; /** - * The contents of CResult_TransactionNoneZ + * The contents of CResult_DelayedPaymentOutputDescriptorDecodeErrorZ */ -typedef union LDKCResult_TransactionNoneZPtr { +typedef union LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKTransaction *result; + struct LDKDelayedPaymentOutputDescriptor *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_TransactionNoneZPtr; + struct LDKDecodeError *err; +} LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZPtr; /** - * A CResult_TransactionNoneZ represents the result of a fallible operation, - * containing a crate::c_types::Transaction on success and a () on failure. + * A CResult_DelayedPaymentOutputDescriptorDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::chain::keysinterface::DelayedPaymentOutputDescriptor on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_TransactionNoneZ { +typedef struct LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ { /** - * The contents of this CResult_TransactionNoneZ, accessible via either + * The contents of this CResult_DelayedPaymentOutputDescriptorDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_TransactionNoneZPtr contents; + union LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZPtr contents; /** - * Whether this CResult_TransactionNoneZ represents a success state. + * Whether this CResult_DelayedPaymentOutputDescriptorDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_TransactionNoneZ; - - - -/** - * A ChannelMonitor handles chain events (blocks connected and disconnected) and generates - * on-chain transactions to ensure no loss of funds occurs. - * - * You MUST ensure that no ChannelMonitors for a given channel anywhere contain out-of-date - * information and are actively monitoring the chain. - * - * Pending Events or updated HTLCs which have not yet been read out by - * get_and_clear_pending_monitor_events or get_and_clear_pending_events are serialized to disk and - * reloaded at deserialize-time. Thus, you must ensure that, when handling events, all events - * gotten are fully handled before re-serializing the new state. - * - * Note that the deserializer is only implemented for (BlockHash, ChannelMonitor), which - * tells you the last block hash which was block_connect()ed. You MUST rescan any blocks along - * the \"reorg path\" (ie disconnecting blocks until you find a common ancestor from both the - * returned block hash and the the current chain and then reconnecting blocks to get to the - * best chain) upon deserializing the object! - */ -typedef struct MUST_USE_STRUCT LDKChannelMonitor { - /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. - */ - LDKnativeChannelMonitor *inner; - /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. - */ - bool is_owned; -} LDKChannelMonitor; +} LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ; /** - * A tuple of 2 elements. See the individual fields for the types contained. + * The contents of CResult_StaticPaymentOutputDescriptorDecodeErrorZ */ -typedef struct LDKC2Tuple_BlockHashChannelMonitorZ { +typedef union LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZPtr { /** - * The element at position 0 + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKThirtyTwoBytes a; + struct LDKStaticPaymentOutputDescriptor *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 LDKChannelMonitor b; -} LDKC2Tuple_BlockHashChannelMonitorZ; + struct LDKDecodeError *err; +} LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZPtr; /** - * A dynamically-allocated array of crate::c_types::derived::C2Tuple_BlockHashChannelMonitorZs of arbitrary size. - * This corresponds to std::vector in C++ + * A CResult_StaticPaymentOutputDescriptorDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::chain::keysinterface::StaticPaymentOutputDescriptor on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCVec_C2Tuple_BlockHashChannelMonitorZZ { +typedef struct LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ { /** - * 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_StaticPaymentOutputDescriptorDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKC2Tuple_BlockHashChannelMonitorZ *data; + union LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZPtr contents; /** - * The number of elements pointed to by `data`. + * Whether this CResult_StaticPaymentOutputDescriptorDecodeErrorZ represents a success state. */ - uintptr_t datalen; -} LDKCVec_C2Tuple_BlockHashChannelMonitorZZ; + bool result_ok; +} LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ; /** - * The contents of CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ + * The contents of CResult_SpendableOutputDescriptorDecodeErrorZ */ -typedef union LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZPtr { +typedef union LDKCResult_SpendableOutputDescriptorDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKCVec_C2Tuple_BlockHashChannelMonitorZZ *result; + struct LDKSpendableOutputDescriptor *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - enum LDKIOError *err; -} LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZPtr; + struct LDKDecodeError *err; +} LDKCResult_SpendableOutputDescriptorDecodeErrorZPtr; /** - * A CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ represents the result of a fallible operation, - * containing a crate::c_types::derived::CVec_C2Tuple_BlockHashChannelMonitorZZ on success and a crate::c_types::IOError on failure. + * A CResult_SpendableOutputDescriptorDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::chain::keysinterface::SpendableOutputDescriptor on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ { +typedef struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ { /** - * The contents of this CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ, accessible via either + * The contents of this CResult_SpendableOutputDescriptorDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZPtr contents; + union LDKCResult_SpendableOutputDescriptorDecodeErrorZPtr contents; /** - * Whether this CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ represents a success state. + * Whether this CResult_SpendableOutputDescriptorDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ; +} LDKCResult_SpendableOutputDescriptorDecodeErrorZ; /** - * An enum which can either contain a u16 or not + * A dynamically-allocated array of crate::c_types::ThirtyTwoBytess of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef enum LDKCOption_u16Z_Tag { - /** - * When we're in this state, this COption_u16Z contains a u16 - */ - LDKCOption_u16Z_Some, +typedef struct LDKCVec_PaymentPreimageZ { /** - * When we're in this state, this COption_u16Z contains nothing + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - LDKCOption_u16Z_None, + struct LDKThirtyTwoBytes *data; /** - * Must be last for serialization purposes + * The number of elements pointed to by `data`. */ - LDKCOption_u16Z_Sentinel, -} LDKCOption_u16Z_Tag; - -typedef struct LDKCOption_u16Z { - LDKCOption_u16Z_Tag tag; - union { - struct { - uint16_t some; - }; - }; -} LDKCOption_u16Z; + uintptr_t datalen; +} LDKCVec_PaymentPreimageZ; /** - * Indicates an error on the client's part (usually some variant of attempting to use too-low or - * too-high values) + * A tuple of 2 elements. See the individual fields for the types contained. */ -typedef enum LDKAPIError_Tag { +typedef struct LDKC2Tuple_SignatureCVec_SignatureZZ { /** - * Indicates the API was wholly misused (see err for more). Cases where these can be returned - * are documented, but generally indicates some precondition of a function was violated. + * The element at position 0 */ - LDKAPIError_APIMisuseError, - /** - * Due to a high feerate, we were unable to complete the request. - * For example, this may be returned if the feerate implies we cannot open a channel at the - * requested value, but opening a larger channel would succeed. - */ - LDKAPIError_FeeRateTooHigh, + struct LDKSignature a; /** - * A malformed Route was provided (eg overflowed value, node id mismatch, overly-looped route, - * too-many-hops, etc). + * The element at position 1 */ - LDKAPIError_RouteError, + struct LDKCVec_SignatureZ b; +} LDKC2Tuple_SignatureCVec_SignatureZZ; + +/** + * The contents of CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ + */ +typedef union LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr { /** - * We were unable to complete the request as the Channel required to do so is unable to - * complete the request (or was not found). This can take many forms, including disconnected - * peer, channel at capacity, channel shutting down, etc. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - LDKAPIError_ChannelUnavailable, + struct LDKC2Tuple_SignatureCVec_SignatureZZ *result; /** - * An attempt to call watch/update_channel returned an Err (ie you did this!), causing the - * attempted action to fail. + * Note that this value is always NULL, as there are no contents in the Err variant */ - LDKAPIError_MonitorUpdateFailed, + void *err; +} LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr; + +/** + * A CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ represents the result of a fallible operation, + * containing a crate::c_types::derived::C2Tuple_SignatureCVec_SignatureZZ on success and a () on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { /** - * [`KeysInterface::get_shutdown_scriptpubkey`] returned a shutdown scriptpubkey incompatible - * with the channel counterparty as negotiated in [`InitFeatures`]. - * - * Using a SegWit v0 script should resolve this issue. If you cannot, you won't be able to open - * a channel or cooperatively close one with this peer (and will have to force-close instead). - * - * [`KeysInterface::get_shutdown_scriptpubkey`]: crate::chain::keysinterface::KeysInterface::get_shutdown_scriptpubkey - * [`InitFeatures`]: crate::ln::features::InitFeatures + * The contents of this CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - LDKAPIError_IncompatibleShutdownScript, + union LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr contents; /** - * Must be last for serialization purposes + * Whether this CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ represents a success state. */ - LDKAPIError_Sentinel, -} LDKAPIError_Tag; + bool result_ok; +} LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ; -typedef struct LDKAPIError_LDKAPIMisuseError_Body { +/** + * The contents of CResult_SignatureNoneZ + */ +typedef union LDKCResult_SignatureNoneZPtr { /** - * A human-readable error message + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKStr err; -} LDKAPIError_LDKAPIMisuseError_Body; - -typedef struct LDKAPIError_LDKFeeRateTooHigh_Body { + struct LDKSignature *result; /** - * A human-readable error message + * Note that this value is always NULL, as there are no contents in the Err variant */ - struct LDKStr err; + void *err; +} LDKCResult_SignatureNoneZPtr; + +/** + * 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 feerate which was too high. + * The contents of this CResult_SignatureNoneZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - uint32_t feerate; -} LDKAPIError_LDKFeeRateTooHigh_Body; - -typedef struct LDKAPIError_LDKRouteError_Body { + union LDKCResult_SignatureNoneZPtr contents; /** - * A human-readable error message + * Whether this CResult_SignatureNoneZ represents a success state. */ - struct LDKStr err; -} LDKAPIError_LDKRouteError_Body; + bool result_ok; +} LDKCResult_SignatureNoneZ; -typedef struct LDKAPIError_LDKChannelUnavailable_Body { +/** + * A tuple of 2 elements. See the individual fields for the types contained. + */ +typedef struct LDKC2Tuple_SignatureSignatureZ { /** - * A human-readable error message + * The element at position 0 */ - struct LDKStr err; -} LDKAPIError_LDKChannelUnavailable_Body; - -typedef struct LDKAPIError_LDKIncompatibleShutdownScript_Body { + struct LDKSignature a; /** - * The incompatible shutdown script. + * The element at position 1 */ - 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; + struct LDKSignature b; +} LDKC2Tuple_SignatureSignatureZ; /** - * The contents of CResult_NoneAPIErrorZ + * The contents of CResult_C2Tuple_SignatureSignatureZNoneZ */ -typedef union LDKCResult_NoneAPIErrorZPtr { +typedef union LDKCResult_C2Tuple_SignatureSignatureZNoneZPtr { /** - * 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 LDKC2Tuple_SignatureSignatureZ *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 LDKAPIError *err; -} LDKCResult_NoneAPIErrorZPtr; + void *err; +} LDKCResult_C2Tuple_SignatureSignatureZNoneZPtr; /** - * A CResult_NoneAPIErrorZ represents the result of a fallible operation, - * containing a () on success and a crate::lightning::util::errors::APIError on failure. + * A CResult_C2Tuple_SignatureSignatureZNoneZ represents the result of a fallible operation, + * containing a crate::c_types::derived::C2Tuple_SignatureSignatureZ on success and a () on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_NoneAPIErrorZ { +typedef struct LDKCResult_C2Tuple_SignatureSignatureZNoneZ { /** - * The contents of this CResult_NoneAPIErrorZ, accessible via either + * The contents of this CResult_C2Tuple_SignatureSignatureZNoneZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_NoneAPIErrorZPtr contents; + union LDKCResult_C2Tuple_SignatureSignatureZNoneZPtr contents; /** - * Whether this CResult_NoneAPIErrorZ represents a success state. + * Whether this CResult_C2Tuple_SignatureSignatureZNoneZ represents a success state. */ bool result_ok; -} LDKCResult_NoneAPIErrorZ; +} LDKCResult_C2Tuple_SignatureSignatureZNoneZ; /** - * A dynamically-allocated array of crate::c_types::derived::CResult_NoneAPIErrorZs of arbitrary size. - * This corresponds to std::vector in C++ + * The contents of CResult_SecretKeyNoneZ */ -typedef struct LDKCVec_CResult_NoneAPIErrorZZ { +typedef union LDKCResult_SecretKeyNoneZPtr { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKCResult_NoneAPIErrorZ *data; + struct LDKSecretKey *result; /** - * The number of elements pointed to by `data`. + * Note that this value is always NULL, as there are no contents in the Err variant */ - uintptr_t datalen; -} LDKCVec_CResult_NoneAPIErrorZZ; + void *err; +} LDKCResult_SecretKeyNoneZPtr; /** - * A dynamically-allocated array of crate::lightning::util::errors::APIErrors of arbitrary size. - * This corresponds to std::vector in C++ + * A CResult_SecretKeyNoneZ represents the result of a fallible operation, + * containing a crate::c_types::SecretKey on success and a () on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCVec_APIErrorZ { +typedef struct LDKCResult_SecretKeyNoneZ { /** - * 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_SecretKeyNoneZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKAPIError *data; + union LDKCResult_SecretKeyNoneZPtr contents; /** - * The number of elements pointed to by `data`. + * Whether this CResult_SecretKeyNoneZ represents a success state. */ - uintptr_t datalen; -} LDKCVec_APIErrorZ; + bool result_ok; +} LDKCResult_SecretKeyNoneZ; /** - * The contents of CResult__u832APIErrorZ + * The contents of CResult_PublicKeyNoneZ */ -typedef union LDKCResult__u832APIErrorZPtr { +typedef union LDKCResult_PublicKeyNoneZPtr { /** * 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 LDKPublicKey *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 LDKAPIError *err; -} LDKCResult__u832APIErrorZPtr; + void *err; +} LDKCResult_PublicKeyNoneZPtr; /** - * A CResult__u832APIErrorZ represents the result of a fallible operation, - * containing a crate::c_types::ThirtyTwoBytes on success and a crate::lightning::util::errors::APIError on failure. + * A CResult_PublicKeyNoneZ represents the result of a fallible operation, + * containing a crate::c_types::PublicKey on success and a () on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult__u832APIErrorZ { +typedef struct LDKCResult_PublicKeyNoneZ { /** - * The contents of this CResult__u832APIErrorZ, accessible via either + * The contents of this CResult_PublicKeyNoneZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult__u832APIErrorZPtr contents; + union LDKCResult_PublicKeyNoneZPtr contents; /** - * Whether this CResult__u832APIErrorZ represents a success state. + * Whether this CResult_PublicKeyNoneZ represents a success state. */ bool result_ok; -} LDKCResult__u832APIErrorZ; +} LDKCResult_PublicKeyNoneZ; /** - * 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. + * An enum which can either contain a crate::c_types::BigEndianScalar or not */ -typedef enum LDKPaymentSendFailure_Tag { +typedef enum LDKCOption_ScalarZ_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. + * When we're in this state, this COption_ScalarZ contains a crate::c_types::BigEndianScalar */ - LDKPaymentSendFailure_ParameterError, + LDKCOption_ScalarZ_Some, /** - * 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. + * When we're in this state, this COption_ScalarZ contains nothing */ - LDKPaymentSendFailure_PathParameterError, + LDKCOption_ScalarZ_None, /** - * 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). + * Must be last for serialization purposes */ - LDKPaymentSendFailure_AllFailedRetrySafe, + LDKCOption_ScalarZ_Sentinel, +} LDKCOption_ScalarZ_Tag; + +typedef struct LDKCOption_ScalarZ { + LDKCOption_ScalarZ_Tag tag; + union { + struct { + struct LDKBigEndianScalar some; + }; + }; +} LDKCOption_ScalarZ; + +/** + * The contents of CResult_SharedSecretNoneZ + */ +typedef union LDKCResult_SharedSecretNoneZPtr { /** - * 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. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - LDKPaymentSendFailure_PartialFailure, + struct LDKThirtyTwoBytes *result; /** - * Must be last for serialization purposes + * Note that this value is always NULL, as there are no contents in the Err variant */ - LDKPaymentSendFailure_Sentinel, -} LDKPaymentSendFailure_Tag; + void *err; +} LDKCResult_SharedSecretNoneZPtr; -typedef struct LDKPaymentSendFailure_LDKPartialFailure_Body { +/** + * A CResult_SharedSecretNoneZ represents the result of a fallible operation, + * containing a crate::c_types::ThirtyTwoBytes on success and a () on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_SharedSecretNoneZ { /** - * The errors themselves, in the same order as the route hops. + * The contents of this CResult_SharedSecretNoneZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - 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; + union LDKCResult_SharedSecretNoneZPtr contents; /** - * The payment id for the payment, which is now at least partially pending. + * Whether this CResult_SharedSecretNoneZ represents a success state. */ - struct LDKThirtyTwoBytes payment_id; -} LDKPaymentSendFailure_LDKPartialFailure_Body; + bool result_ok; +} LDKCResult_SharedSecretNoneZ; -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`. + * This class tracks the per-transaction information needed to build a closing transaction and will + * actually build it and sign. + * + * This class can be used inside a signer implementation to generate a signature given the relevant + * secret key. */ -typedef struct LDKCResult_PaymentIdPaymentSendFailureZ { +typedef struct MUST_USE_STRUCT LDKClosingTransaction { /** - * The contents of this CResult_PaymentIdPaymentSendFailureZ, 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_PaymentIdPaymentSendFailureZPtr contents; + LDKnativeClosingTransaction *inner; /** - * Whether this CResult_PaymentIdPaymentSendFailureZ 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_PaymentIdPaymentSendFailureZ; + bool is_owned; +} LDKClosingTransaction; -/** - * The contents of CResult_NonePaymentSendFailureZ - */ -typedef union LDKCResult_NonePaymentSendFailureZPtr { - /** - * 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 LDKPaymentSendFailure *err; -} LDKCResult_NonePaymentSendFailureZPtr; -/** - * 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 LDKCResult_NonePaymentSendFailureZ { - /** - * The contents of this CResult_NonePaymentSendFailureZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. - */ - union LDKCResult_NonePaymentSendFailureZPtr contents; - /** - * Whether this CResult_NonePaymentSendFailureZ represents a success state. - */ - bool result_ok; -} LDKCResult_NonePaymentSendFailureZ; /** - * A tuple of 2 elements. See the individual fields for the types contained. + * The unsigned part of a channel_announcement */ -typedef struct LDKC2Tuple_PaymentHashPaymentIdZ { +typedef struct MUST_USE_STRUCT LDKUnsignedChannelAnnouncement { /** - * 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; + LDKnativeUnsignedChannelAnnouncement *inner; /** - * The element at position 1 + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - struct LDKThirtyTwoBytes b; -} LDKC2Tuple_PaymentHashPaymentIdZ; + bool is_owned; +} LDKUnsignedChannelAnnouncement; /** - * The contents of CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ + * A trait to sign lightning channel transactions as described in BOLT 3. + * + * Signing services could be implemented on a hardware wallet. In this case, + * the current Sign would be a front-end on top of a communication + * channel connected to your secure device and lightning key material wouldn't + * reside on a hot server. Nevertheless, a this deployment would still need + * to trust the ChannelManager to avoid loss of funds as this latest component + * could ask to sign commitment transaction with HTLCs paying to attacker pubkeys. + * + * A more secure iteration would be to use hashlock (or payment points) to pair + * invoice/incoming HTLCs with outgoing HTLCs to implement a no-trust-ChannelManager + * at the price of more state and computation on the hardware wallet side. In the future, + * we are looking forward to design such interface. + * + * In any case, ChannelMonitor or fallback watchtowers are always going to be trusted + * to act, as liveness and breach reply correctness are always going to be hard requirements + * of LN security model, orthogonal of key management issues. */ -typedef union LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZPtr { - /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. - */ - struct LDKC2Tuple_PaymentHashPaymentIdZ *result; +typedef struct LDKBaseSign { /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is 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 LDKPaymentSendFailure *err; -} LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZPtr; - -/** - * 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 LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ { + void *this_arg; /** - * The contents of this CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * Gets the per-commitment point for a specific commitment number + * + * Note that the commitment number starts at (1 << 48) - 1 and counts backwards. */ - union LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZPtr contents; + struct LDKPublicKey (*get_per_commitment_point)(const void *this_arg, uint64_t idx); /** - * Whether this CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ represents a success state. + * Gets the commitment secret for a specific commitment number as part of the revocation process + * + * An external signer implementation should error here if the commitment was already signed + * and should refuse to sign it in the future. + * + * May be called more than once for the same index. + * + * Note that the commitment number starts at (1 << 48) - 1 and counts backwards. */ - bool result_ok; -} LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ; - -/** - * A 4-byte byte array. - */ -typedef struct LDKFourBytes { + struct LDKThirtyTwoBytes (*release_commitment_secret)(const void *this_arg, uint64_t idx); /** - * The four bytes + * Validate the counterparty's signatures on the holder commitment transaction and HTLCs. + * + * This is required in order for the signer to make sure that releasing a commitment + * secret won't leave us without a broadcastable holder transaction. + * Policy checks should be implemented in this function, including checking the amount + * sent to us and checking the HTLCs. + * + * The preimages of outgoing HTLCs that were fulfilled since the last commitment are provided. + * A validating signer should ensure that an HTLC output is removed only when the matching + * preimage is provided, or when the value to holder is restored. + * + * NOTE: all the relevant preimages will be provided, but there may also be additional + * irrelevant or duplicate preimages. */ - uint8_t data[4]; -} LDKFourBytes; - -/** - * A 16-byte byte array. - */ -typedef struct LDKSixteenBytes { + struct LDKCResult_NoneNoneZ (*validate_holder_commitment)(const void *this_arg, const struct LDKHolderCommitmentTransaction *NONNULL_PTR holder_tx, struct LDKCVec_PaymentPreimageZ preimages); /** - * The sixteen bytes + * Gets the holder's channel public keys and basepoints */ - uint8_t data[16]; -} LDKSixteenBytes; - -/** - * A 12-byte byte array. - */ -typedef struct LDKTwelveBytes { + struct LDKChannelPublicKeys pubkeys; /** - * The twelve bytes + * Fill in the pubkeys field as a reference to it will be given to Rust after this returns + * Note that this takes a pointer to this object, not the this_ptr like other methods do + * This function pointer may be NULL if pubkeys is filled in when this object is created and never needs updating. */ - uint8_t data[12]; -} LDKTwelveBytes; - -/** - * An address which can be used to connect to a remote peer - */ -typedef enum LDKNetAddress_Tag { + void (*set_pubkeys)(const struct LDKBaseSign*NONNULL_PTR ); /** - * An IPv4 address/port on which the peer is listening. + * Gets an arbitrary identifier describing the set of keys which are provided back to you in + * some SpendableOutputDescriptor types. This should be sufficient to identify this + * Sign object uniquely and lookup or re-derive its keys. */ - LDKNetAddress_IPv4, + struct LDKThirtyTwoBytes (*channel_keys_id)(const void *this_arg); /** - * An IPv6 address/port on which the peer is listening. + * Create a signature for a counterparty's commitment transaction and associated HTLC transactions. + * + * Note that if signing fails or is rejected, the channel will be force-closed. + * + * Policy checks should be implemented in this function, including checking the amount + * sent to us and checking the HTLCs. + * + * The preimages of outgoing HTLCs that were fulfilled since the last commitment are provided. + * A validating signer should ensure that an HTLC output is removed only when the matching + * preimage is provided, or when the value to holder is restored. + * + * NOTE: all the relevant preimages will be provided, but there may also be additional + * irrelevant or duplicate preimages. */ - LDKNetAddress_IPv6, + struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ (*sign_counterparty_commitment)(const void *this_arg, const struct LDKCommitmentTransaction *NONNULL_PTR commitment_tx, struct LDKCVec_PaymentPreimageZ preimages); /** - * An old-style Tor onion address/port on which the peer is listening. + * Validate the counterparty's revocation. * - * This field is deprecated and the Tor network generally no longer supports V2 Onion - * addresses. Thus, the details are not parsed here. + * This is required in order for the signer to make sure that the state has moved + * forward and it is safe to sign the next counterparty commitment. */ - LDKNetAddress_OnionV2, + struct LDKCResult_NoneNoneZ (*validate_counterparty_revocation)(const void *this_arg, uint64_t idx, const uint8_t (*secret)[32]); /** - * 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\". - */ - LDKNetAddress_OnionV3, - /** - * Must be last for serialization purposes + * Create a signatures for a holder's commitment transaction and its claiming HTLC transactions. + * This will only ever be called with a non-revoked commitment_tx. This will be called with the + * latest commitment_tx when we initiate a force-close. + * This will be called with the previous latest, just to get claiming HTLC signatures, if we are + * reacting to a ChannelMonitor replica that decided to broadcast before it had been updated to + * the latest. + * This may be called multiple times for the same transaction. + * + * An external signer implementation should check that the commitment has not been revoked. + * + * May return Err if key derivation fails. Callers, such as ChannelMonitor, will panic in such a case. */ - LDKNetAddress_Sentinel, -} LDKNetAddress_Tag; - -typedef struct LDKNetAddress_LDKIPv4_Body { + struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ (*sign_holder_commitment_and_htlcs)(const void *this_arg, const struct LDKHolderCommitmentTransaction *NONNULL_PTR commitment_tx); /** - * The 4-byte IPv4 address + * Create a signature for the given input in a transaction spending an HTLC transaction output + * or a commitment transaction `to_local` output when our counterparty broadcasts an old state. + * + * A justice transaction may claim multiple outputs at the same time if timelocks are + * similar, but only a signature for the input at index `input` should be signed for here. + * It may be called multiple times for same output(s) if a fee-bump is needed with regards + * to an upcoming timelock expiration. + * + * Amount is value of the output spent by this input, committed to in the BIP 143 signature. + * + * per_commitment_key is revocation secret which was provided by our counterparty when they + * revoked the state which they eventually broadcast. It's not a _holder_ secret key and does + * not allow the spending of any funds by itself (you need our holder revocation_secret to do + * so). */ - struct LDKFourBytes addr; + struct LDKCResult_SignatureNoneZ (*sign_justice_revoked_output)(const void *this_arg, struct LDKTransaction justice_tx, uintptr_t input, uint64_t amount, const uint8_t (*per_commitment_key)[32]); /** - * The port on which the node is listening + * Create a signature for the given input in a transaction spending a commitment transaction + * HTLC output when our counterparty broadcasts an old state. + * + * A justice transaction may claim multiple outputs at the same time if timelocks are + * similar, but only a signature for the input at index `input` should be signed for here. + * It may be called multiple times for same output(s) if a fee-bump is needed with regards + * to an upcoming timelock expiration. + * + * Amount is value of the output spent by this input, committed to in the BIP 143 signature. + * + * per_commitment_key is revocation secret which was provided by our counterparty when they + * revoked the state which they eventually broadcast. It's not a _holder_ secret key and does + * not allow the spending of any funds by itself (you need our holder revocation_secret to do + * so). + * + * htlc holds HTLC elements (hash, timelock), thus changing the format of the witness script + * (which is committed to in the BIP 143 signatures). */ - uint16_t port; -} LDKNetAddress_LDKIPv4_Body; - -typedef struct LDKNetAddress_LDKIPv6_Body { + struct LDKCResult_SignatureNoneZ (*sign_justice_revoked_htlc)(const void *this_arg, struct LDKTransaction justice_tx, uintptr_t input, uint64_t amount, const uint8_t (*per_commitment_key)[32], const struct LDKHTLCOutputInCommitment *NONNULL_PTR htlc); /** - * The 16-byte IPv6 address + * Create a signature for a claiming transaction for a HTLC output on a counterparty's commitment + * transaction, either offered or received. + * + * Such a transaction may claim multiples offered outputs at same time if we know the + * preimage for each when we create it, but only the input at index `input` should be + * signed for here. It may be called multiple times for same output(s) if a fee-bump is + * needed with regards to an upcoming timelock expiration. + * + * Witness_script is either a offered or received script as defined in BOLT3 for HTLC + * outputs. + * + * Amount is value of the output spent by this input, committed to in the BIP 143 signature. + * + * Per_commitment_point is the dynamic point corresponding to the channel state + * detected onchain. It has been generated by our counterparty and is used to derive + * channel state keys, which are then included in the witness script and committed to in the + * BIP 143 signature. */ - struct LDKSixteenBytes addr; + struct LDKCResult_SignatureNoneZ (*sign_counterparty_htlc_transaction)(const void *this_arg, struct LDKTransaction htlc_tx, uintptr_t input, uint64_t amount, struct LDKPublicKey per_commitment_point, const struct LDKHTLCOutputInCommitment *NONNULL_PTR htlc); /** - * The port on which the node is listening + * Create a signature for a (proposed) closing transaction. + * + * Note that, due to rounding, there may be one \"missing\" satoshi, and either party may have + * chosen to forgo their output as dust. */ - uint16_t port; -} LDKNetAddress_LDKIPv6_Body; - -typedef struct LDKNetAddress_LDKOnionV3_Body { + struct LDKCResult_SignatureNoneZ (*sign_closing_transaction)(const void *this_arg, const struct LDKClosingTransaction *NONNULL_PTR closing_tx); /** - * The ed25519 long-term public key of the peer + * Computes the signature for a commitment transaction's anchor output used as an + * input within `anchor_tx`, which spends the commitment transaction, at index `input`. */ - struct LDKThirtyTwoBytes ed25519_pubkey; + struct LDKCResult_SignatureNoneZ (*sign_holder_anchor_input)(const void *this_arg, struct LDKTransaction anchor_tx, uintptr_t input); /** - * The checksum of the pubkey and version, as included in the onion address + * 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. */ - uint16_t checksum; + struct LDKCResult_C2Tuple_SignatureSignatureZNoneZ (*sign_channel_announcement)(const void *this_arg, const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR msg); /** - * The version byte, as defined by the Tor Onion v3 spec. + * Set the counterparty static channel data, including basepoints, + * counterparty_selected/holder_selected_contest_delay and funding outpoint. + * This is done as soon as the funding outpoint is known. Since these are static channel data, + * they MUST NOT be allowed to change to different values once set. + * + * channel_parameters.is_populated() MUST be true. + * + * We bind holder_selected_contest_delay late here for API convenience. + * + * Will be called before any signatures are applied. */ - uint8_t version; + void (*ready_channel)(void *this_arg, const struct LDKChannelTransactionParameters *NONNULL_PTR channel_parameters); /** - * The port on which the node is listening + * 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. */ - 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; + void (*free)(void *this_arg); +} LDKBaseSign; /** - * A dynamically-allocated array of crate::lightning::ln::msgs::NetAddresss of arbitrary size. - * This corresponds to std::vector in C++ + * A cloneable signer. + * + * Although we require signers to be cloneable, it may be useful for developers to be able to use + * signers in an un-sized way, for example as `dyn BaseSign`. Therefore we separate the Clone trait, + * which implies Sized, into this derived trait. */ -typedef struct LDKCVec_NetAddressZ { +typedef struct LDKSign { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * 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 LDKNetAddress *data; + void *this_arg; /** - * The number of elements pointed to by `data`. + * Implementation of BaseSign for this object. */ - uintptr_t datalen; -} LDKCVec_NetAddressZ; - -/** - * A tuple of 2 elements. See the individual fields for the types contained. - */ -typedef struct LDKC2Tuple_PaymentHashPaymentSecretZ { + struct LDKBaseSign BaseSign; /** - * The element at position 0 + * Serialize the object into a byte array */ - struct LDKThirtyTwoBytes a; + struct LDKCVec_u8Z (*write)(const void *this_arg); /** - * The element at position 1 + * Called, if set, after this Sign has been cloned into a duplicate object. + * The new Sign is provided, and should be mutated as needed to perform a + * deep copy of the object pointed to by this_arg or avoid any double-freeing. */ - struct LDKThirtyTwoBytes b; -} LDKC2Tuple_PaymentHashPaymentSecretZ; + void (*cloned)(struct LDKSign *NONNULL_PTR new_Sign); + /** + * 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); +} LDKSign; /** - * The contents of CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ + * The contents of CResult_SignDecodeErrorZ */ -typedef union LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZPtr { +typedef union LDKCResult_SignDecodeErrorZPtr { /** * 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; + struct LDKSign *result; /** - * Note that this value is always NULL, as there are no contents in the Err variant + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - void *err; -} LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZPtr; + struct LDKDecodeError *err; +} LDKCResult_SignDecodeErrorZPtr; /** - * A CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ represents the result of a fallible operation, - * containing a crate::c_types::derived::C2Tuple_PaymentHashPaymentSecretZ on success and a () on failure. + * A CResult_SignDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::chain::keysinterface::Sign on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ { +typedef struct LDKCResult_SignDecodeErrorZ { /** - * The contents of this CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ, accessible via either + * The contents of this CResult_SignDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZPtr contents; + union LDKCResult_SignDecodeErrorZPtr contents; /** - * Whether this CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ represents a success state. + * Whether this CResult_SignDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ; +} LDKCResult_SignDecodeErrorZ; /** - * The contents of CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ + * Integer in the range `0..32` */ -typedef union LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZPtr { +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 { /** - * 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_PaymentHashPaymentSecretZ *result; + struct LDKu5 *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 LDKAPIError *err; -} LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZPtr; + uintptr_t datalen; +} LDKCVec_u5Z; /** - * 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`. + * 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. */ -typedef struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ { - /** - * The contents of this CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. - */ - union LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZPtr contents; +typedef struct LDKRecoverableSignature { /** - * Whether this CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ represents a success state. + * The bytes of the signature in "compact" form plus a "Recovery ID" which allows for + * recovery. */ - bool result_ok; -} LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ; + uint8_t serialized_form[68]; +} LDKRecoverableSignature; /** - * The contents of CResult_PaymentSecretNoneZ + * The contents of CResult_RecoverableSignatureNoneZ */ -typedef union LDKCResult_PaymentSecretNoneZPtr { +typedef union LDKCResult_RecoverableSignatureNoneZPtr { /** * 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 LDKRecoverableSignature *result; /** * Note that this value is always NULL, as there are no contents in the Err variant */ void *err; -} LDKCResult_PaymentSecretNoneZPtr; +} LDKCResult_RecoverableSignatureNoneZPtr; /** - * A CResult_PaymentSecretNoneZ represents the result of a fallible operation, - * containing a crate::c_types::ThirtyTwoBytes on success and a () on failure. + * A CResult_RecoverableSignatureNoneZ represents the result of a fallible operation, + * containing a crate::c_types::RecoverableSignature on success and a () on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_PaymentSecretNoneZ { +typedef struct LDKCResult_RecoverableSignatureNoneZ { /** - * The contents of this CResult_PaymentSecretNoneZ, accessible via either + * The contents of this CResult_RecoverableSignatureNoneZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_PaymentSecretNoneZPtr contents; + union LDKCResult_RecoverableSignatureNoneZPtr contents; /** - * Whether this CResult_PaymentSecretNoneZ represents a success state. + * Whether this CResult_RecoverableSignatureNoneZ represents a success state. */ bool result_ok; -} LDKCResult_PaymentSecretNoneZ; - -/** - * The contents of CResult_PaymentSecretAPIErrorZ - */ -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 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_PaymentSecretAPIErrorZPtr; +} LDKCResult_RecoverableSignatureNoneZ; /** - * 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`. + * A dynamically-allocated array of crate::c_types::derived::CVec_u8Zs of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef struct LDKCResult_PaymentSecretAPIErrorZ { +typedef struct LDKCVec_CVec_u8ZZ { /** - * The contents of this CResult_PaymentSecretAPIErrorZ, 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_PaymentSecretAPIErrorZPtr contents; + struct LDKCVec_u8Z *data; /** - * Whether this CResult_PaymentSecretAPIErrorZ represents a success state. + * The number of elements pointed to by `data`. */ - bool result_ok; -} LDKCResult_PaymentSecretAPIErrorZ; + uintptr_t datalen; +} LDKCVec_CVec_u8ZZ; /** - * The contents of CResult_PaymentPreimageAPIErrorZ + * The contents of CResult_CVec_CVec_u8ZZNoneZ */ -typedef union LDKCResult_PaymentPreimageAPIErrorZPtr { +typedef union LDKCResult_CVec_CVec_u8ZZNoneZPtr { /** * 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 LDKCVec_CVec_u8ZZ *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 LDKAPIError *err; -} LDKCResult_PaymentPreimageAPIErrorZPtr; + void *err; +} LDKCResult_CVec_CVec_u8ZZNoneZPtr; /** - * A CResult_PaymentPreimageAPIErrorZ represents the result of a fallible operation, - * containing a crate::c_types::ThirtyTwoBytes on success and a crate::lightning::util::errors::APIError on failure. + * A CResult_CVec_CVec_u8ZZNoneZ represents the result of a fallible operation, + * containing a crate::c_types::derived::CVec_CVec_u8ZZ on success and a () on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_PaymentPreimageAPIErrorZ { +typedef struct LDKCResult_CVec_CVec_u8ZZNoneZ { /** - * The contents of this CResult_PaymentPreimageAPIErrorZ, accessible via either + * The contents of this CResult_CVec_CVec_u8ZZNoneZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_PaymentPreimageAPIErrorZPtr contents; + union LDKCResult_CVec_CVec_u8ZZNoneZPtr contents; /** - * Whether this CResult_PaymentPreimageAPIErrorZ represents a success state. + * Whether this CResult_CVec_CVec_u8ZZNoneZ represents a success state. */ bool result_ok; -} LDKCResult_PaymentPreimageAPIErrorZ; +} LDKCResult_CVec_CVec_u8ZZNoneZ; /** - * Information needed for constructing an invoice route hint for this channel. + * A simple implementation of Sign that just keeps the private keys in memory. + * + * This implementation performs no policy checks and is insufficient by itself as + * a secure external signer. */ -typedef struct MUST_USE_STRUCT LDKCounterpartyForwardingInfo { +typedef struct MUST_USE_STRUCT LDKInMemorySigner { /** * A pointer to the opaque Rust object. * Nearly everywhere, 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; + LDKnativeInMemorySigner *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; +} LDKInMemorySigner; /** - * The contents of CResult_CounterpartyForwardingInfoDecodeErrorZ + * The contents of CResult_InMemorySignerDecodeErrorZ */ -typedef union LDKCResult_CounterpartyForwardingInfoDecodeErrorZPtr { +typedef union LDKCResult_InMemorySignerDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKCounterpartyForwardingInfo *result; + struct LDKInMemorySigner *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_CounterpartyForwardingInfoDecodeErrorZPtr; +} LDKCResult_InMemorySignerDecodeErrorZPtr; /** - * 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. + * A CResult_InMemorySignerDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::chain::keysinterface::InMemorySigner on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_CounterpartyForwardingInfoDecodeErrorZ { +typedef struct LDKCResult_InMemorySignerDecodeErrorZ { /** - * The contents of this CResult_CounterpartyForwardingInfoDecodeErrorZ, accessible via either + * The contents of this CResult_InMemorySignerDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_CounterpartyForwardingInfoDecodeErrorZPtr contents; + union LDKCResult_InMemorySignerDecodeErrorZPtr contents; /** - * Whether this CResult_CounterpartyForwardingInfoDecodeErrorZ represents a success state. + * Whether this CResult_InMemorySignerDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_CounterpartyForwardingInfoDecodeErrorZ; - - +} LDKCResult_InMemorySignerDecodeErrorZ; /** - * Channel parameters which apply to our counterparty. These are split out from [`ChannelDetails`] - * to better separate parameters. + * A dynamically-allocated array of crate::c_types::TxOuts of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef struct MUST_USE_STRUCT LDKChannelCounterparty { +typedef struct LDKCVec_TxOutZ { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, 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(). */ - LDKnativeChannelCounterparty *inner; + struct LDKTxOut *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; -} LDKChannelCounterparty; + uintptr_t datalen; +} LDKCVec_TxOutZ; /** - * The contents of CResult_ChannelCounterpartyDecodeErrorZ + * The contents of CResult_TransactionNoneZ */ -typedef union LDKCResult_ChannelCounterpartyDecodeErrorZPtr { +typedef union LDKCResult_TransactionNoneZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKChannelCounterparty *result; + struct LDKTransaction *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_ChannelCounterpartyDecodeErrorZPtr; + void *err; +} LDKCResult_TransactionNoneZPtr; /** - * 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. + * A CResult_TransactionNoneZ represents the result of a fallible operation, + * containing a crate::c_types::Transaction on success and a () on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_ChannelCounterpartyDecodeErrorZ { +typedef struct LDKCResult_TransactionNoneZ { /** - * The contents of this CResult_ChannelCounterpartyDecodeErrorZ, accessible via either + * The contents of this CResult_TransactionNoneZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_ChannelCounterpartyDecodeErrorZPtr contents; + union LDKCResult_TransactionNoneZPtr contents; /** - * Whether this CResult_ChannelCounterpartyDecodeErrorZ represents a success state. + * Whether this CResult_TransactionNoneZ represents a success state. */ bool result_ok; -} LDKCResult_ChannelCounterpartyDecodeErrorZ; +} LDKCResult_TransactionNoneZ; + + /** - * The contents of CResult_ChannelDetailsDecodeErrorZ + * A ChannelMonitor handles chain events (blocks connected and disconnected) and generates + * on-chain transactions to ensure no loss of funds occurs. + * + * You MUST ensure that no ChannelMonitors for a given channel anywhere contain out-of-date + * information and are actively monitoring the chain. + * + * Pending Events or updated HTLCs which have not yet been read out by + * get_and_clear_pending_monitor_events or get_and_clear_pending_events are serialized to disk and + * reloaded at deserialize-time. Thus, you must ensure that, when handling events, all events + * gotten are fully handled before re-serializing the new state. + * + * Note that the deserializer is only implemented for (BlockHash, ChannelMonitor), which + * tells you the last block hash which was block_connect()ed. You MUST rescan any blocks along + * the \"reorg path\" (ie disconnecting blocks until you find a common ancestor from both the + * returned block hash and the the current chain and then reconnecting blocks to get to the + * best chain) upon deserializing the object! */ -typedef union LDKCResult_ChannelDetailsDecodeErrorZPtr { +typedef struct MUST_USE_STRUCT LDKChannelMonitor { /** - * 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 LDKChannelDetails *result; + LDKnativeChannelMonitor *inner; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - struct LDKDecodeError *err; -} LDKCResult_ChannelDetailsDecodeErrorZPtr; + bool is_owned; +} LDKChannelMonitor; /** - * 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`. + * A tuple of 2 elements. See the individual fields for the types contained. */ -typedef struct LDKCResult_ChannelDetailsDecodeErrorZ { +typedef struct LDKC2Tuple_BlockHashChannelMonitorZ { /** - * The contents of this CResult_ChannelDetailsDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * The element at position 0 */ - union LDKCResult_ChannelDetailsDecodeErrorZPtr contents; + struct LDKThirtyTwoBytes a; /** - * Whether this CResult_ChannelDetailsDecodeErrorZ represents a success state. + * The element at position 1 */ - bool result_ok; -} LDKCResult_ChannelDetailsDecodeErrorZ; - - + struct LDKChannelMonitor b; +} LDKC2Tuple_BlockHashChannelMonitorZ; /** - * Route hints used in constructing invoices for [phantom node payents]. - * - * [phantom node payments]: crate::chain::keysinterface::PhantomKeysManager + * A dynamically-allocated array of crate::c_types::derived::C2Tuple_BlockHashChannelMonitorZs of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef struct MUST_USE_STRUCT LDKPhantomRouteHints { +typedef struct LDKCVec_C2Tuple_BlockHashChannelMonitorZZ { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, 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(). */ - LDKnativePhantomRouteHints *inner; + struct LDKC2Tuple_BlockHashChannelMonitorZ *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; -} LDKPhantomRouteHints; + uintptr_t datalen; +} LDKCVec_C2Tuple_BlockHashChannelMonitorZZ; /** - * The contents of CResult_PhantomRouteHintsDecodeErrorZ + * The contents of CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ */ -typedef union LDKCResult_PhantomRouteHintsDecodeErrorZPtr { +typedef union LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKPhantomRouteHints *result; + struct LDKCVec_C2Tuple_BlockHashChannelMonitorZZ *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKDecodeError *err; -} LDKCResult_PhantomRouteHintsDecodeErrorZPtr; + enum LDKIOError *err; +} LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZPtr; /** - * 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. + * A CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ represents the result of a fallible operation, + * containing a crate::c_types::derived::CVec_C2Tuple_BlockHashChannelMonitorZZ on success and a crate::c_types::IOError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_PhantomRouteHintsDecodeErrorZ { +typedef struct LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ { /** - * The contents of this CResult_PhantomRouteHintsDecodeErrorZ, accessible via either + * The contents of this CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_PhantomRouteHintsDecodeErrorZPtr contents; + union LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZPtr contents; /** - * Whether this CResult_PhantomRouteHintsDecodeErrorZ represents a success state. + * Whether this CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ represents a success state. */ bool result_ok; -} LDKCResult_PhantomRouteHintsDecodeErrorZ; +} LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ; /** - * A dynamically-allocated array of crate::lightning::chain::channelmonitor::ChannelMonitors of arbitrary size. - * This corresponds to std::vector in C++ + * An enum which can either contain a u16 or not */ -typedef struct LDKCVec_ChannelMonitorZ { +typedef enum LDKCOption_u16Z_Tag { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * When we're in this state, this COption_u16Z contains a u16 */ - struct LDKChannelMonitor *data; + LDKCOption_u16Z_Some, /** - * The number of elements pointed to by `data`. + * When we're in this state, this COption_u16Z contains nothing */ - uintptr_t datalen; -} LDKCVec_ChannelMonitorZ; - + LDKCOption_u16Z_None, + /** + * Must be last for serialization purposes + */ + LDKCOption_u16Z_Sentinel, +} LDKCOption_u16Z_Tag; +typedef struct LDKCOption_u16Z { + LDKCOption_u16Z_Tag tag; + union { + struct { + uint16_t some; + }; + }; +} LDKCOption_u16Z; /** - * An update generated by the underlying Channel itself which contains some new information the - * ChannelMonitor should be made aware of. + * Indicates an error on the client's part (usually some variant of attempting to use too-low or + * too-high values) */ -typedef struct MUST_USE_STRUCT LDKChannelMonitorUpdate { +typedef enum LDKAPIError_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. + * Indicates the API was wholly misused (see err for more). Cases where these can be returned + * are documented, but generally indicates some precondition of a function was violated. */ - LDKnativeChannelMonitorUpdate *inner; + LDKAPIError_APIMisuseError, /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * Due to a high feerate, we were unable to complete the request. + * For example, this may be returned if the feerate implies we cannot open a channel at the + * requested value, but opening a larger channel would succeed. */ - 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 { + LDKAPIError_FeeRateTooHigh, /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. + * A malformed Route was provided (eg overflowed value, node id mismatch, overly-looped route, + * too-many-hops, etc). */ - void *this_arg; + LDKAPIError_RouteError, /** - * 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 + * We were unable to complete the request as the Channel required to do so is unable to + * complete the request (or was not found). This can take many forms, including disconnected + * peer, channel at capacity, channel shutting down, etc. */ - struct LDKCResult_NoneChannelMonitorUpdateErrZ (*watch_channel)(const void *this_arg, struct LDKOutPoint funding_txo, struct LDKChannelMonitor monitor); + LDKAPIError_ChannelUnavailable, /** - * 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. + * An attempt to call [`chain::Watch::watch_channel`]/[`chain::Watch::update_channel`] + * returned a [`ChannelMonitorUpdateStatus::InProgress`] indicating the persistence of a + * monitor update is awaiting async resolution. Once it resolves the attempted action should + * complete automatically. * - * [`update_monitor`]: channelmonitor::ChannelMonitor::update_monitor + * [`chain::Watch::watch_channel`]: crate::chain::Watch::watch_channel + * [`chain::Watch::update_channel`]: crate::chain::Watch::update_channel + * [`ChannelMonitorUpdateStatus::InProgress`]: crate::chain::ChannelMonitorUpdateStatus::InProgress */ - struct LDKCResult_NoneChannelMonitorUpdateErrZ (*update_channel)(const void *this_arg, struct LDKOutPoint funding_txo, struct LDKChannelMonitorUpdate update); + LDKAPIError_MonitorUpdateInProgress, /** - * Returns any monitor events since the last call. Subsequent calls must only return new - * events. + * [`KeysInterface::get_shutdown_scriptpubkey`] returned a shutdown scriptpubkey incompatible + * with the channel counterparty as negotiated in [`InitFeatures`]. * - * 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. + * Using a SegWit v0 script should resolve this issue. If you cannot, you won't be able to open + * a channel or cooperatively close one with this peer (and will have to force-close instead). * - * For details on asynchronous [`ChannelMonitor`] updating and returning - * [`MonitorEvent::UpdateCompleted`] here, see [`ChannelMonitorUpdateErr::TemporaryFailure`]. + * [`KeysInterface::get_shutdown_scriptpubkey`]: crate::chain::keysinterface::KeysInterface::get_shutdown_scriptpubkey + * [`InitFeatures`]: crate::ln::features::InitFeatures */ - struct LDKCVec_MonitorEventZ (*release_pending_monitor_events)(const void *this_arg); + LDKAPIError_IncompatibleShutdownScript, /** - * Frees any resources associated with this object given its this_arg pointer. - * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + * Must be last for serialization purposes */ - void (*free)(void *this_arg); -} LDKWatch; + LDKAPIError_Sentinel, +} LDKAPIError_Tag; -/** - * An interface to send a transaction to the Bitcoin network. - */ -typedef struct LDKBroadcasterInterface { +typedef struct LDKAPIError_LDKAPIMisuseError_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. + * A human-readable error message */ - void *this_arg; + struct LDKStr err; +} LDKAPIError_LDKAPIMisuseError_Body; + +typedef struct LDKAPIError_LDKFeeRateTooHigh_Body { /** - * Sends a transaction out to (hopefully) be mined. + * A human-readable error message */ - void (*broadcast_transaction)(const void *this_arg, struct LDKTransaction tx); + struct LDKStr err; /** - * 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 feerate which was too high. */ - void (*free)(void *this_arg); -} LDKBroadcasterInterface; + uint32_t feerate; +} LDKAPIError_LDKFeeRateTooHigh_Body; + +typedef struct LDKAPIError_LDKRouteError_Body { + /** + * A human-readable error message + */ + struct LDKStr err; +} LDKAPIError_LDKRouteError_Body; + +typedef struct LDKAPIError_LDKChannelUnavailable_Body { + /** + * A human-readable error message + */ + struct LDKStr err; +} LDKAPIError_LDKChannelUnavailable_Body; + +typedef struct LDKAPIError_LDKIncompatibleShutdownScript_Body { + /** + * The incompatible shutdown script. + */ + 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; /** - * A "slice" referencing some byte array. This is simply a length-tagged pointer which does not - * own the memory pointed to by data. + * The contents of CResult_NoneAPIErrorZ */ -typedef struct LDKu8slice { +typedef union LDKCResult_NoneAPIErrorZPtr { /** - * A pointer to the byte buffer + * Note that this value is always NULL, as there are no contents in the OK variant */ - const uint8_t *data; + void *result; /** - * The number of bytes 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; -} LDKu8slice; + struct LDKAPIError *err; +} LDKCResult_NoneAPIErrorZPtr; /** - * A trait to describe an object which can get user secrets and key material. + * 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 LDKKeysInterface { +typedef struct LDKCResult_NoneAPIErrorZ { /** - * 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 contents of this CResult_NoneAPIErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - void *this_arg; + union LDKCResult_NoneAPIErrorZPtr contents; /** - * 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. + * Whether this CResult_NoneAPIErrorZ represents a success state. */ - struct LDKCResult_SecretKeyNoneZ (*get_node_secret)(const void *this_arg, enum LDKRecipient recipient); + 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 { /** - * 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. + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - struct LDKCVec_u8Z (*get_destination_script)(const void *this_arg); + struct LDKCResult_NoneAPIErrorZ *data; /** - * 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. + * The number of elements pointed to by `data`. */ - struct LDKShutdownScript (*get_shutdown_scriptpubkey)(const void *this_arg); + 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 { /** - * 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. + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - struct LDKSign (*get_channel_signer)(const void *this_arg, bool inbound, uint64_t channel_value_satoshis); + struct LDKAPIError *data; /** - * 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. + * The number of elements pointed to by `data`. */ - struct LDKThirtyTwoBytes (*get_secure_random_bytes)(const void *this_arg); - /** - * 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. + 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 LDKCResult_SignDecodeErrorZ (*read_chan_signer)(const void *this_arg, struct LDKu8slice reader); + struct LDKThirtyTwoBytes *result; /** - * 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`]. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKCResult_RecoverableSignatureNoneZ (*sign_invoice)(const void *this_arg, struct LDKu8slice hrp_bytes, struct LDKCVec_u5Z invoice_data, enum LDKRecipient receipient); + 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 { /** - * 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 + * The contents of this CResult__u832APIErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKThirtyTwoBytes (*get_inbound_payment_key_material)(const void *this_arg); + union LDKCResult__u832APIErrorZPtr 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__u832APIErrorZ represents a success state. */ - void (*free)(void *this_arg); -} LDKKeysInterface; + bool result_ok; +} LDKCResult__u832APIErrorZ; /** - * 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). + * 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 struct LDKFeeEstimator { +typedef enum LDKPaymentSendFailure_Tag { /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. + * 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. */ - void *this_arg; + LDKPaymentSendFailure_ParameterError, /** - * 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). + * 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. * - * This method can be implemented with the following unit conversions: - * * max(satoshis-per-byte * 250, 253) - * * max(satoshis-per-kbyte / 4, 253) + * The results here are ordered the same as the paths in the route object which was passed to + * send_payment. */ - uint32_t (*get_est_sat_per_1000_weight)(const void *this_arg, enum LDKConfirmationTarget confirmation_target); + LDKPaymentSendFailure_PathParameterError, /** - * 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. + * 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). */ - void (*free)(void *this_arg); -} LDKFeeEstimator; - - - -/** - * 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 LDKRecord { + LDKPaymentSendFailure_AllFailedRetrySafe, /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * 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 `Err`s which are not [`APIError::MonitorUpdateInProgress`] can be + * safely retried via [`ChannelManager::retry_payment`]. + * + * Any entries which contain `Err(APIError::MonitorUpdateInprogress)` 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 a [`MonitorEvent::Completed`] is provided for + * the next-hop channel with the latest update_id. */ - LDKnativeRecord *inner; + LDKPaymentSendFailure_PartialFailure, /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * Must be last for serialization purposes */ - bool is_owned; -} LDKRecord; + LDKPaymentSendFailure_Sentinel, +} LDKPaymentSendFailure_Tag; -/** - * A trait encapsulating the operations required of a logger - */ -typedef struct LDKLogger { +typedef struct LDKPaymentSendFailure_LDKPartialFailure_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 errors themselves, in the same order as the route hops. */ - void *this_arg; + struct LDKCVec_CResult_NoneAPIErrorZZ results; /** - * Logs the `Record` + * 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 */ - void (*log)(const void *this_arg, const struct LDKRecord *NONNULL_PTR record); + struct LDKRouteParameters failed_paths_retry; /** - * 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 payment id for the payment, which is now at least partially pending. */ - void (*free)(void *this_arg); -} LDKLogger; - + 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; /** - * 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. + * The contents of CResult_PaymentIdPaymentSendFailureZ */ -typedef struct MUST_USE_STRUCT LDKChannelManager { +typedef union LDKCResult_PaymentIdPaymentSendFailureZPtr { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, 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. */ - LDKnativeChannelManager *inner; + struct LDKThirtyTwoBytes *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; -} LDKChannelManager; + struct LDKPaymentSendFailure *err; +} LDKCResult_PaymentIdPaymentSendFailureZPtr; /** - * A tuple of 2 elements. See the individual fields for the types contained. + * 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 LDKC2Tuple_BlockHashChannelManagerZ { +typedef struct LDKCResult_PaymentIdPaymentSendFailureZ { /** - * The element at position 0 + * The contents of this CResult_PaymentIdPaymentSendFailureZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKThirtyTwoBytes a; + union LDKCResult_PaymentIdPaymentSendFailureZPtr contents; /** - * The element at position 1 + * Whether this CResult_PaymentIdPaymentSendFailureZ represents a success state. */ - struct LDKChannelManager b; -} LDKC2Tuple_BlockHashChannelManagerZ; + bool result_ok; +} LDKCResult_PaymentIdPaymentSendFailureZ; /** - * The contents of CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ + * The contents of CResult_NonePaymentSendFailureZ */ -typedef union LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr { +typedef union LDKCResult_NonePaymentSendFailureZPtr { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * Note that this value is always NULL, as there are no contents in the OK variant */ - struct LDKC2Tuple_BlockHashChannelManagerZ *result; + void *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_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr; + struct LDKPaymentSendFailure *err; +} LDKCResult_NonePaymentSendFailureZPtr; /** - * 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_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 LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ { +typedef struct LDKCResult_NonePaymentSendFailureZ { /** - * The contents of this CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ, accessible via either + * The contents of this CResult_NonePaymentSendFailureZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr contents; + union LDKCResult_NonePaymentSendFailureZPtr contents; /** - * Whether this CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ represents a success state. + * Whether this CResult_NonePaymentSendFailureZ represents a success state. */ bool result_ok; -} LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ; - - +} LDKCResult_NonePaymentSendFailureZ; /** - * Options which apply on a per-channel basis and may change at runtime or based on negotiation - * with our counterparty. + * A tuple of 2 elements. See the individual fields for the types contained. */ -typedef struct MUST_USE_STRUCT LDKChannelConfig { +typedef struct LDKC2Tuple_PaymentHashPaymentIdZ { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The element at position 0 */ - LDKnativeChannelConfig *inner; + struct LDKThirtyTwoBytes a; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * The element at position 1 */ - bool is_owned; -} LDKChannelConfig; + struct LDKThirtyTwoBytes b; +} LDKC2Tuple_PaymentHashPaymentIdZ; /** - * The contents of CResult_ChannelConfigDecodeErrorZ + * The contents of CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ */ -typedef union LDKCResult_ChannelConfigDecodeErrorZPtr { +typedef union LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZPtr { /** * 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 LDKC2Tuple_PaymentHashPaymentIdZ *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_ChannelConfigDecodeErrorZPtr; + struct LDKPaymentSendFailure *err; +} LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZPtr; /** - * A CResult_ChannelConfigDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::util::config::ChannelConfig on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_C2Tuple_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 LDKCResult_ChannelConfigDecodeErrorZ { +typedef struct LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ { /** - * The contents of this CResult_ChannelConfigDecodeErrorZ, accessible via either + * The contents of this CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_ChannelConfigDecodeErrorZPtr contents; + union LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZPtr contents; /** - * Whether this CResult_ChannelConfigDecodeErrorZ represents a success state. + * Whether this CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ represents a success state. */ bool result_ok; -} LDKCResult_ChannelConfigDecodeErrorZ; +} LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ; /** - * The contents of CResult_OutPointDecodeErrorZ + * A dynamically-allocated array of crate::c_types::ThirtyTwoBytess of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef union LDKCResult_OutPointDecodeErrorZPtr { +typedef struct LDKCVec_ThirtyTwoBytesZ { /** - * 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 LDKOutPoint *result; + struct LDKThirtyTwoBytes *data; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * The number of elements pointed to by `data`. */ - struct LDKDecodeError *err; -} LDKCResult_OutPointDecodeErrorZPtr; + uintptr_t datalen; +} LDKCVec_ThirtyTwoBytesZ; /** - * 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`. + * A tuple of 2 elements. See the individual fields for the types contained. */ -typedef struct LDKCResult_OutPointDecodeErrorZ { +typedef struct LDKC2Tuple_PaymentHashPaymentSecretZ { /** - * The contents of this CResult_OutPointDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * The element at position 0 */ - union LDKCResult_OutPointDecodeErrorZPtr contents; + struct LDKThirtyTwoBytes a; /** - * Whether this CResult_OutPointDecodeErrorZ represents a success state. + * The element at position 1 */ - bool result_ok; -} LDKCResult_OutPointDecodeErrorZ; + struct LDKThirtyTwoBytes b; +} LDKC2Tuple_PaymentHashPaymentSecretZ; /** - * 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_C2Tuple_PaymentHashPaymentSecretZNoneZ */ -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; - /** - * Returns the type identifying the message payload. - */ - uint16_t (*type_id)(const void *this_arg); - /** - * Return a human-readable "debug" string describing this object - */ - struct LDKStr (*debug_str)(const void *this_arg); +typedef union LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZPtr { /** - * Serialize the object into a byte array + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKCVec_u8Z (*write)(const void *this_arg); + struct LDKC2Tuple_PaymentHashPaymentSecretZ *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. + * Note that this value is always NULL, as there are no contents in the Err variant */ - void (*free)(void *this_arg); -} LDKType; + void *err; +} LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZPtr; /** - * An enum which can either contain a crate::lightning::ln::wire::Type or not + * 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 enum LDKCOption_TypeZ_Tag { - /** - * When we're in this state, this COption_TypeZ contains a crate::lightning::ln::wire::Type - */ - LDKCOption_TypeZ_Some, +typedef struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ { /** - * When we're in this state, this COption_TypeZ contains nothing + * The contents of this CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - LDKCOption_TypeZ_None, + union LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZPtr contents; /** - * Must be last for serialization purposes + * Whether this CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ represents a success state. */ - LDKCOption_TypeZ_Sentinel, -} LDKCOption_TypeZ_Tag; - -typedef struct LDKCOption_TypeZ { - LDKCOption_TypeZ_Tag tag; - union { - struct { - struct LDKType some; - }; - }; -} LDKCOption_TypeZ; + bool result_ok; +} LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ; /** - * The contents of CResult_COption_TypeZDecodeErrorZ + * The contents of CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ */ -typedef union LDKCResult_COption_TypeZDecodeErrorZPtr { +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 LDKCOption_TypeZ *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. */ - struct LDKDecodeError *err; -} LDKCResult_COption_TypeZDecodeErrorZPtr; + struct LDKAPIError *err; +} LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZPtr; /** - * 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_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 LDKCResult_COption_TypeZDecodeErrorZ { +typedef struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ { /** - * The contents of this CResult_COption_TypeZDecodeErrorZ, accessible via either + * The contents of this CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_COption_TypeZDecodeErrorZPtr contents; + union LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZPtr contents; /** - * Whether this CResult_COption_TypeZDecodeErrorZ represents a success state. + * Whether this CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ represents a success state. */ bool result_ok; -} LDKCResult_COption_TypeZDecodeErrorZ; +} LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ; /** - * An error that may occur when making a payment. + * The contents of CResult_PaymentSecretNoneZ */ -typedef enum LDKPaymentError_Tag { +typedef union LDKCResult_PaymentSecretNoneZPtr { /** - * An error resulting from the provided [`Invoice`] or payment hash. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - LDKPaymentError_Invoice, + struct LDKThirtyTwoBytes *result; /** - * An error occurring when finding a route. + * Note that this value is always NULL, as there are no contents in the Err variant */ - LDKPaymentError_Routing, + void *err; +} LDKCResult_PaymentSecretNoneZPtr; + +/** + * 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_PaymentSecretNoneZ { /** - * An error occurring when sending a payment. + * The contents of this CResult_PaymentSecretNoneZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - LDKPaymentError_Sending, + union LDKCResult_PaymentSecretNoneZPtr contents; /** - * Must be last for serialization purposes + * Whether this CResult_PaymentSecretNoneZ represents a success state. */ - 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; + bool result_ok; +} LDKCResult_PaymentSecretNoneZ; /** - * The contents of CResult_PaymentIdPaymentErrorZ + * The contents of CResult_PaymentSecretAPIErrorZ */ -typedef union LDKCResult_PaymentIdPaymentErrorZPtr { +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. @@ -7123,16637 +7748,20287 @@ typedef union LDKCResult_PaymentIdPaymentErrorZPtr { * 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 LDKAPIError *err; +} LDKCResult_PaymentSecretAPIErrorZPtr; /** - * 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_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_PaymentIdPaymentErrorZ { +typedef struct LDKCResult_PaymentSecretAPIErrorZ { /** - * The contents of this CResult_PaymentIdPaymentErrorZ, accessible via either + * The contents of this CResult_PaymentSecretAPIErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_PaymentIdPaymentErrorZPtr contents; + union LDKCResult_PaymentSecretAPIErrorZPtr contents; /** - * Whether this CResult_PaymentIdPaymentErrorZ represents a success state. + * Whether this CResult_PaymentSecretAPIErrorZ represents a success state. */ bool result_ok; -} LDKCResult_PaymentIdPaymentErrorZ; +} LDKCResult_PaymentSecretAPIErrorZ; /** - * The contents of CResult_SiPrefixNoneZ + * The contents of CResult_PaymentPreimageAPIErrorZ */ -typedef union LDKCResult_SiPrefixNoneZPtr { +typedef union LDKCResult_PaymentPreimageAPIErrorZPtr { /** * 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 LDKThirtyTwoBytes *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 LDKAPIError *err; +} LDKCResult_PaymentPreimageAPIErrorZPtr; /** - * A CResult_SiPrefixNoneZ represents the result of a fallible operation, - * containing a crate::lightning_invoice::SiPrefix on success and a () on failure. + * A CResult_PaymentPreimageAPIErrorZ represents the result of a fallible operation, + * containing a crate::c_types::ThirtyTwoBytes on success and a crate::lightning::util::errors::APIError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_SiPrefixNoneZ { +typedef struct LDKCResult_PaymentPreimageAPIErrorZ { /** - * The contents of this CResult_SiPrefixNoneZ, accessible via either + * The contents of this CResult_PaymentPreimageAPIErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_SiPrefixNoneZPtr contents; + union LDKCResult_PaymentPreimageAPIErrorZPtr contents; /** - * Whether this CResult_SiPrefixNoneZ represents a success state. + * Whether this CResult_PaymentPreimageAPIErrorZ represents a success state. */ bool result_ok; -} LDKCResult_SiPrefixNoneZ; +} LDKCResult_PaymentPreimageAPIErrorZ; /** - * 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)` + * Information needed for constructing an invoice route hint for this channel. */ -typedef struct MUST_USE_STRUCT LDKInvoice { +typedef struct MUST_USE_STRUCT LDKCounterpartyForwardingInfo { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeInvoice *inner; + LDKnativeCounterpartyForwardingInfo *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKInvoice; +} LDKCounterpartyForwardingInfo; /** - * The contents of CResult_InvoiceNoneZ + * The contents of CResult_CounterpartyForwardingInfoDecodeErrorZ */ -typedef union LDKCResult_InvoiceNoneZPtr { +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 LDKInvoice *result; + struct LDKCounterpartyForwardingInfo *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_InvoiceNoneZPtr; + struct LDKDecodeError *err; +} LDKCResult_CounterpartyForwardingInfoDecodeErrorZPtr; /** - * A CResult_InvoiceNoneZ represents the result of a fallible operation, - * containing a crate::lightning_invoice::Invoice on success and a () 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_InvoiceNoneZ { +typedef struct LDKCResult_CounterpartyForwardingInfoDecodeErrorZ { /** - * The contents of this CResult_InvoiceNoneZ, accessible via either + * The contents of this CResult_CounterpartyForwardingInfoDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_InvoiceNoneZPtr contents; + union LDKCResult_CounterpartyForwardingInfoDecodeErrorZPtr contents; /** - * Whether this CResult_InvoiceNoneZ represents a success state. + * Whether this CResult_CounterpartyForwardingInfoDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_InvoiceNoneZ; +} LDKCResult_CounterpartyForwardingInfoDecodeErrorZ; /** - * 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`. + * Channel parameters which apply to our counterparty. These are split out from [`ChannelDetails`] + * to better separate parameters. */ -typedef struct MUST_USE_STRUCT LDKSignedRawInvoice { +typedef struct MUST_USE_STRUCT LDKChannelCounterparty { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeSignedRawInvoice *inner; + LDKnativeChannelCounterparty *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKSignedRawInvoice; +} LDKChannelCounterparty; /** - * The contents of CResult_SignedRawInvoiceNoneZ + * The contents of CResult_ChannelCounterpartyDecodeErrorZ */ -typedef union LDKCResult_SignedRawInvoiceNoneZPtr { +typedef union LDKCResult_ChannelCounterpartyDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKSignedRawInvoice *result; + struct LDKChannelCounterparty *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_SignedRawInvoiceNoneZPtr; + struct LDKDecodeError *err; +} LDKCResult_ChannelCounterpartyDecodeErrorZPtr; /** - * A CResult_SignedRawInvoiceNoneZ represents the result of a fallible operation, - * containing a crate::lightning_invoice::SignedRawInvoice on success and a () on failure. + * A CResult_ChannelCounterpartyDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::channelmanager::ChannelCounterparty on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_SignedRawInvoiceNoneZ { +typedef struct LDKCResult_ChannelCounterpartyDecodeErrorZ { /** - * The contents of this CResult_SignedRawInvoiceNoneZ, accessible via either + * The contents of this CResult_ChannelCounterpartyDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_SignedRawInvoiceNoneZPtr contents; + union LDKCResult_ChannelCounterpartyDecodeErrorZPtr contents; /** - * Whether this CResult_SignedRawInvoiceNoneZ represents a success state. + * Whether this CResult_ChannelCounterpartyDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_SignedRawInvoiceNoneZ; - - - -/** - * 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 LDKRawInvoice { - /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. - */ - LDKnativeRawInvoice *inner; - /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. - */ - bool is_owned; -} LDKRawInvoice; - - +} LDKCResult_ChannelCounterpartyDecodeErrorZ; /** - * Recoverable signature + * The contents of CResult_ChannelDetailsDecodeErrorZ */ -typedef struct MUST_USE_STRUCT LDKInvoiceSignature { +typedef union LDKCResult_ChannelDetailsDecodeErrorZPtr { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, 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. */ - LDKnativeInvoiceSignature *inner; + struct LDKChannelDetails *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; -} LDKInvoiceSignature; + struct LDKDecodeError *err; +} LDKCResult_ChannelDetailsDecodeErrorZPtr; /** - * A tuple of 3 elements. See the individual fields for the types contained. + * 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 LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ { - /** - * The element at position 0 - */ - struct LDKRawInvoice a; +typedef struct LDKCResult_ChannelDetailsDecodeErrorZ { /** - * The element at position 1 + * The contents of this CResult_ChannelDetailsDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKThirtyTwoBytes b; + union LDKCResult_ChannelDetailsDecodeErrorZPtr contents; /** - * The element at position 2 + * Whether this CResult_ChannelDetailsDecodeErrorZ represents a success state. */ - struct LDKInvoiceSignature c; -} LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ; + bool result_ok; +} LDKCResult_ChannelDetailsDecodeErrorZ; /** - * Payee public key + * Route hints used in constructing invoices for [phantom node payents]. + * + * [phantom node payments]: crate::chain::keysinterface::PhantomKeysManager */ -typedef struct MUST_USE_STRUCT LDKPayeePubKey { +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. */ - LDKnativePayeePubKey *inner; + 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; -} LDKPayeePubKey; +} LDKPhantomRouteHints; /** - * The contents of CResult_PayeePubKeyErrorZ + * The contents of CResult_PhantomRouteHintsDecodeErrorZ */ -typedef union LDKCResult_PayeePubKeyErrorZPtr { +typedef union LDKCResult_PhantomRouteHintsDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKPayeePubKey *result; + struct LDKPhantomRouteHints *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; + struct LDKDecodeError *err; +} LDKCResult_PhantomRouteHintsDecodeErrorZPtr; /** - * A CResult_PayeePubKeyErrorZ represents the result of a fallible operation, - * containing a crate::lightning_invoice::PayeePubKey on success and a crate::c_types::Secp256k1Error on failure. + * A CResult_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_PayeePubKeyErrorZ { +typedef struct LDKCResult_PhantomRouteHintsDecodeErrorZ { /** - * The contents of this CResult_PayeePubKeyErrorZ, accessible via either + * The contents of this CResult_PhantomRouteHintsDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_PayeePubKeyErrorZPtr contents; + union LDKCResult_PhantomRouteHintsDecodeErrorZPtr contents; /** - * Whether this CResult_PayeePubKeyErrorZ represents a success state. + * Whether this CResult_PhantomRouteHintsDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_PayeePubKeyErrorZ; - - - -/** - * Private routing information - * - * # Invariants - * The encoded route has to be <1024 5bit characters long (<=639 bytes or <=12 hops) - * - */ -typedef struct MUST_USE_STRUCT LDKPrivateRoute { - /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. - */ - LDKnativePrivateRoute *inner; - /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. - */ - bool is_owned; -} LDKPrivateRoute; +} LDKCResult_PhantomRouteHintsDecodeErrorZ; /** - * A dynamically-allocated array of crate::lightning_invoice::PrivateRoutes of arbitrary size. + * A dynamically-allocated array of crate::lightning::chain::channelmonitor::ChannelMonitors of arbitrary size. * This corresponds to std::vector in C++ */ -typedef struct LDKCVec_PrivateRouteZ { +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 LDKPrivateRoute *data; + struct LDKChannelMonitor *data; /** * The number of elements pointed to by `data`. */ uintptr_t datalen; -} LDKCVec_PrivateRouteZ; +} LDKCVec_ChannelMonitorZ; /** - * A timestamp that refers to a date after 1 January 1970. - * - * # Invariants + * An update generated by the underlying channel itself which contains some new information the + * [`ChannelMonitor`] should be made aware of. * - * The Unix timestamp representing the stored time has to be positive and no greater than - * [`MAX_TIMESTAMP`]. + * Because this represents only a small number of updates to the underlying state, it is generally + * much smaller than a full [`ChannelMonitor`]. However, for large single commitment transaction + * updates (e.g. ones during which there are hundreds of HTLCs pending on the commitment + * transaction), a single update may reach upwards of 1 MiB in serialized size. */ -typedef struct MUST_USE_STRUCT LDKPositiveTimestamp { +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. */ - LDKnativePositiveTimestamp *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; -} LDKPositiveTimestamp; +} LDKChannelMonitorUpdate; /** - * The contents of CResult_PositiveTimestampCreationErrorZ + * 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 [`ChannelMonitorUpdateStatus`] for more details about how to handle + * multiple instances. + * + * [`PermanentFailure`]: ChannelMonitorUpdateStatus::PermanentFailure */ -typedef union LDKCResult_PositiveTimestampCreationErrorZPtr { +typedef struct LDKWatch { /** - * 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 LDKPositiveTimestamp *result; + void *this_arg; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * 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 [`ChannelMonitorUpdateStatus::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 */ - enum LDKCreationError *err; -} LDKCResult_PositiveTimestampCreationErrorZPtr; - -/** - * A CResult_PositiveTimestampCreationErrorZ represents the result of a fallible operation, - * containing a crate::lightning_invoice::PositiveTimestamp on success and a crate::lightning_invoice::CreationError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_PositiveTimestampCreationErrorZ { + enum LDKChannelMonitorUpdateStatus (*watch_channel)(const void *this_arg, struct LDKOutPoint funding_txo, struct LDKChannelMonitor monitor); /** - * The contents of this CResult_PositiveTimestampCreationErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * Updates a channel identified by `funding_txo` by applying `update` to its monitor. + * + * Implementations must call [`update_monitor`] with the given update. See + * [`ChannelMonitorUpdateStatus`] for invariants around returning an error. + * + * [`update_monitor`]: channelmonitor::ChannelMonitor::update_monitor */ - union LDKCResult_PositiveTimestampCreationErrorZPtr contents; + enum LDKChannelMonitorUpdateStatus (*update_channel)(const void *this_arg, struct LDKOutPoint funding_txo, struct LDKChannelMonitorUpdate update); /** - * Whether this CResult_PositiveTimestampCreationErrorZ represents a success state. + * 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::Completed`] here, see [`ChannelMonitorUpdateStatus::InProgress`]. */ - bool result_ok; -} LDKCResult_PositiveTimestampCreationErrorZ; + struct LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ (*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; /** - * The contents of CResult_NoneSemanticErrorZ + * An interface to send a transaction to the Bitcoin network. */ -typedef union LDKCResult_NoneSemanticErrorZPtr { +typedef struct LDKBroadcasterInterface { /** - * Note that this value is always NULL, as there are no contents in the OK variant + * 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 *result; + void *this_arg; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * Sends a transaction out to (hopefully) be mined. */ - enum LDKSemanticError *err; -} LDKCResult_NoneSemanticErrorZPtr; + 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; /** - * 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`. + * A "slice" referencing some byte array. This is simply a length-tagged pointer which does not + * own the memory pointed to by data. */ -typedef struct LDKCResult_NoneSemanticErrorZ { +typedef struct LDKu8slice { /** - * The contents of this CResult_NoneSemanticErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * A pointer to the byte buffer */ - union LDKCResult_NoneSemanticErrorZPtr contents; + const uint8_t *data; /** - * Whether this CResult_NoneSemanticErrorZ represents a success state. + * The number of bytes pointed to by `data`. */ - bool result_ok; -} LDKCResult_NoneSemanticErrorZ; + uintptr_t datalen; +} LDKu8slice; /** - * The contents of CResult_InvoiceSemanticErrorZ + * A trait to describe an object which can get user secrets and key material. */ -typedef union LDKCResult_InvoiceSemanticErrorZPtr { +typedef struct LDKKeysInterface { /** - * 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. + * Get node secret key based on the provided [`Recipient`]. + * + * The node_id/network_key is the public key that corresponds to this secret key. + * + * This method must return the same value each time it is called with a given `Recipient` + * parameter. + * + * Errors if the `Recipient` variant is not supported by the implementation. */ - enum LDKSemanticError *err; -} LDKCResult_InvoiceSemanticErrorZPtr; + struct LDKCResult_SecretKeyNoneZ (*get_node_secret)(const void *this_arg, enum LDKRecipient recipient); + /** + * Get node id based on the provided [`Recipient`]. This public key corresponds to the secret in + * [`get_node_secret`]. + * + * This method must return the same value each time it is called with a given `Recipient` + * parameter. + * + * Errors if the `Recipient` variant is not supported by the implementation. + * + * [`get_node_secret`]: KeysInterface::get_node_secret + */ + struct LDKCResult_PublicKeyNoneZ (*get_node_id)(const void *this_arg, enum LDKRecipient recipient); + /** + * Gets the ECDH shared secret of our [`node secret`] and `other_key`, multiplying by `tweak` if + * one is provided. Note that this tweak can be applied to `other_key` instead of our node + * secret, though this is less efficient. + * + * Errors if the `Recipient` variant is not supported by the implementation. + * + * [`node secret`]: Self::get_node_secret + */ + struct LDKCResult_SharedSecretNoneZ (*ecdh)(const void *this_arg, enum LDKRecipient recipient, struct LDKPublicKey other_key, struct LDKCOption_ScalarZ tweak); + /** + * 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. + */ + struct LDKCVec_u8Z (*get_destination_script)(const void *this_arg); + /** + * 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. + */ + struct LDKShutdownScript (*get_shutdown_scriptpubkey)(const void *this_arg); + /** + * 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 LDKSign (*get_channel_signer)(const void *this_arg, bool inbound, uint64_t channel_value_satoshis); + /** + * 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. + */ + struct LDKThirtyTwoBytes (*get_secure_random_bytes)(const void *this_arg); + /** + * 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. + */ + struct LDKCResult_SignDecodeErrorZ (*read_chan_signer)(const void *this_arg, struct LDKu8slice reader); + /** + * 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`]. + * + * Errors if the `Recipient` variant is not supported by the implementation. + */ + struct LDKCResult_RecoverableSignatureNoneZ (*sign_invoice)(const void *this_arg, struct LDKu8slice hrp_bytes, struct LDKCVec_u5Z invoice_data, enum LDKRecipient 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; /** - * 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`. + * 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 LDKCResult_InvoiceSemanticErrorZ { +typedef struct LDKFeeEstimator { /** - * The contents of this CResult_InvoiceSemanticErrorZ, 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_InvoiceSemanticErrorZPtr contents; + void *this_arg; /** - * Whether this CResult_InvoiceSemanticErrorZ represents a success state. + * Gets estimated satoshis of fee required per 1000 Weight-Units. + * + * LDK will wrap this method and ensure that the value returned is 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). + * + * The following unit conversions can be used to convert to sats/KW: + * * satoshis-per-byte * 250 + * * satoshis-per-kbyte / 4 */ - bool result_ok; -} LDKCResult_InvoiceSemanticErrorZ; + 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; /** - * Description string + * 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. * - * # Invariants - * The description can be at most 639 __bytes__ long + * 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 LDKDescription { +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. */ - LDKnativeDescription *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; -} LDKDescription; +} LDKChannelManager; /** - * The contents of CResult_DescriptionCreationErrorZ + * A tuple of 2 elements. See the individual fields for the types contained. */ -typedef union LDKCResult_DescriptionCreationErrorZPtr { +typedef struct LDKC2Tuple_BlockHashChannelManagerZ { + /** + * The element at position 0 + */ + struct LDKThirtyTwoBytes a; + /** + * The element at position 1 + */ + struct LDKChannelManager b; +} LDKC2Tuple_BlockHashChannelManagerZ; + +/** + * The contents of CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ + */ +typedef union LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr { /** * 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 LDKC2Tuple_BlockHashChannelManagerZ *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_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr; /** - * 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_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 LDKCResult_DescriptionCreationErrorZ { +typedef struct LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ { /** - * The contents of this CResult_DescriptionCreationErrorZ, accessible via either + * The contents of this CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_DescriptionCreationErrorZPtr contents; + union LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr contents; /** - * Whether this CResult_DescriptionCreationErrorZ represents a success state. + * Whether this CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_DescriptionCreationErrorZ; +} LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ; + + /** - * The contents of CResult_PrivateRouteCreationErrorZ + * Options which apply on a per-channel basis and may change at runtime or based on negotiation + * with our counterparty. */ -typedef union LDKCResult_PrivateRouteCreationErrorZPtr { +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. + */ + 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; +} LDKChannelConfig; + +/** + * The contents of CResult_ChannelConfigDecodeErrorZ + */ +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 LDKPrivateRoute *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_PrivateRouteCreationErrorZPtr; + struct LDKDecodeError *err; +} LDKCResult_ChannelConfigDecodeErrorZPtr; /** - * 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_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_PrivateRouteCreationErrorZ { +typedef struct LDKCResult_ChannelConfigDecodeErrorZ { /** - * The contents of this CResult_PrivateRouteCreationErrorZ, accessible via either + * The contents of this CResult_ChannelConfigDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_PrivateRouteCreationErrorZPtr contents; + union LDKCResult_ChannelConfigDecodeErrorZPtr contents; /** - * Whether this CResult_PrivateRouteCreationErrorZ represents a success state. + * Whether this CResult_ChannelConfigDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_PrivateRouteCreationErrorZ; +} LDKCResult_ChannelConfigDecodeErrorZ; /** - * The contents of CResult_StringErrorZ + * The contents of CResult_OutPointDecodeErrorZ */ -typedef union LDKCResult_StringErrorZPtr { +typedef union LDKCResult_OutPointDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKStr *result; + struct LDKOutPoint *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_StringErrorZPtr; + struct LDKDecodeError *err; +} LDKCResult_OutPointDecodeErrorZPtr; /** - * A CResult_StringErrorZ represents the result of a fallible operation, - * containing a crate::c_types::Str on success and a crate::c_types::Secp256k1Error on failure. + * A CResult_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_StringErrorZ { +typedef struct LDKCResult_OutPointDecodeErrorZ { /** - * The contents of this CResult_StringErrorZ, accessible via either + * The contents of this CResult_OutPointDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_StringErrorZPtr contents; + union LDKCResult_OutPointDecodeErrorZPtr contents; /** - * Whether this CResult_StringErrorZ represents a success state. + * Whether this CResult_OutPointDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_StringErrorZ; +} LDKCResult_OutPointDecodeErrorZ; /** - * The contents of CResult_ChannelMonitorUpdateDecodeErrorZ + * Defines a type identifier for sending messages over the wire. + * + * Messages implementing this trait specify a type and must be [`Writeable`]. */ -typedef union LDKCResult_ChannelMonitorUpdateDecodeErrorZPtr { +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; + /** + * Returns the type identifying the message payload. + */ + uint16_t (*type_id)(const void *this_arg); + /** + * Return a human-readable "debug" string describing this object + */ + struct LDKStr (*debug_str)(const void *this_arg); + /** + * Serialize the object into a byte array + */ + struct LDKCVec_u8Z (*write)(const void *this_arg); + /** + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + */ + void (*free)(void *this_arg); +} LDKType; + +/** + * 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, + /** + * When we're in this state, this COption_TypeZ contains nothing + */ + 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_COption_TypeZDecodeErrorZ + */ +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 LDKChannelMonitorUpdate *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. */ struct LDKDecodeError *err; -} LDKCResult_ChannelMonitorUpdateDecodeErrorZPtr; +} LDKCResult_COption_TypeZDecodeErrorZPtr; /** - * A CResult_ChannelMonitorUpdateDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::chain::channelmonitor::ChannelMonitorUpdate on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_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_ChannelMonitorUpdateDecodeErrorZ { +typedef struct LDKCResult_COption_TypeZDecodeErrorZ { /** - * The contents of this CResult_ChannelMonitorUpdateDecodeErrorZ, 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_ChannelMonitorUpdateDecodeErrorZPtr contents; + union LDKCResult_COption_TypeZDecodeErrorZPtr contents; /** - * Whether this CResult_ChannelMonitorUpdateDecodeErrorZ represents a success state. + * Whether this CResult_COption_TypeZDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_ChannelMonitorUpdateDecodeErrorZ; +} LDKCResult_COption_TypeZDecodeErrorZ; /** - * An enum which can either contain a crate::lightning::chain::channelmonitor::MonitorEvent or not + * An error that may occur when making a payment. */ -typedef enum LDKCOption_MonitorEventZ_Tag { +typedef enum LDKPaymentError_Tag { /** - * When we're in this state, this COption_MonitorEventZ contains a crate::lightning::chain::channelmonitor::MonitorEvent + * An error resulting from the provided [`Invoice`] or payment hash. */ - LDKCOption_MonitorEventZ_Some, + LDKPaymentError_Invoice, /** - * When we're in this state, this COption_MonitorEventZ contains nothing + * An error occurring when finding a route. */ - LDKCOption_MonitorEventZ_None, + LDKPaymentError_Routing, + /** + * An error occurring when sending a payment. + */ + LDKPaymentError_Sending, /** * Must be last for serialization purposes */ - LDKCOption_MonitorEventZ_Sentinel, -} LDKCOption_MonitorEventZ_Tag; + LDKPaymentError_Sentinel, +} LDKPaymentError_Tag; -typedef struct LDKCOption_MonitorEventZ { - LDKCOption_MonitorEventZ_Tag tag; +typedef struct MUST_USE_STRUCT LDKPaymentError { + LDKPaymentError_Tag tag; union { struct { - struct LDKMonitorEvent some; + struct LDKStr invoice; + }; + struct { + struct LDKLightningError routing; + }; + struct { + struct LDKPaymentSendFailure sending; }; }; -} LDKCOption_MonitorEventZ; +} LDKPaymentError; /** - * The contents of CResult_COption_MonitorEventZDecodeErrorZ + * The contents of CResult_PaymentIdPaymentErrorZ */ -typedef union LDKCResult_COption_MonitorEventZDecodeErrorZPtr { +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 LDKCOption_MonitorEventZ *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_COption_MonitorEventZDecodeErrorZPtr; + struct LDKPaymentError *err; +} LDKCResult_PaymentIdPaymentErrorZPtr; /** - * A CResult_COption_MonitorEventZDecodeErrorZ represents the result of a fallible operation, - * containing a crate::c_types::derived::COption_MonitorEventZ on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_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_COption_MonitorEventZDecodeErrorZ { +typedef struct LDKCResult_PaymentIdPaymentErrorZ { /** - * The contents of this CResult_COption_MonitorEventZDecodeErrorZ, accessible via either + * The contents of this CResult_PaymentIdPaymentErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_COption_MonitorEventZDecodeErrorZPtr contents; + union LDKCResult_PaymentIdPaymentErrorZPtr contents; /** - * Whether this CResult_COption_MonitorEventZDecodeErrorZ represents a success state. + * Whether this CResult_PaymentIdPaymentErrorZ represents a success state. */ bool result_ok; -} LDKCResult_COption_MonitorEventZDecodeErrorZ; +} LDKCResult_PaymentIdPaymentErrorZ; + + /** - * The contents of CResult_HTLCUpdateDecodeErrorZ + * A map with liquidity value (in msat) keyed by a short channel id and the direction the HTLC + * is traveling in. The direction boolean is determined by checking if the HTLC source's public + * key is less than its destination. See [`InFlightHtlcs::used_liquidity_msat`] for more + * details. */ -typedef union LDKCResult_HTLCUpdateDecodeErrorZPtr { +typedef struct MUST_USE_STRUCT LDKInFlightHtlcs { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeInFlightHtlcs *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; +} LDKInFlightHtlcs; + +/** + * The contents of CResult_InFlightHtlcsDecodeErrorZ + */ +typedef union LDKCResult_InFlightHtlcsDecodeErrorZPtr { /** * 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 LDKInFlightHtlcs *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_HTLCUpdateDecodeErrorZPtr; +} LDKCResult_InFlightHtlcsDecodeErrorZPtr; /** - * 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_InFlightHtlcsDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning_invoice::payment::InFlightHtlcs on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_HTLCUpdateDecodeErrorZ { +typedef struct LDKCResult_InFlightHtlcsDecodeErrorZ { /** - * The contents of this CResult_HTLCUpdateDecodeErrorZ, accessible via either + * The contents of this CResult_InFlightHtlcsDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_HTLCUpdateDecodeErrorZPtr contents; + union LDKCResult_InFlightHtlcsDecodeErrorZPtr contents; /** - * Whether this CResult_HTLCUpdateDecodeErrorZ represents a success state. + * Whether this CResult_InFlightHtlcsDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_HTLCUpdateDecodeErrorZ; +} LDKCResult_InFlightHtlcsDecodeErrorZ; /** - * A tuple of 2 elements. See the individual fields for the types contained. + * Sub-errors which don't have specific information in them use this type. */ -typedef struct LDKC2Tuple_OutPointScriptZ { - /** - * The element at position 0 - */ - struct LDKOutPoint a; +typedef struct LDKError { /** - * The element at position 1 + * Zero-Sized_types aren't consistent across Rust/C/C++, so we add some size here */ - struct LDKCVec_u8Z b; -} LDKC2Tuple_OutPointScriptZ; + uint8_t _dummy; +} LDKError; /** - * A tuple of 2 elements. See the individual fields for the types contained. + * Errors that indicate what is wrong with the invoice. They have some granularity for debug + * reasons, but should generally result in an \"invalid BOLT11 invoice\" message for the user. */ -typedef struct LDKC2Tuple_u32ScriptZ { +typedef enum LDKParseError_Tag { + LDKParseError_Bech32Error, + LDKParseError_ParseAmountError, + LDKParseError_MalformedSignature, + LDKParseError_BadPrefix, + LDKParseError_UnknownCurrency, + LDKParseError_UnknownSiPrefix, + LDKParseError_MalformedHRP, + LDKParseError_TooShortDataPart, + LDKParseError_UnexpectedEndOfTaggedFields, + LDKParseError_DescriptionDecodeError, + LDKParseError_PaddingError, + LDKParseError_IntegerOverflowError, + LDKParseError_InvalidSegWitProgramLength, + LDKParseError_InvalidPubKeyHashLength, + LDKParseError_InvalidScriptHashLength, + LDKParseError_InvalidRecoveryId, + LDKParseError_InvalidSliceLength, /** - * The element at position 0 + * Not an error, but used internally to signal that a part of the invoice should be ignored + * according to BOLT11 */ - uint32_t a; + LDKParseError_Skip, /** - * The element at position 1 + * Must be last for serialization purposes */ - struct LDKCVec_u8Z b; -} LDKC2Tuple_u32ScriptZ; + LDKParseError_Sentinel, +} LDKParseError_Tag; + +typedef struct MUST_USE_STRUCT LDKParseError { + LDKParseError_Tag tag; + union { + struct { + struct LDKBech32Error bech32_error; + }; + struct { + struct LDKError parse_amount_error; + }; + struct { + enum LDKSecp256k1Error malformed_signature; + }; + struct { + struct LDKError description_decode_error; + }; + struct { + struct LDKStr invalid_slice_length; + }; + }; +} LDKParseError; /** - * A dynamically-allocated array of crate::c_types::derived::C2Tuple_u32ScriptZs of arbitrary size. - * This corresponds to std::vector in C++ + * The contents of CResult_SiPrefixParseErrorZ */ -typedef struct LDKCVec_C2Tuple_u32ScriptZZ { +typedef union LDKCResult_SiPrefixParseErrorZPtr { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKC2Tuple_u32ScriptZ *data; + enum LDKSiPrefix *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_C2Tuple_u32ScriptZZ; + struct LDKParseError *err; +} LDKCResult_SiPrefixParseErrorZPtr; /** - * A tuple of 2 elements. See the individual fields for the types contained. + * A CResult_SiPrefixParseErrorZ represents the result of a fallible operation, + * containing a crate::lightning_invoice::SiPrefix on success and a crate::lightning_invoice::ParseError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ { +typedef struct LDKCResult_SiPrefixParseErrorZ { /** - * The element at position 0 + * The contents of this CResult_SiPrefixParseErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKThirtyTwoBytes a; + union LDKCResult_SiPrefixParseErrorZPtr contents; /** - * The element at position 1 + * Whether this CResult_SiPrefixParseErrorZ represents a success state. */ - struct LDKCVec_C2Tuple_u32ScriptZZ b; -} LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ; + bool result_ok; +} LDKCResult_SiPrefixParseErrorZ; + + /** - * A dynamically-allocated array of crate::c_types::derived::C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZs of arbitrary size. - * This corresponds to std::vector in C++ + * 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 struct LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ { +typedef struct MUST_USE_STRUCT LDKInvoice { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - struct LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *data; + LDKnativeInvoice *inner; /** - * The number of elements pointed to by `data`. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - uintptr_t datalen; -} LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ; + bool is_owned; +} LDKInvoice; /** - * A dynamically-allocated array of crate::lightning::util::events::Events of arbitrary size. - * This corresponds to std::vector in C++ + * Indicates that something went wrong while parsing or validating the invoice. Parsing errors + * should be mostly seen as opaque and are only there for debugging reasons. Semantic errors + * like wrong signatures, missing fields etc. could mean that someone tampered with the invoice. */ -typedef struct LDKCVec_EventZ { +typedef enum LDKParseOrSemanticError_Tag { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * The invoice couldn't be decoded */ - struct LDKEvent *data; + LDKParseOrSemanticError_ParseError, /** - * The number of elements pointed to by `data`. + * The invoice could be decoded but violates the BOLT11 standard */ - uintptr_t datalen; -} LDKCVec_EventZ; + LDKParseOrSemanticError_SemanticError, + /** + * Must be last for serialization purposes + */ + LDKParseOrSemanticError_Sentinel, +} LDKParseOrSemanticError_Tag; + +typedef struct MUST_USE_STRUCT LDKParseOrSemanticError { + LDKParseOrSemanticError_Tag tag; + union { + struct { + struct LDKParseError parse_error; + }; + struct { + enum LDKSemanticError semantic_error; + }; + }; +} LDKParseOrSemanticError; /** - * A dynamically-allocated array of crate::c_types::Transactions of arbitrary size. - * This corresponds to std::vector in C++ + * The contents of CResult_InvoiceParseOrSemanticErrorZ */ -typedef struct LDKCVec_TransactionZ { +typedef union LDKCResult_InvoiceParseOrSemanticErrorZPtr { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKTransaction *data; + struct LDKInvoice *result; /** - * The number of elements pointed to by `data`. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - uintptr_t datalen; -} LDKCVec_TransactionZ; + struct LDKParseOrSemanticError *err; +} LDKCResult_InvoiceParseOrSemanticErrorZPtr; /** - * A tuple of 2 elements. See the individual fields for the types contained. + * A CResult_InvoiceParseOrSemanticErrorZ represents the result of a fallible operation, + * containing a crate::lightning_invoice::Invoice on success and a crate::lightning_invoice::ParseOrSemanticError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKC2Tuple_u32TxOutZ { +typedef struct LDKCResult_InvoiceParseOrSemanticErrorZ { /** - * The element at position 0 + * The contents of this CResult_InvoiceParseOrSemanticErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - uint32_t a; + union LDKCResult_InvoiceParseOrSemanticErrorZPtr contents; /** - * The element at position 1 + * Whether this CResult_InvoiceParseOrSemanticErrorZ represents a success state. */ - struct LDKTxOut b; -} LDKC2Tuple_u32TxOutZ; + bool result_ok; +} LDKCResult_InvoiceParseOrSemanticErrorZ; + + /** - * A dynamically-allocated array of crate::c_types::derived::C2Tuple_u32TxOutZs of arbitrary size. - * This corresponds to std::vector in C++ + * 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 LDKCVec_C2Tuple_u32TxOutZZ { +typedef struct MUST_USE_STRUCT LDKSignedRawInvoice { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - struct LDKC2Tuple_u32TxOutZ *data; + LDKnativeSignedRawInvoice *inner; /** - * The number of elements pointed to by `data`. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - uintptr_t datalen; -} LDKCVec_C2Tuple_u32TxOutZZ; + bool is_owned; +} LDKSignedRawInvoice; /** - * A tuple of 2 elements. See the individual fields for the types contained. + * The contents of CResult_SignedRawInvoiceParseErrorZ */ -typedef struct LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ { +typedef union LDKCResult_SignedRawInvoiceParseErrorZPtr { /** - * The element at position 0 + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKThirtyTwoBytes a; + struct LDKSignedRawInvoice *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_C2Tuple_u32TxOutZZ b; -} LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ; + struct LDKParseError *err; +} LDKCResult_SignedRawInvoiceParseErrorZPtr; /** - * A dynamically-allocated array of crate::c_types::derived::C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZs of arbitrary size. - * This corresponds to std::vector in C++ + * A CResult_SignedRawInvoiceParseErrorZ represents the result of a fallible operation, + * containing a crate::lightning_invoice::SignedRawInvoice on success and a crate::lightning_invoice::ParseError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCVec_TransactionOutputsZ { +typedef struct LDKCResult_SignedRawInvoiceParseErrorZ { /** - * 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_SignedRawInvoiceParseErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *data; + union LDKCResult_SignedRawInvoiceParseErrorZPtr contents; /** - * The number of elements pointed to by `data`. + * Whether this CResult_SignedRawInvoiceParseErrorZ represents a success state. */ - uintptr_t datalen; -} LDKCVec_TransactionOutputsZ; + bool result_ok; +} LDKCResult_SignedRawInvoiceParseErrorZ; + + /** - * Details about the balance(s) available for spending once the channel appears on chain. + * 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. * - * See [`ChannelMonitor::get_claimable_balances`] for more details on when these will or will not - * be provided. + * For methods without docs see the corresponding methods in `Invoice`. */ -typedef enum LDKBalance_Tag { - /** - * The channel is not yet closed (or the commitment or closing transaction has not yet - * appeared in a block). The given balance is claimable (less on-chain fees) if the channel is - * force-closed now. - */ - LDKBalance_ClaimableOnChannelClose, +typedef struct MUST_USE_STRUCT LDKRawInvoice { /** - * The channel has been closed, and the given balance is ours but awaiting confirmations until - * we consider it spendable. + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKBalance_ClaimableAwaitingConfirmations, + LDKnativeRawInvoice *inner; /** - * The channel has been closed, and the given balance should be ours but awaiting spending - * transaction confirmation. If the spending transaction does not confirm in time, it is - * possible our counterparty can take the funds by broadcasting an HTLC timeout on-chain. - * - * Once the spending transaction confirms, before it has reached enough confirmations to be - * considered safe from chain reorganizations, the balance will instead be provided via - * [`Balance::ClaimableAwaitingConfirmations`]. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - LDKBalance_ContentiousClaimable, + bool is_owned; +} LDKRawInvoice; + + + +/** + * Recoverable signature + */ +typedef struct MUST_USE_STRUCT LDKInvoiceSignature { /** - * HTLCs which we sent to our counterparty which are claimable after a timeout (less on-chain - * fees) if the counterparty does not know the preimage for the HTLCs. These are somewhat - * likely to be claimed by our counterparty before we do. + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKBalance_MaybeClaimableHTLCAwaitingTimeout, + LDKnativeInvoiceSignature *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. */ - LDKBalance_Sentinel, -} LDKBalance_Tag; + bool is_owned; +} LDKInvoiceSignature; -typedef struct LDKBalance_LDKClaimableOnChannelClose_Body { +/** + * A tuple of 3 elements. See the individual fields for the types contained. + */ +typedef struct LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ { /** - * The amount available to claim, in satoshis, excluding the on-chain fees which will be - * required to do so. + * The element at position 0 */ - uint64_t claimable_amount_satoshis; -} LDKBalance_LDKClaimableOnChannelClose_Body; - -typedef struct LDKBalance_LDKClaimableAwaitingConfirmations_Body { + struct LDKRawInvoice a; /** - * The amount available to claim, in satoshis, possibly excluding the on-chain fees which - * were spent in broadcasting the transaction. + * The element at position 1 */ - uint64_t claimable_amount_satoshis; + struct LDKThirtyTwoBytes b; /** - * The height at which an [`Event::SpendableOutputs`] event will be generated for this - * amount. + * The element at position 2 */ - uint32_t confirmation_height; -} LDKBalance_LDKClaimableAwaitingConfirmations_Body; + struct LDKInvoiceSignature c; +} LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ; -typedef struct LDKBalance_LDKContentiousClaimable_Body { + + +/** + * Payee public key + */ +typedef struct MUST_USE_STRUCT LDKPayeePubKey { /** - * The amount available to claim, in satoshis, excluding the on-chain fees which will be - * required to do so. - */ - uint64_t claimable_amount_satoshis; - /** - * The height at which the counterparty may be able to claim the balance if we have not - * done so. - */ - uint32_t timeout_height; -} LDKBalance_LDKContentiousClaimable_Body; - -typedef struct LDKBalance_LDKMaybeClaimableHTLCAwaitingTimeout_Body { - /** - * The amount available to claim, in satoshis, excluding the on-chain fees which will be - * required to do so. - */ - uint64_t claimable_amount_satoshis; - /** - * The height at which we will be able to claim the balance if our counterparty has not - * done so. - */ - uint32_t claimable_height; -} LDKBalance_LDKMaybeClaimableHTLCAwaitingTimeout_Body; - -typedef struct MUST_USE_STRUCT LDKBalance { - LDKBalance_Tag tag; - union { - LDKBalance_LDKClaimableOnChannelClose_Body claimable_on_channel_close; - LDKBalance_LDKClaimableAwaitingConfirmations_Body claimable_awaiting_confirmations; - LDKBalance_LDKContentiousClaimable_Body contentious_claimable; - LDKBalance_LDKMaybeClaimableHTLCAwaitingTimeout_Body maybe_claimable_htlc_awaiting_timeout; - }; -} LDKBalance; - -/** - * A dynamically-allocated array of crate::lightning::chain::channelmonitor::Balances of arbitrary size. - * This corresponds to std::vector in C++ - */ -typedef struct LDKCVec_BalanceZ { - /** - * 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 LDKBalance *data; + LDKnativePayeePubKey *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_BalanceZ; + bool is_owned; +} LDKPayeePubKey; /** - * The contents of CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ + * The contents of CResult_PayeePubKeyErrorZ */ -typedef union LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZPtr { +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 LDKC2Tuple_BlockHashChannelMonitorZ *result; + struct LDKPayeePubKey *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_C2Tuple_BlockHashChannelMonitorZDecodeErrorZPtr; + enum LDKSecp256k1Error *err; +} LDKCResult_PayeePubKeyErrorZPtr; /** - * A CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ represents the result of a fallible operation, - * containing a crate::c_types::derived::C2Tuple_BlockHashChannelMonitorZ on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_PayeePubKeyErrorZ represents the result of a fallible operation, + * containing a crate::lightning_invoice::PayeePubKey on success and a crate::c_types::Secp256k1Error on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ { +typedef struct LDKCResult_PayeePubKeyErrorZ { /** - * The contents of this CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ, accessible via either + * The contents of this CResult_PayeePubKeyErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZPtr contents; + union LDKCResult_PayeePubKeyErrorZPtr contents; /** - * Whether this CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ represents a success state. + * Whether this CResult_PayeePubKeyErrorZ represents a success state. */ bool result_ok; -} LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ; +} LDKCResult_PayeePubKeyErrorZ; + -/** - * The contents of CResult_NoneLightningErrorZ - */ -typedef union LDKCResult_NoneLightningErrorZPtr { - /** - * 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 LDKLightningError *err; -} LDKCResult_NoneLightningErrorZPtr; /** - * A CResult_NoneLightningErrorZ represents the result of a fallible operation, - * containing a () on success and a crate::lightning::ln::msgs::LightningError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. + * Private routing information + * + * # Invariants + * The encoded route has to be <1024 5bit characters long (<=639 bytes or <=12 hops) + * */ -typedef struct LDKCResult_NoneLightningErrorZ { +typedef struct MUST_USE_STRUCT LDKPrivateRoute { /** - * The contents of this CResult_NoneLightningErrorZ, 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_NoneLightningErrorZPtr contents; + LDKnativePrivateRoute *inner; /** - * Whether this CResult_NoneLightningErrorZ 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_NoneLightningErrorZ; + bool is_owned; +} LDKPrivateRoute; /** - * A tuple of 2 elements. See the individual fields for the types contained. + * A dynamically-allocated array of crate::lightning_invoice::PrivateRoutes of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef struct LDKC2Tuple_PublicKeyTypeZ { +typedef struct LDKCVec_PrivateRouteZ { /** - * 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 LDKPublicKey a; + struct LDKPrivateRoute *data; /** - * The element at position 1 + * The number of elements pointed to by `data`. */ - struct LDKType b; -} LDKC2Tuple_PublicKeyTypeZ; + uintptr_t datalen; +} LDKCVec_PrivateRouteZ; + + /** - * A dynamically-allocated array of crate::c_types::derived::C2Tuple_PublicKeyTypeZs of arbitrary size. - * This corresponds to std::vector in C++ + * 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 struct LDKCVec_C2Tuple_PublicKeyTypeZZ { +typedef struct MUST_USE_STRUCT LDKPositiveTimestamp { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - struct LDKC2Tuple_PublicKeyTypeZ *data; + LDKnativePositiveTimestamp *inner; /** - * The number of elements pointed to by `data`. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - uintptr_t datalen; -} LDKCVec_C2Tuple_PublicKeyTypeZZ; + bool is_owned; +} LDKPositiveTimestamp; /** - * The contents of CResult_boolLightningErrorZ + * The contents of CResult_PositiveTimestampCreationErrorZ */ -typedef union LDKCResult_boolLightningErrorZPtr { +typedef union LDKCResult_PositiveTimestampCreationErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - bool *result; + struct LDKPositiveTimestamp *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKLightningError *err; -} LDKCResult_boolLightningErrorZPtr; + enum LDKCreationError *err; +} LDKCResult_PositiveTimestampCreationErrorZPtr; /** - * A CResult_boolLightningErrorZ represents the result of a fallible operation, - * containing a bool on success and a crate::lightning::ln::msgs::LightningError on failure. + * A CResult_PositiveTimestampCreationErrorZ represents the result of a fallible operation, + * containing a crate::lightning_invoice::PositiveTimestamp on success and a crate::lightning_invoice::CreationError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_boolLightningErrorZ { +typedef struct LDKCResult_PositiveTimestampCreationErrorZ { /** - * The contents of this CResult_boolLightningErrorZ, accessible via either + * The contents of this CResult_PositiveTimestampCreationErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_boolLightningErrorZPtr contents; + union LDKCResult_PositiveTimestampCreationErrorZPtr contents; /** - * Whether this CResult_boolLightningErrorZ represents a success state. + * Whether this CResult_PositiveTimestampCreationErrorZ represents a success state. */ bool result_ok; -} LDKCResult_boolLightningErrorZ; +} LDKCResult_PositiveTimestampCreationErrorZ; /** - * A tuple of 3 elements. See the individual fields for the types contained. + * The contents of CResult_NoneSemanticErrorZ */ -typedef struct LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ { - /** - * The element at position 0 - */ - struct LDKChannelAnnouncement a; +typedef union LDKCResult_NoneSemanticErrorZPtr { /** - * The element at position 1 + * Note that this value is always NULL, as there are no contents in the OK variant */ - struct LDKChannelUpdate b; + void *result; /** - * The element at position 2 + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKChannelUpdate c; -} LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ; + enum LDKSemanticError *err; +} LDKCResult_NoneSemanticErrorZPtr; /** - * A dynamically-allocated array of crate::c_types::derived::C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZs of arbitrary size. - * This corresponds to std::vector in C++ + * 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 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ { +typedef struct LDKCResult_NoneSemanticErrorZ { /** - * 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_NoneSemanticErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *data; + union LDKCResult_NoneSemanticErrorZPtr contents; /** - * The number of elements pointed to by `data`. + * Whether this CResult_NoneSemanticErrorZ represents a success state. */ - uintptr_t datalen; -} LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ; + bool result_ok; +} LDKCResult_NoneSemanticErrorZ; /** - * A dynamically-allocated array of crate::lightning::ln::msgs::NodeAnnouncements of arbitrary size. - * This corresponds to std::vector in C++ + * The contents of CResult_InvoiceSemanticErrorZ */ -typedef struct LDKCVec_NodeAnnouncementZ { +typedef union LDKCResult_InvoiceSemanticErrorZPtr { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKNodeAnnouncement *data; + struct LDKInvoice *result; /** - * The number of elements pointed to by `data`. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - uintptr_t datalen; -} LDKCVec_NodeAnnouncementZ; + enum LDKSemanticError *err; +} LDKCResult_InvoiceSemanticErrorZPtr; /** - * A dynamically-allocated array of crate::c_types::PublicKeys of arbitrary size. - * This corresponds to std::vector in C++ + * A CResult_InvoiceSemanticErrorZ represents the result of a fallible operation, + * containing a crate::lightning_invoice::Invoice on success and a crate::lightning_invoice::SemanticError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCVec_PublicKeyZ { +typedef struct LDKCResult_InvoiceSemanticErrorZ { /** - * 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_InvoiceSemanticErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKPublicKey *data; + union LDKCResult_InvoiceSemanticErrorZPtr contents; /** - * The number of elements pointed to by `data`. + * Whether this CResult_InvoiceSemanticErrorZ represents a success state. */ - uintptr_t datalen; -} LDKCVec_PublicKeyZ; + bool result_ok; +} LDKCResult_InvoiceSemanticErrorZ; /** - * Error for PeerManager errors. If you get one of these, you must disconnect the socket and - * generate no further read_event/write_buffer_space_avail/socket_disconnected calls for the - * descriptor. + * Description string + * + * # Invariants + * The description can be at most 639 __bytes__ long */ -typedef struct MUST_USE_STRUCT LDKPeerHandleError { +typedef struct MUST_USE_STRUCT LDKDescription { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativePeerHandleError *inner; + LDKnativeDescription *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKPeerHandleError; +} LDKDescription; /** - * The contents of CResult_CVec_u8ZPeerHandleErrorZ + * The contents of CResult_DescriptionCreationErrorZ */ -typedef union LDKCResult_CVec_u8ZPeerHandleErrorZPtr { +typedef union LDKCResult_DescriptionCreationErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKCVec_u8Z *result; + struct LDKDescription *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKPeerHandleError *err; -} LDKCResult_CVec_u8ZPeerHandleErrorZPtr; + enum LDKCreationError *err; +} LDKCResult_DescriptionCreationErrorZPtr; /** - * A CResult_CVec_u8ZPeerHandleErrorZ represents the result of a fallible operation, - * containing a crate::c_types::derived::CVec_u8Z on success and a crate::lightning::ln::peer_handler::PeerHandleError on failure. + * A CResult_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_CVec_u8ZPeerHandleErrorZ { +typedef struct LDKCResult_DescriptionCreationErrorZ { /** - * The contents of this CResult_CVec_u8ZPeerHandleErrorZ, accessible via either + * The contents of this CResult_DescriptionCreationErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_CVec_u8ZPeerHandleErrorZPtr contents; + union LDKCResult_DescriptionCreationErrorZPtr contents; /** - * Whether this CResult_CVec_u8ZPeerHandleErrorZ represents a success state. + * Whether this CResult_DescriptionCreationErrorZ represents a success state. */ bool result_ok; -} LDKCResult_CVec_u8ZPeerHandleErrorZ; +} LDKCResult_DescriptionCreationErrorZ; /** - * The contents of CResult_NonePeerHandleErrorZ + * The contents of CResult_PrivateRouteCreationErrorZ */ -typedef union LDKCResult_NonePeerHandleErrorZPtr { +typedef union LDKCResult_PrivateRouteCreationErrorZPtr { /** - * 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 LDKPrivateRoute *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKPeerHandleError *err; -} LDKCResult_NonePeerHandleErrorZPtr; + enum LDKCreationError *err; +} LDKCResult_PrivateRouteCreationErrorZPtr; /** - * A CResult_NonePeerHandleErrorZ represents the result of a fallible operation, - * containing a () on success and a crate::lightning::ln::peer_handler::PeerHandleError on failure. + * A CResult_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_NonePeerHandleErrorZ { +typedef struct LDKCResult_PrivateRouteCreationErrorZ { /** - * The contents of this CResult_NonePeerHandleErrorZ, accessible via either + * The contents of this CResult_PrivateRouteCreationErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_NonePeerHandleErrorZPtr contents; + union LDKCResult_PrivateRouteCreationErrorZPtr contents; /** - * Whether this CResult_NonePeerHandleErrorZ represents a success state. + * Whether this CResult_PrivateRouteCreationErrorZ represents a success state. */ bool result_ok; -} LDKCResult_NonePeerHandleErrorZ; +} LDKCResult_PrivateRouteCreationErrorZ; /** - * The contents of CResult_boolPeerHandleErrorZ + * The contents of CResult_StringErrorZ */ -typedef union LDKCResult_boolPeerHandleErrorZPtr { +typedef union LDKCResult_StringErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - bool *result; + struct LDKStr *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKPeerHandleError *err; -} LDKCResult_boolPeerHandleErrorZPtr; + enum LDKSecp256k1Error *err; +} LDKCResult_StringErrorZPtr; /** - * A CResult_boolPeerHandleErrorZ represents the result of a fallible operation, - * containing a bool on success and a crate::lightning::ln::peer_handler::PeerHandleError on failure. + * A CResult_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_boolPeerHandleErrorZ { +typedef struct LDKCResult_StringErrorZ { /** - * The contents of this CResult_boolPeerHandleErrorZ, accessible via either + * The contents of this CResult_StringErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_boolPeerHandleErrorZPtr contents; + union LDKCResult_StringErrorZPtr contents; /** - * Whether this CResult_boolPeerHandleErrorZ represents a success state. + * Whether this CResult_StringErrorZ represents a success state. */ bool result_ok; -} LDKCResult_boolPeerHandleErrorZ; +} LDKCResult_StringErrorZ; +/** + * The contents of CResult_ChannelMonitorUpdateDecodeErrorZ + */ +typedef union LDKCResult_ChannelMonitorUpdateDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKChannelMonitorUpdate *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_ChannelMonitorUpdateDecodeErrorZPtr; +/** + * 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 contents of this CResult_ChannelMonitorUpdateDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_ChannelMonitorUpdateDecodeErrorZPtr contents; + /** + * Whether this CResult_ChannelMonitorUpdateDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_ChannelMonitorUpdateDecodeErrorZ; /** - * Represents the compressed public key of a node + * An enum which can either contain a crate::lightning::chain::channelmonitor::MonitorEvent or not */ -typedef struct MUST_USE_STRUCT LDKNodeId { +typedef enum LDKCOption_MonitorEventZ_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_MonitorEventZ contains a crate::lightning::chain::channelmonitor::MonitorEvent */ - LDKnativeNodeId *inner; + LDKCOption_MonitorEventZ_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_MonitorEventZ contains nothing */ - bool is_owned; -} LDKNodeId; + LDKCOption_MonitorEventZ_None, + /** + * Must be last for serialization purposes + */ + 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_NodeIdDecodeErrorZ + * The contents of CResult_COption_MonitorEventZDecodeErrorZ */ -typedef union LDKCResult_NodeIdDecodeErrorZPtr { +typedef union LDKCResult_COption_MonitorEventZDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKNodeId *result; + struct LDKCOption_MonitorEventZ *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_NodeIdDecodeErrorZPtr; +} LDKCResult_COption_MonitorEventZDecodeErrorZPtr; /** - * A CResult_NodeIdDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::routing::network_graph::NodeId on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_COption_MonitorEventZDecodeErrorZ represents the result of a fallible operation, + * containing a crate::c_types::derived::COption_MonitorEventZ on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_NodeIdDecodeErrorZ { +typedef struct LDKCResult_COption_MonitorEventZDecodeErrorZ { /** - * The contents of this CResult_NodeIdDecodeErrorZ, accessible via either + * The contents of this CResult_COption_MonitorEventZDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_NodeIdDecodeErrorZPtr contents; + union LDKCResult_COption_MonitorEventZDecodeErrorZPtr contents; /** - * Whether this CResult_NodeIdDecodeErrorZ represents a success state. + * Whether this CResult_COption_MonitorEventZDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_NodeIdDecodeErrorZ; +} LDKCResult_COption_MonitorEventZDecodeErrorZ; /** - * The contents of CResult_COption_NetworkUpdateZDecodeErrorZ + * The contents of CResult_HTLCUpdateDecodeErrorZ */ -typedef union LDKCResult_COption_NetworkUpdateZDecodeErrorZPtr { +typedef union LDKCResult_HTLCUpdateDecodeErrorZPtr { /** * 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; + struct LDKHTLCUpdate *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; +} LDKCResult_HTLCUpdateDecodeErrorZPtr; /** - * 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. + * 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_COption_NetworkUpdateZDecodeErrorZ { +typedef struct LDKCResult_HTLCUpdateDecodeErrorZ { /** - * The contents of this CResult_COption_NetworkUpdateZDecodeErrorZ, accessible via either + * The contents of this CResult_HTLCUpdateDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_COption_NetworkUpdateZDecodeErrorZPtr contents; + union LDKCResult_HTLCUpdateDecodeErrorZPtr contents; /** - * Whether this CResult_COption_NetworkUpdateZDecodeErrorZ represents a success state. + * Whether this CResult_HTLCUpdateDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_COption_NetworkUpdateZDecodeErrorZ; +} LDKCResult_HTLCUpdateDecodeErrorZ; /** - * The `Access` trait defines behavior for accessing chain data and state, such as blocks and - * UTXOs. + * A tuple of 2 elements. See the individual fields for the types contained. */ -typedef struct LDKAccess { - /** - * 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_OutPointScriptZ { /** - * Returns the transaction output of a funding transaction encoded by [`short_channel_id`]. - * Returns an error if `genesis_hash` is for a different chain or if such a transaction output - * is unknown. - * - * [`short_channel_id`]: https://github.com/lightningnetwork/lightning-rfc/blob/master/07-routing-gossip.md#definition-of-short_channel_id + * The element at position 0 */ - struct LDKCResult_TxOutAccessErrorZ (*get_utxo)(const void *this_arg, const uint8_t (*genesis_hash)[32], uint64_t short_channel_id); + struct LDKOutPoint a; /** - * 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 element at position 1 */ - void (*free)(void *this_arg); -} LDKAccess; + struct LDKCVec_u8Z b; +} LDKC2Tuple_OutPointScriptZ; /** - * An enum which can either contain a crate::lightning::chain::Access or not + * A tuple of 2 elements. See the individual fields for the types contained. */ -typedef enum LDKCOption_AccessZ_Tag { - /** - * When we're in this state, this COption_AccessZ contains a crate::lightning::chain::Access - */ - LDKCOption_AccessZ_Some, +typedef struct LDKC2Tuple_u32ScriptZ { /** - * When we're in this state, this COption_AccessZ contains nothing + * The element at position 0 */ - LDKCOption_AccessZ_None, + uint32_t a; /** - * Must be last for serialization purposes + * The element at position 1 */ - LDKCOption_AccessZ_Sentinel, -} LDKCOption_AccessZ_Tag; - -typedef struct LDKCOption_AccessZ { - LDKCOption_AccessZ_Tag tag; - union { - struct { - struct LDKAccess some; - }; - }; -} LDKCOption_AccessZ; - - + struct LDKCVec_u8Z b; +} LDKC2Tuple_u32ScriptZ; /** - * Details about one direction of a channel as received within a [`ChannelUpdate`]. + * A dynamically-allocated array of crate::c_types::derived::C2Tuple_u32ScriptZs of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef struct MUST_USE_STRUCT LDKChannelUpdateInfo { +typedef struct LDKCVec_C2Tuple_u32ScriptZZ { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, 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(). */ - LDKnativeChannelUpdateInfo *inner; + struct LDKC2Tuple_u32ScriptZ *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; -} LDKChannelUpdateInfo; + uintptr_t datalen; +} LDKCVec_C2Tuple_u32ScriptZZ; /** - * The contents of CResult_ChannelUpdateInfoDecodeErrorZ + * A tuple of 2 elements. See the individual fields for the types contained. */ -typedef union LDKCResult_ChannelUpdateInfoDecodeErrorZPtr { +typedef struct LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * The element at position 0 */ - struct LDKChannelUpdateInfo *result; + struct LDKThirtyTwoBytes a; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * The element at position 1 */ - struct LDKDecodeError *err; -} LDKCResult_ChannelUpdateInfoDecodeErrorZPtr; + struct LDKCVec_C2Tuple_u32ScriptZZ b; +} LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ; /** - * 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`. + * 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 LDKCResult_ChannelUpdateInfoDecodeErrorZ { +typedef struct LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ { /** - * The contents of this CResult_ChannelUpdateInfoDecodeErrorZ, 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_ChannelUpdateInfoDecodeErrorZPtr contents; + struct LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *data; /** - * Whether this CResult_ChannelUpdateInfoDecodeErrorZ represents a success state. + * The number of elements pointed to by `data`. */ - bool result_ok; -} LDKCResult_ChannelUpdateInfoDecodeErrorZ; - - + uintptr_t datalen; +} LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ; /** - * Details about a channel (both directions). - * Received within a channel announcement. + * A dynamically-allocated array of crate::lightning::util::events::Events of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef struct MUST_USE_STRUCT LDKChannelInfo { +typedef struct LDKCVec_EventZ { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, 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(). */ - LDKnativeChannelInfo *inner; + struct LDKEvent *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; -} LDKChannelInfo; + uintptr_t datalen; +} LDKCVec_EventZ; /** - * The contents of CResult_ChannelInfoDecodeErrorZ + * A dynamically-allocated array of crate::c_types::Transactions of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef union LDKCResult_ChannelInfoDecodeErrorZPtr { +typedef struct LDKCVec_TransactionZ { /** - * 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 LDKChannelInfo *result; + struct LDKTransaction *data; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * The number of elements pointed to by `data`. */ - struct LDKDecodeError *err; -} LDKCResult_ChannelInfoDecodeErrorZPtr; + uintptr_t datalen; +} LDKCVec_TransactionZ; /** - * A CResult_ChannelInfoDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::routing::network_graph::ChannelInfo on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. + * A tuple of 2 elements. See the individual fields for the types contained. */ -typedef struct LDKCResult_ChannelInfoDecodeErrorZ { +typedef struct LDKC2Tuple_u32TxOutZ { /** - * The contents of this CResult_ChannelInfoDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * The element at position 0 */ - union LDKCResult_ChannelInfoDecodeErrorZPtr contents; + uint32_t a; /** - * Whether this CResult_ChannelInfoDecodeErrorZ represents a success state. + * The element at position 1 */ - bool result_ok; -} LDKCResult_ChannelInfoDecodeErrorZ; - - + struct LDKTxOut b; +} LDKC2Tuple_u32TxOutZ; /** - * Fees for routing via a given channel or a node + * A dynamically-allocated array of crate::c_types::derived::C2Tuple_u32TxOutZs of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef struct MUST_USE_STRUCT LDKRoutingFees { +typedef struct LDKCVec_C2Tuple_u32TxOutZZ { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, 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(). */ - LDKnativeRoutingFees *inner; + struct LDKC2Tuple_u32TxOutZ *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; -} LDKRoutingFees; + uintptr_t datalen; +} LDKCVec_C2Tuple_u32TxOutZZ; /** - * The contents of CResult_RoutingFeesDecodeErrorZ + * A tuple of 2 elements. See the individual fields for the types contained. */ -typedef union LDKCResult_RoutingFeesDecodeErrorZPtr { +typedef struct LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * The element at position 0 */ - struct LDKRoutingFees *result; + struct LDKThirtyTwoBytes a; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * The element at position 1 */ - struct LDKDecodeError *err; -} LDKCResult_RoutingFeesDecodeErrorZPtr; + struct LDKCVec_C2Tuple_u32TxOutZZ b; +} LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ; /** - * A CResult_RoutingFeesDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::routing::network_graph::RoutingFees on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. + * A dynamically-allocated array of crate::c_types::derived::C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZs of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef struct LDKCResult_RoutingFeesDecodeErrorZ { +typedef struct LDKCVec_TransactionOutputsZ { /** - * The contents of this CResult_RoutingFeesDecodeErrorZ, 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_RoutingFeesDecodeErrorZPtr contents; + struct LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *data; /** - * Whether this CResult_RoutingFeesDecodeErrorZ represents a success state. + * The number of elements pointed to by `data`. */ - bool result_ok; -} LDKCResult_RoutingFeesDecodeErrorZ; - - + uintptr_t datalen; +} LDKCVec_TransactionOutputsZ; /** - * Information received in the latest node_announcement from this node. + * Details about the balance(s) available for spending once the channel appears on chain. + * + * See [`ChannelMonitor::get_claimable_balances`] for more details on when these will or will not + * be provided. */ -typedef struct MUST_USE_STRUCT LDKNodeAnnouncementInfo { +typedef enum LDKBalance_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. + * The channel is not yet closed (or the commitment or closing transaction has not yet + * appeared in a block). The given balance is claimable (less on-chain fees) if the channel is + * force-closed now. */ - LDKnativeNodeAnnouncementInfo *inner; + LDKBalance_ClaimableOnChannelClose, /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * The channel has been closed, and the given balance is ours but awaiting confirmations until + * we consider it spendable. */ - bool is_owned; -} LDKNodeAnnouncementInfo; - -/** - * The contents of CResult_NodeAnnouncementInfoDecodeErrorZ - */ -typedef union LDKCResult_NodeAnnouncementInfoDecodeErrorZPtr { + LDKBalance_ClaimableAwaitingConfirmations, /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * The channel has been closed, and the given balance should be ours but awaiting spending + * transaction confirmation. If the spending transaction does not confirm in time, it is + * possible our counterparty can take the funds by broadcasting an HTLC timeout on-chain. + * + * Once the spending transaction confirms, before it has reached enough confirmations to be + * considered safe from chain reorganizations, the balance will instead be provided via + * [`Balance::ClaimableAwaitingConfirmations`]. */ - struct LDKNodeAnnouncementInfo *result; + LDKBalance_ContentiousClaimable, /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * HTLCs which we sent to our counterparty which are claimable after a timeout (less on-chain + * fees) if the counterparty does not know the preimage for the HTLCs. These are somewhat + * likely to be claimed by our counterparty before we do. */ - struct LDKDecodeError *err; -} LDKCResult_NodeAnnouncementInfoDecodeErrorZPtr; - -/** - * A CResult_NodeAnnouncementInfoDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::routing::network_graph::NodeAnnouncementInfo 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_NodeAnnouncementInfoDecodeErrorZ { + LDKBalance_MaybeTimeoutClaimableHTLC, /** - * The contents of this CResult_NodeAnnouncementInfoDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * HTLCs which we received from our counterparty which are claimable with a preimage which we + * do not currently have. This will only be claimable if we receive the preimage from the node + * to which we forwarded this HTLC before the timeout. */ - union LDKCResult_NodeAnnouncementInfoDecodeErrorZPtr contents; + LDKBalance_MaybePreimageClaimableHTLC, /** - * Whether this CResult_NodeAnnouncementInfoDecodeErrorZ represents a success state. + * The channel has been closed, and our counterparty broadcasted a revoked commitment + * transaction. + * + * Thus, we're able to claim all outputs in the commitment transaction, one of which has the + * following amount. */ - bool result_ok; -} LDKCResult_NodeAnnouncementInfoDecodeErrorZ; - -/** - * A dynamically-allocated array of u64s of arbitrary size. - * This corresponds to std::vector in C++ - */ -typedef struct LDKCVec_u64Z { + LDKBalance_CounterpartyRevokedOutputClaimable, /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * Must be last for serialization purposes */ - uint64_t *data; + LDKBalance_Sentinel, +} LDKBalance_Tag; + +typedef struct LDKBalance_LDKClaimableOnChannelClose_Body { /** - * The number of elements pointed to by `data`. + * The amount available to claim, in satoshis, excluding the on-chain fees which will be + * required to do so. */ - uintptr_t datalen; -} LDKCVec_u64Z; - - + uint64_t claimable_amount_satoshis; +} LDKBalance_LDKClaimableOnChannelClose_Body; -/** - * Details about a node in the network, known from the network announcement. - */ -typedef struct MUST_USE_STRUCT LDKNodeInfo { +typedef struct LDKBalance_LDKClaimableAwaitingConfirmations_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 amount available to claim, in satoshis, possibly excluding the on-chain fees which + * were spent in broadcasting the transaction. */ - LDKnativeNodeInfo *inner; + uint64_t claimable_amount_satoshis; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust 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 height at which an [`Event::SpendableOutputs`] event will be generated for this + * amount. */ - bool is_owned; -} LDKNodeInfo; + uint32_t confirmation_height; +} LDKBalance_LDKClaimableAwaitingConfirmations_Body; -/** - * The contents of CResult_NodeInfoDecodeErrorZ - */ -typedef union LDKCResult_NodeInfoDecodeErrorZPtr { +typedef struct LDKBalance_LDKContentiousClaimable_Body { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * The amount available to claim, in satoshis, excluding the on-chain fees which will be + * required to do so. */ - struct LDKNodeInfo *result; + uint64_t claimable_amount_satoshis; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * The height at which the counterparty may be able to claim the balance if we have not + * done so. */ - struct LDKDecodeError *err; -} LDKCResult_NodeInfoDecodeErrorZPtr; + uint32_t timeout_height; +} LDKBalance_LDKContentiousClaimable_Body; -/** - * A CResult_NodeInfoDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::routing::network_graph::NodeInfo 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_NodeInfoDecodeErrorZ { +typedef struct LDKBalance_LDKMaybeTimeoutClaimableHTLC_Body { /** - * The contents of this CResult_NodeInfoDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * The amount potentially available to claim, in satoshis, excluding the on-chain fees + * which will be required to do so. */ - union LDKCResult_NodeInfoDecodeErrorZPtr contents; + uint64_t claimable_amount_satoshis; /** - * Whether this CResult_NodeInfoDecodeErrorZ represents a success state. + * The height at which we will be able to claim the balance if our counterparty has not + * done so. */ - bool result_ok; -} LDKCResult_NodeInfoDecodeErrorZ; + uint32_t claimable_height; +} LDKBalance_LDKMaybeTimeoutClaimableHTLC_Body; -/** - * The contents of CResult_NetworkGraphDecodeErrorZ - */ -typedef union LDKCResult_NetworkGraphDecodeErrorZPtr { +typedef struct LDKBalance_LDKMaybePreimageClaimableHTLC_Body { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * The amount potentially available to claim, in satoshis, excluding the on-chain fees + * which will be required to do so. */ - struct LDKNetworkGraph *result; + uint64_t claimable_amount_satoshis; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * The height at which our counterparty will be able to claim the balance if we have not + * yet received the preimage and claimed it ourselves. */ - struct LDKDecodeError *err; -} LDKCResult_NetworkGraphDecodeErrorZPtr; + uint32_t expiry_height; +} LDKBalance_LDKMaybePreimageClaimableHTLC_Body; -/** - * A CResult_NetworkGraphDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::routing::network_graph::NetworkGraph 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_NetworkGraphDecodeErrorZ { +typedef struct LDKBalance_LDKCounterpartyRevokedOutputClaimable_Body { /** - * The contents of this CResult_NetworkGraphDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. - */ - union LDKCResult_NetworkGraphDecodeErrorZPtr contents; - /** - * Whether this CResult_NetworkGraphDecodeErrorZ represents a success state. + * The amount, in satoshis, of the output which we can claim. + * + * Note that for outputs from HTLC balances this may be excluding some on-chain fees that + * were already spent. */ - bool result_ok; -} LDKCResult_NetworkGraphDecodeErrorZ; + uint64_t claimable_amount_satoshis; +} LDKBalance_LDKCounterpartyRevokedOutputClaimable_Body; + +typedef struct MUST_USE_STRUCT LDKBalance { + LDKBalance_Tag tag; + union { + LDKBalance_LDKClaimableOnChannelClose_Body claimable_on_channel_close; + LDKBalance_LDKClaimableAwaitingConfirmations_Body claimable_awaiting_confirmations; + LDKBalance_LDKContentiousClaimable_Body contentious_claimable; + LDKBalance_LDKMaybeTimeoutClaimableHTLC_Body maybe_timeout_claimable_htlc; + LDKBalance_LDKMaybePreimageClaimableHTLC_Body maybe_preimage_claimable_htlc; + LDKBalance_LDKCounterpartyRevokedOutputClaimable_Body counterparty_revoked_output_claimable; + }; +} LDKBalance; /** - * An enum which can either contain a crate::c_types::derived::CVec_NetAddressZ or not + * A dynamically-allocated array of crate::lightning::chain::channelmonitor::Balances of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef enum LDKCOption_CVec_NetAddressZZ_Tag { - /** - * When we're in this state, this COption_CVec_NetAddressZZ contains a crate::c_types::derived::CVec_NetAddressZ - */ - LDKCOption_CVec_NetAddressZZ_Some, +typedef struct LDKCVec_BalanceZ { /** - * When we're in this state, this COption_CVec_NetAddressZZ contains nothing + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - LDKCOption_CVec_NetAddressZZ_None, + struct LDKBalance *data; /** - * Must be last for serialization purposes + * The number of elements pointed to by `data`. */ - LDKCOption_CVec_NetAddressZZ_Sentinel, -} LDKCOption_CVec_NetAddressZZ_Tag; - -typedef struct LDKCOption_CVec_NetAddressZZ { - LDKCOption_CVec_NetAddressZZ_Tag tag; - union { - struct { - struct LDKCVec_NetAddressZ some; - }; - }; -} LDKCOption_CVec_NetAddressZZ; + uintptr_t datalen; +} LDKCVec_BalanceZ; /** - * The contents of CResult_NetAddressDecodeErrorZ + * The contents of CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ */ -typedef union LDKCResult_NetAddressDecodeErrorZPtr { +typedef union LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKNetAddress *result; + struct LDKC2Tuple_BlockHashChannelMonitorZ *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_NetAddressDecodeErrorZPtr; +} LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZPtr; /** - * A CResult_NetAddressDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::NetAddress on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ represents the result of a fallible operation, + * containing a crate::c_types::derived::C2Tuple_BlockHashChannelMonitorZ on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_NetAddressDecodeErrorZ { +typedef struct LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ { /** - * The contents of this CResult_NetAddressDecodeErrorZ, accessible via either + * The contents of this CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_NetAddressDecodeErrorZPtr contents; + union LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZPtr contents; /** - * Whether this CResult_NetAddressDecodeErrorZ represents a success state. + * Whether this CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_NetAddressDecodeErrorZ; - - +} LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ; /** - * An update_add_htlc message to be sent or received from a peer + * A tuple of 2 elements. See the individual fields for the types contained. */ -typedef struct MUST_USE_STRUCT LDKUpdateAddHTLC { +typedef struct LDKC2Tuple_PublicKeyTypeZ { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The element at position 0 */ - LDKnativeUpdateAddHTLC *inner; + struct LDKPublicKey a; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * The element at position 1 */ - bool is_owned; -} LDKUpdateAddHTLC; + struct LDKType b; +} LDKC2Tuple_PublicKeyTypeZ; /** - * A dynamically-allocated array of crate::lightning::ln::msgs::UpdateAddHTLCs of arbitrary size. + * A dynamically-allocated array of crate::c_types::derived::C2Tuple_PublicKeyTypeZs of arbitrary size. * This corresponds to std::vector in C++ */ -typedef struct LDKCVec_UpdateAddHTLCZ { +typedef struct LDKCVec_C2Tuple_PublicKeyTypeZZ { /** * The elements in the array. * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - struct LDKUpdateAddHTLC *data; + struct LDKC2Tuple_PublicKeyTypeZ *data; /** * The number of elements pointed to by `data`. */ uintptr_t datalen; -} LDKCVec_UpdateAddHTLCZ; - - +} LDKCVec_C2Tuple_PublicKeyTypeZZ; /** - * An update_fulfill_htlc message to be sent or received from a peer + * The contents of a custom onion message. */ -typedef struct MUST_USE_STRUCT LDKUpdateFulfillHTLC { +typedef struct LDKCustomOnionMessageContents { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, 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. */ - LDKnativeUpdateFulfillHTLC *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. + * Returns the TLV type identifying the message contents. MUST be >= 64. */ - bool is_owned; -} LDKUpdateFulfillHTLC; + uint64_t (*tlv_type)(const void *this_arg); + /** + * Serialize the object into a byte array + */ + struct LDKCVec_u8Z (*write)(const void *this_arg); + /** + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + */ + void (*free)(void *this_arg); +} LDKCustomOnionMessageContents; /** - * A dynamically-allocated array of crate::lightning::ln::msgs::UpdateFulfillHTLCs of arbitrary size. - * This corresponds to std::vector in C++ + * An enum which can either contain a crate::lightning::onion_message::packet::CustomOnionMessageContents or not */ -typedef struct LDKCVec_UpdateFulfillHTLCZ { +typedef enum LDKCOption_CustomOnionMessageContentsZ_Tag { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * When we're in this state, this COption_CustomOnionMessageContentsZ contains a crate::lightning::onion_message::packet::CustomOnionMessageContents */ - struct LDKUpdateFulfillHTLC *data; + LDKCOption_CustomOnionMessageContentsZ_Some, /** - * The number of elements pointed to by `data`. + * When we're in this state, this COption_CustomOnionMessageContentsZ contains nothing */ - uintptr_t datalen; -} LDKCVec_UpdateFulfillHTLCZ; + LDKCOption_CustomOnionMessageContentsZ_None, + /** + * Must be last for serialization purposes + */ + LDKCOption_CustomOnionMessageContentsZ_Sentinel, +} LDKCOption_CustomOnionMessageContentsZ_Tag; +typedef struct LDKCOption_CustomOnionMessageContentsZ { + LDKCOption_CustomOnionMessageContentsZ_Tag tag; + union { + struct { + struct LDKCustomOnionMessageContents some; + }; + }; +} LDKCOption_CustomOnionMessageContentsZ; +/** + * The contents of CResult_COption_CustomOnionMessageContentsZDecodeErrorZ + */ +typedef union LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKCOption_CustomOnionMessageContentsZ *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_CustomOnionMessageContentsZDecodeErrorZPtr; /** - * An update_fail_htlc message to be sent or received from a peer + * A CResult_COption_CustomOnionMessageContentsZDecodeErrorZ represents the result of a fallible operation, + * containing a crate::c_types::derived::COption_CustomOnionMessageContentsZ on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct MUST_USE_STRUCT LDKUpdateFailHTLC { +typedef struct LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The contents of this CResult_COption_CustomOnionMessageContentsZDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - LDKnativeUpdateFailHTLC *inner; + union LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZPtr contents; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * Whether this CResult_COption_CustomOnionMessageContentsZDecodeErrorZ represents a success state. */ - bool is_owned; -} LDKUpdateFailHTLC; + bool result_ok; +} LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ; /** - * A dynamically-allocated array of crate::lightning::ln::msgs::UpdateFailHTLCs of arbitrary size. - * This corresponds to std::vector in C++ + * An enum which can either contain a crate::lightning::ln::msgs::NetAddress or not */ -typedef struct LDKCVec_UpdateFailHTLCZ { +typedef enum LDKCOption_NetAddressZ_Tag { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * When we're in this state, this COption_NetAddressZ contains a crate::lightning::ln::msgs::NetAddress */ - struct LDKUpdateFailHTLC *data; + LDKCOption_NetAddressZ_Some, /** - * The number of elements pointed to by `data`. + * When we're in this state, this COption_NetAddressZ contains nothing */ - uintptr_t datalen; -} LDKCVec_UpdateFailHTLCZ; + 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; /** - * An update_fail_malformed_htlc message to be sent or received from a peer + * Error for PeerManager errors. If you get one of these, you must disconnect the socket and + * generate no further read_event/write_buffer_space_avail/socket_disconnected calls for the + * descriptor. */ -typedef struct MUST_USE_STRUCT LDKUpdateFailMalformedHTLC { +typedef struct MUST_USE_STRUCT LDKPeerHandleError { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeUpdateFailMalformedHTLC *inner; + LDKnativePeerHandleError *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKUpdateFailMalformedHTLC; +} LDKPeerHandleError; /** - * A dynamically-allocated array of crate::lightning::ln::msgs::UpdateFailMalformedHTLCs of arbitrary size. - * This corresponds to std::vector in C++ + * The contents of CResult_CVec_u8ZPeerHandleErrorZ */ -typedef struct LDKCVec_UpdateFailMalformedHTLCZ { +typedef union LDKCResult_CVec_u8ZPeerHandleErrorZPtr { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKUpdateFailMalformedHTLC *data; + struct LDKCVec_u8Z *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_UpdateFailMalformedHTLCZ; - -/** - * The contents of CResult_AcceptChannelDecodeErrorZ - */ -typedef union LDKCResult_AcceptChannelDecodeErrorZPtr { - /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. - */ - struct LDKAcceptChannel *result; - /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. - */ - struct LDKDecodeError *err; -} LDKCResult_AcceptChannelDecodeErrorZPtr; + struct LDKPeerHandleError *err; +} LDKCResult_CVec_u8ZPeerHandleErrorZPtr; /** - * A CResult_AcceptChannelDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::AcceptChannel on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_CVec_u8ZPeerHandleErrorZ represents the result of a fallible operation, + * containing a crate::c_types::derived::CVec_u8Z on success and a crate::lightning::ln::peer_handler::PeerHandleError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_AcceptChannelDecodeErrorZ { +typedef struct LDKCResult_CVec_u8ZPeerHandleErrorZ { /** - * The contents of this CResult_AcceptChannelDecodeErrorZ, accessible via either + * The contents of this CResult_CVec_u8ZPeerHandleErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_AcceptChannelDecodeErrorZPtr contents; + union LDKCResult_CVec_u8ZPeerHandleErrorZPtr contents; /** - * Whether this CResult_AcceptChannelDecodeErrorZ represents a success state. + * Whether this CResult_CVec_u8ZPeerHandleErrorZ represents a success state. */ bool result_ok; -} LDKCResult_AcceptChannelDecodeErrorZ; +} LDKCResult_CVec_u8ZPeerHandleErrorZ; /** - * The contents of CResult_AnnouncementSignaturesDecodeErrorZ + * The contents of CResult_NonePeerHandleErrorZ */ -typedef union LDKCResult_AnnouncementSignaturesDecodeErrorZPtr { +typedef union LDKCResult_NonePeerHandleErrorZPtr { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * Note that this value is always NULL, as there are no contents in the OK variant */ - struct LDKAnnouncementSignatures *result; + void *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKDecodeError *err; -} LDKCResult_AnnouncementSignaturesDecodeErrorZPtr; + struct LDKPeerHandleError *err; +} LDKCResult_NonePeerHandleErrorZPtr; /** - * A CResult_AnnouncementSignaturesDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::AnnouncementSignatures on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_NonePeerHandleErrorZ represents the result of a fallible operation, + * containing a () on success and a crate::lightning::ln::peer_handler::PeerHandleError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_AnnouncementSignaturesDecodeErrorZ { +typedef struct LDKCResult_NonePeerHandleErrorZ { /** - * The contents of this CResult_AnnouncementSignaturesDecodeErrorZ, accessible via either + * The contents of this CResult_NonePeerHandleErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_AnnouncementSignaturesDecodeErrorZPtr contents; + union LDKCResult_NonePeerHandleErrorZPtr contents; /** - * Whether this CResult_AnnouncementSignaturesDecodeErrorZ represents a success state. + * Whether this CResult_NonePeerHandleErrorZ represents a success state. */ bool result_ok; -} LDKCResult_AnnouncementSignaturesDecodeErrorZ; +} LDKCResult_NonePeerHandleErrorZ; /** - * The contents of CResult_ChannelReestablishDecodeErrorZ + * The contents of CResult_boolPeerHandleErrorZ */ -typedef union LDKCResult_ChannelReestablishDecodeErrorZPtr { +typedef union LDKCResult_boolPeerHandleErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKChannelReestablish *result; + bool *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKDecodeError *err; -} LDKCResult_ChannelReestablishDecodeErrorZPtr; + struct LDKPeerHandleError *err; +} LDKCResult_boolPeerHandleErrorZPtr; /** - * A CResult_ChannelReestablishDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::ChannelReestablish on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_boolPeerHandleErrorZ represents the result of a fallible operation, + * containing a bool on success and a crate::lightning::ln::peer_handler::PeerHandleError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_ChannelReestablishDecodeErrorZ { +typedef struct LDKCResult_boolPeerHandleErrorZ { /** - * The contents of this CResult_ChannelReestablishDecodeErrorZ, accessible via either + * The contents of this CResult_boolPeerHandleErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_ChannelReestablishDecodeErrorZPtr contents; + union LDKCResult_boolPeerHandleErrorZPtr contents; /** - * Whether this CResult_ChannelReestablishDecodeErrorZ represents a success state. + * Whether this CResult_boolPeerHandleErrorZ represents a success state. */ bool result_ok; -} LDKCResult_ChannelReestablishDecodeErrorZ; - -/** - * The contents of CResult_ClosingSignedDecodeErrorZ - */ -typedef union LDKCResult_ClosingSignedDecodeErrorZPtr { - /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. - */ - struct LDKClosingSigned *result; - /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. - */ - struct LDKDecodeError *err; -} LDKCResult_ClosingSignedDecodeErrorZPtr; +} LDKCResult_boolPeerHandleErrorZ; /** - * A CResult_ClosingSignedDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::ClosingSigned on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. + * Errors that may occur when [sending an onion message]. + * + * [sending an onion message]: OnionMessenger::send_custom_onion_message */ -typedef struct LDKCResult_ClosingSignedDecodeErrorZ { - /** - * The contents of this CResult_ClosingSignedDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. - */ - union LDKCResult_ClosingSignedDecodeErrorZPtr contents; +typedef enum LDKSendError_Tag { /** - * Whether this CResult_ClosingSignedDecodeErrorZ represents a success state. + * Errored computing onion message packet keys. */ - bool result_ok; -} LDKCResult_ClosingSignedDecodeErrorZ; - - - -/** - * The minimum and maximum fees which the sender is willing to place on the closing transaction. - * This is provided in [`ClosingSigned`] by both sides to indicate the fee range they are willing - * to use. - */ -typedef struct MUST_USE_STRUCT LDKClosingSignedFeeRange { + LDKSendError_Secp256k1, /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * Because implementations such as Eclair will drop onion messages where the message packet + * exceeds 32834 bytes, we refuse to send messages where the packet exceeds this size. */ - LDKnativeClosingSignedFeeRange *inner; + LDKSendError_TooBigPacket, /** - * Indicates that this is the only struct which contains the same pointer. - * Rust 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 provided [`Destination`] was an invalid [`BlindedRoute`], due to having fewer than two + * blinded hops. */ - bool is_owned; -} LDKClosingSignedFeeRange; - -/** - * The contents of CResult_ClosingSignedFeeRangeDecodeErrorZ - */ -typedef union LDKCResult_ClosingSignedFeeRangeDecodeErrorZPtr { + LDKSendError_TooFewBlindedHops, /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * Our next-hop peer was offline or does not support onion message forwarding. */ - struct LDKClosingSignedFeeRange *result; + LDKSendError_InvalidFirstHop, /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * Onion message contents must have a TLV type >= 64. */ - struct LDKDecodeError *err; -} LDKCResult_ClosingSignedFeeRangeDecodeErrorZPtr; - -/** - * A CResult_ClosingSignedFeeRangeDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::ClosingSignedFeeRange on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_ClosingSignedFeeRangeDecodeErrorZ { + LDKSendError_InvalidMessage, /** - * The contents of this CResult_ClosingSignedFeeRangeDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * Our next-hop peer's buffer was full or our total outbound buffer was full. */ - union LDKCResult_ClosingSignedFeeRangeDecodeErrorZPtr contents; + LDKSendError_BufferFull, /** - * Whether this CResult_ClosingSignedFeeRangeDecodeErrorZ represents a success state. + * Must be last for serialization purposes */ - bool result_ok; -} LDKCResult_ClosingSignedFeeRangeDecodeErrorZ; - + LDKSendError_Sentinel, +} LDKSendError_Tag; +typedef struct MUST_USE_STRUCT LDKSendError { + LDKSendError_Tag tag; + union { + struct { + enum LDKSecp256k1Error secp256k1; + }; + }; +} LDKSendError; /** - * A commitment_signed message to be sent or received from a peer - */ -typedef struct MUST_USE_STRUCT LDKCommitmentSigned { - /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. - */ - LDKnativeCommitmentSigned *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; -} LDKCommitmentSigned; - -/** - * The contents of CResult_CommitmentSignedDecodeErrorZ + * The contents of CResult_NoneSendErrorZ */ -typedef union LDKCResult_CommitmentSignedDecodeErrorZPtr { +typedef union LDKCResult_NoneSendErrorZPtr { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * Note that this value is always NULL, as there are no contents in the OK variant */ - struct LDKCommitmentSigned *result; + void *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_CommitmentSignedDecodeErrorZPtr; + struct LDKSendError *err; +} LDKCResult_NoneSendErrorZPtr; /** - * A CResult_CommitmentSignedDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::CommitmentSigned on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_NoneSendErrorZ represents the result of a fallible operation, + * containing a () on success and a crate::lightning::onion_message::messenger::SendError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_CommitmentSignedDecodeErrorZ { +typedef struct LDKCResult_NoneSendErrorZ { /** - * The contents of this CResult_CommitmentSignedDecodeErrorZ, accessible via either + * The contents of this CResult_NoneSendErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_CommitmentSignedDecodeErrorZPtr contents; + union LDKCResult_NoneSendErrorZPtr contents; /** - * Whether this CResult_CommitmentSignedDecodeErrorZ represents a success state. + * Whether this CResult_NoneSendErrorZ represents a success state. */ bool result_ok; -} LDKCResult_CommitmentSignedDecodeErrorZ; +} LDKCResult_NoneSendErrorZ; /** - * The contents of CResult_FundingCreatedDecodeErrorZ + * All-encompassing standard error type that processing can return */ -typedef union LDKCResult_FundingCreatedDecodeErrorZPtr { - /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. - */ - struct LDKFundingCreated *result; +typedef enum LDKGraphSyncError_Tag { /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * Error trying to read the update data, typically due to an erroneous data length indication + * that is greater than the actual amount of data provided */ - struct LDKDecodeError *err; -} LDKCResult_FundingCreatedDecodeErrorZPtr; - -/** - * A CResult_FundingCreatedDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::FundingCreated on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_FundingCreatedDecodeErrorZ { + LDKGraphSyncError_DecodeError, /** - * The contents of this CResult_FundingCreatedDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * Error applying the patch to the network graph, usually the result of updates that are too + * old or missing prerequisite data to the application of updates out of order */ - union LDKCResult_FundingCreatedDecodeErrorZPtr contents; + LDKGraphSyncError_LightningError, /** - * Whether this CResult_FundingCreatedDecodeErrorZ represents a success state. + * Must be last for serialization purposes */ - bool result_ok; -} LDKCResult_FundingCreatedDecodeErrorZ; + LDKGraphSyncError_Sentinel, +} LDKGraphSyncError_Tag; + +typedef struct MUST_USE_STRUCT LDKGraphSyncError { + LDKGraphSyncError_Tag tag; + union { + struct { + struct LDKDecodeError decode_error; + }; + struct { + struct LDKLightningError lightning_error; + }; + }; +} LDKGraphSyncError; /** - * The contents of CResult_FundingSignedDecodeErrorZ + * The contents of CResult_u32GraphSyncErrorZ */ -typedef union LDKCResult_FundingSignedDecodeErrorZPtr { +typedef union LDKCResult_u32GraphSyncErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKFundingSigned *result; + uint32_t *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKDecodeError *err; -} LDKCResult_FundingSignedDecodeErrorZPtr; + struct LDKGraphSyncError *err; +} LDKCResult_u32GraphSyncErrorZPtr; /** - * A CResult_FundingSignedDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::FundingSigned on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_u32GraphSyncErrorZ represents the result of a fallible operation, + * containing a u32 on success and a crate::lightning_rapid_gossip_sync::error::GraphSyncError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_FundingSignedDecodeErrorZ { +typedef struct LDKCResult_u32GraphSyncErrorZ { /** - * The contents of this CResult_FundingSignedDecodeErrorZ, accessible via either + * The contents of this CResult_u32GraphSyncErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_FundingSignedDecodeErrorZPtr contents; + union LDKCResult_u32GraphSyncErrorZPtr contents; /** - * Whether this CResult_FundingSignedDecodeErrorZ represents a success state. + * Whether this CResult_u32GraphSyncErrorZ represents a success state. */ bool result_ok; -} LDKCResult_FundingSignedDecodeErrorZ; +} LDKCResult_u32GraphSyncErrorZ; /** - * The contents of CResult_FundingLockedDecodeErrorZ + * The contents of CResult_NetAddressDecodeErrorZ */ -typedef union LDKCResult_FundingLockedDecodeErrorZPtr { +typedef union LDKCResult_NetAddressDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKFundingLocked *result; + struct LDKNetAddress *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_FundingLockedDecodeErrorZPtr; +} LDKCResult_NetAddressDecodeErrorZPtr; /** - * A CResult_FundingLockedDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::FundingLocked on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_NetAddressDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::NetAddress on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_FundingLockedDecodeErrorZ { +typedef struct LDKCResult_NetAddressDecodeErrorZ { /** - * The contents of this CResult_FundingLockedDecodeErrorZ, accessible via either + * The contents of this CResult_NetAddressDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_FundingLockedDecodeErrorZPtr contents; + union LDKCResult_NetAddressDecodeErrorZPtr contents; /** - * Whether this CResult_FundingLockedDecodeErrorZ represents a success state. + * Whether this CResult_NetAddressDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_FundingLockedDecodeErrorZ; +} LDKCResult_NetAddressDecodeErrorZ; /** - * An init message to be sent or received from a peer + * An update_add_htlc message to be sent or received from a peer */ -typedef struct MUST_USE_STRUCT LDKInit { +typedef struct MUST_USE_STRUCT LDKUpdateAddHTLC { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeInit *inner; + LDKnativeUpdateAddHTLC *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKInit; +} LDKUpdateAddHTLC; /** - * The contents of CResult_InitDecodeErrorZ + * A dynamically-allocated array of crate::lightning::ln::msgs::UpdateAddHTLCs of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef union LDKCResult_InitDecodeErrorZPtr { +typedef struct LDKCVec_UpdateAddHTLCZ { /** - * 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 LDKInit *result; + struct LDKUpdateAddHTLC *data; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * The number of elements pointed to by `data`. */ - struct LDKDecodeError *err; -} LDKCResult_InitDecodeErrorZPtr; + uintptr_t datalen; +} LDKCVec_UpdateAddHTLCZ; + + /** - * A CResult_InitDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::Init on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. + * An update_fulfill_htlc message to be sent or received from a peer */ -typedef struct LDKCResult_InitDecodeErrorZ { +typedef struct MUST_USE_STRUCT LDKUpdateFulfillHTLC { /** - * The contents of this CResult_InitDecodeErrorZ, 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_InitDecodeErrorZPtr contents; + LDKnativeUpdateFulfillHTLC *inner; /** - * Whether this CResult_InitDecodeErrorZ 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_InitDecodeErrorZ; + bool is_owned; +} LDKUpdateFulfillHTLC; /** - * The contents of CResult_OpenChannelDecodeErrorZ + * A dynamically-allocated array of crate::lightning::ln::msgs::UpdateFulfillHTLCs of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef union LDKCResult_OpenChannelDecodeErrorZPtr { +typedef struct LDKCVec_UpdateFulfillHTLCZ { /** - * 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 LDKOpenChannel *result; + struct LDKUpdateFulfillHTLC *data; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * The number of elements pointed to by `data`. */ - struct LDKDecodeError *err; -} LDKCResult_OpenChannelDecodeErrorZPtr; + uintptr_t datalen; +} LDKCVec_UpdateFulfillHTLCZ; + + /** - * A CResult_OpenChannelDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::OpenChannel on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. + * An update_fail_htlc message to be sent or received from a peer */ -typedef struct LDKCResult_OpenChannelDecodeErrorZ { +typedef struct MUST_USE_STRUCT LDKUpdateFailHTLC { /** - * The contents of this CResult_OpenChannelDecodeErrorZ, 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_OpenChannelDecodeErrorZPtr contents; + LDKnativeUpdateFailHTLC *inner; /** - * Whether this CResult_OpenChannelDecodeErrorZ 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_OpenChannelDecodeErrorZ; + bool is_owned; +} LDKUpdateFailHTLC; /** - * The contents of CResult_RevokeAndACKDecodeErrorZ + * A dynamically-allocated array of crate::lightning::ln::msgs::UpdateFailHTLCs of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef union LDKCResult_RevokeAndACKDecodeErrorZPtr { +typedef struct LDKCVec_UpdateFailHTLCZ { + /** + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + */ + struct LDKUpdateFailHTLC *data; + /** + * The number of elements pointed to by `data`. + */ + uintptr_t datalen; +} LDKCVec_UpdateFailHTLCZ; + + + +/** + * An update_fail_malformed_htlc message to be sent or received from a peer + */ +typedef struct MUST_USE_STRUCT LDKUpdateFailMalformedHTLC { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeUpdateFailMalformedHTLC *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKUpdateFailMalformedHTLC; + +/** + * A dynamically-allocated array of crate::lightning::ln::msgs::UpdateFailMalformedHTLCs of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_UpdateFailMalformedHTLCZ { + /** + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + */ + struct LDKUpdateFailMalformedHTLC *data; + /** + * The number of elements pointed to by `data`. + */ + uintptr_t datalen; +} LDKCVec_UpdateFailMalformedHTLCZ; + +/** + * The contents of CResult_AcceptChannelDecodeErrorZ + */ +typedef union LDKCResult_AcceptChannelDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKRevokeAndACK *result; + struct LDKAcceptChannel *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_RevokeAndACKDecodeErrorZPtr; +} LDKCResult_AcceptChannelDecodeErrorZPtr; /** - * A CResult_RevokeAndACKDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::RevokeAndACK on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_AcceptChannelDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::AcceptChannel on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_RevokeAndACKDecodeErrorZ { +typedef struct LDKCResult_AcceptChannelDecodeErrorZ { /** - * The contents of this CResult_RevokeAndACKDecodeErrorZ, accessible via either + * The contents of this CResult_AcceptChannelDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_RevokeAndACKDecodeErrorZPtr contents; + union LDKCResult_AcceptChannelDecodeErrorZPtr contents; /** - * Whether this CResult_RevokeAndACKDecodeErrorZ represents a success state. + * Whether this CResult_AcceptChannelDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_RevokeAndACKDecodeErrorZ; +} LDKCResult_AcceptChannelDecodeErrorZ; /** - * The contents of CResult_ShutdownDecodeErrorZ + * The contents of CResult_AnnouncementSignaturesDecodeErrorZ */ -typedef union LDKCResult_ShutdownDecodeErrorZPtr { +typedef union LDKCResult_AnnouncementSignaturesDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKShutdown *result; + struct LDKAnnouncementSignatures *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_ShutdownDecodeErrorZPtr; +} LDKCResult_AnnouncementSignaturesDecodeErrorZPtr; /** - * A CResult_ShutdownDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::Shutdown on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_AnnouncementSignaturesDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::AnnouncementSignatures on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_ShutdownDecodeErrorZ { +typedef struct LDKCResult_AnnouncementSignaturesDecodeErrorZ { /** - * The contents of this CResult_ShutdownDecodeErrorZ, accessible via either + * The contents of this CResult_AnnouncementSignaturesDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_ShutdownDecodeErrorZPtr contents; + union LDKCResult_AnnouncementSignaturesDecodeErrorZPtr contents; /** - * Whether this CResult_ShutdownDecodeErrorZ represents a success state. + * Whether this CResult_AnnouncementSignaturesDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_ShutdownDecodeErrorZ; +} LDKCResult_AnnouncementSignaturesDecodeErrorZ; /** - * The contents of CResult_UpdateFailHTLCDecodeErrorZ + * The contents of CResult_ChannelReestablishDecodeErrorZ */ -typedef union LDKCResult_UpdateFailHTLCDecodeErrorZPtr { +typedef union LDKCResult_ChannelReestablishDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKUpdateFailHTLC *result; + struct LDKChannelReestablish *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_UpdateFailHTLCDecodeErrorZPtr; +} LDKCResult_ChannelReestablishDecodeErrorZPtr; /** - * A CResult_UpdateFailHTLCDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::UpdateFailHTLC on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_ChannelReestablishDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::ChannelReestablish on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_UpdateFailHTLCDecodeErrorZ { +typedef struct LDKCResult_ChannelReestablishDecodeErrorZ { /** - * The contents of this CResult_UpdateFailHTLCDecodeErrorZ, accessible via either + * The contents of this CResult_ChannelReestablishDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_UpdateFailHTLCDecodeErrorZPtr contents; + union LDKCResult_ChannelReestablishDecodeErrorZPtr contents; /** - * Whether this CResult_UpdateFailHTLCDecodeErrorZ represents a success state. + * Whether this CResult_ChannelReestablishDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_UpdateFailHTLCDecodeErrorZ; +} LDKCResult_ChannelReestablishDecodeErrorZ; /** - * The contents of CResult_UpdateFailMalformedHTLCDecodeErrorZ + * The contents of CResult_ClosingSignedDecodeErrorZ */ -typedef union LDKCResult_UpdateFailMalformedHTLCDecodeErrorZPtr { +typedef union LDKCResult_ClosingSignedDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKUpdateFailMalformedHTLC *result; + struct LDKClosingSigned *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_UpdateFailMalformedHTLCDecodeErrorZPtr; +} LDKCResult_ClosingSignedDecodeErrorZPtr; /** - * A CResult_UpdateFailMalformedHTLCDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::UpdateFailMalformedHTLC on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_ClosingSignedDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::ClosingSigned on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ { +typedef struct LDKCResult_ClosingSignedDecodeErrorZ { /** - * The contents of this CResult_UpdateFailMalformedHTLCDecodeErrorZ, accessible via either + * The contents of this CResult_ClosingSignedDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_UpdateFailMalformedHTLCDecodeErrorZPtr contents; + union LDKCResult_ClosingSignedDecodeErrorZPtr contents; /** - * Whether this CResult_UpdateFailMalformedHTLCDecodeErrorZ represents a success state. + * Whether this CResult_ClosingSignedDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ; +} LDKCResult_ClosingSignedDecodeErrorZ; /** - * An update_fee message to be sent or received from a peer + * The minimum and maximum fees which the sender is willing to place on the closing transaction. + * This is provided in [`ClosingSigned`] by both sides to indicate the fee range they are willing + * to use. */ -typedef struct MUST_USE_STRUCT LDKUpdateFee { +typedef struct MUST_USE_STRUCT LDKClosingSignedFeeRange { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeUpdateFee *inner; + LDKnativeClosingSignedFeeRange *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; -} LDKUpdateFee; +} LDKClosingSignedFeeRange; /** - * The contents of CResult_UpdateFeeDecodeErrorZ + * The contents of CResult_ClosingSignedFeeRangeDecodeErrorZ */ -typedef union LDKCResult_UpdateFeeDecodeErrorZPtr { +typedef union LDKCResult_ClosingSignedFeeRangeDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKUpdateFee *result; + struct LDKClosingSignedFeeRange *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_UpdateFeeDecodeErrorZPtr; +} LDKCResult_ClosingSignedFeeRangeDecodeErrorZPtr; /** - * A CResult_UpdateFeeDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::UpdateFee on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_ClosingSignedFeeRangeDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::ClosingSignedFeeRange on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_UpdateFeeDecodeErrorZ { +typedef struct LDKCResult_ClosingSignedFeeRangeDecodeErrorZ { /** - * The contents of this CResult_UpdateFeeDecodeErrorZ, accessible via either + * The contents of this CResult_ClosingSignedFeeRangeDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_UpdateFeeDecodeErrorZPtr contents; + union LDKCResult_ClosingSignedFeeRangeDecodeErrorZPtr contents; /** - * Whether this CResult_UpdateFeeDecodeErrorZ represents a success state. + * Whether this CResult_ClosingSignedFeeRangeDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_UpdateFeeDecodeErrorZ; +} LDKCResult_ClosingSignedFeeRangeDecodeErrorZ; -/** - * The contents of CResult_UpdateFulfillHTLCDecodeErrorZ + + +/** + * A commitment_signed message to be sent or received from a peer */ -typedef union LDKCResult_UpdateFulfillHTLCDecodeErrorZPtr { +typedef struct MUST_USE_STRUCT LDKCommitmentSigned { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeCommitmentSigned *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; +} LDKCommitmentSigned; + +/** + * The contents of CResult_CommitmentSignedDecodeErrorZ + */ +typedef union LDKCResult_CommitmentSignedDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKUpdateFulfillHTLC *result; + struct LDKCommitmentSigned *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_UpdateFulfillHTLCDecodeErrorZPtr; +} LDKCResult_CommitmentSignedDecodeErrorZPtr; /** - * A CResult_UpdateFulfillHTLCDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::UpdateFulfillHTLC on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_CommitmentSignedDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::CommitmentSigned on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_UpdateFulfillHTLCDecodeErrorZ { +typedef struct LDKCResult_CommitmentSignedDecodeErrorZ { /** - * The contents of this CResult_UpdateFulfillHTLCDecodeErrorZ, accessible via either + * The contents of this CResult_CommitmentSignedDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_UpdateFulfillHTLCDecodeErrorZPtr contents; + union LDKCResult_CommitmentSignedDecodeErrorZPtr contents; /** - * Whether this CResult_UpdateFulfillHTLCDecodeErrorZ represents a success state. + * Whether this CResult_CommitmentSignedDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_UpdateFulfillHTLCDecodeErrorZ; +} LDKCResult_CommitmentSignedDecodeErrorZ; /** - * The contents of CResult_UpdateAddHTLCDecodeErrorZ + * The contents of CResult_FundingCreatedDecodeErrorZ */ -typedef union LDKCResult_UpdateAddHTLCDecodeErrorZPtr { +typedef union LDKCResult_FundingCreatedDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKUpdateAddHTLC *result; + struct LDKFundingCreated *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_UpdateAddHTLCDecodeErrorZPtr; +} LDKCResult_FundingCreatedDecodeErrorZPtr; /** - * A CResult_UpdateAddHTLCDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::UpdateAddHTLC on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_FundingCreatedDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::FundingCreated on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_UpdateAddHTLCDecodeErrorZ { +typedef struct LDKCResult_FundingCreatedDecodeErrorZ { /** - * The contents of this CResult_UpdateAddHTLCDecodeErrorZ, accessible via either + * The contents of this CResult_FundingCreatedDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_UpdateAddHTLCDecodeErrorZPtr contents; + union LDKCResult_FundingCreatedDecodeErrorZPtr contents; /** - * Whether this CResult_UpdateAddHTLCDecodeErrorZ represents a success state. + * Whether this CResult_FundingCreatedDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_UpdateAddHTLCDecodeErrorZ; - +} LDKCResult_FundingCreatedDecodeErrorZ; +/** + * The contents of CResult_FundingSignedDecodeErrorZ + */ +typedef union LDKCResult_FundingSignedDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKFundingSigned *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_FundingSignedDecodeErrorZPtr; /** - * A ping message to be sent or received from a peer + * A CResult_FundingSignedDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::FundingSigned on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct MUST_USE_STRUCT LDKPing { +typedef struct LDKCResult_FundingSignedDecodeErrorZ { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, 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_FundingSignedDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - LDKnativePing *inner; + union LDKCResult_FundingSignedDecodeErrorZPtr 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_FundingSignedDecodeErrorZ represents a success state. */ - bool is_owned; -} LDKPing; + bool result_ok; +} LDKCResult_FundingSignedDecodeErrorZ; /** - * The contents of CResult_PingDecodeErrorZ + * The contents of CResult_ChannelReadyDecodeErrorZ */ -typedef union LDKCResult_PingDecodeErrorZPtr { +typedef union LDKCResult_ChannelReadyDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKPing *result; + struct LDKChannelReady *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_PingDecodeErrorZPtr; +} LDKCResult_ChannelReadyDecodeErrorZPtr; /** - * A CResult_PingDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::Ping on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_ChannelReadyDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::ChannelReady on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_PingDecodeErrorZ { +typedef struct LDKCResult_ChannelReadyDecodeErrorZ { /** - * The contents of this CResult_PingDecodeErrorZ, accessible via either + * The contents of this CResult_ChannelReadyDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_PingDecodeErrorZPtr contents; + union LDKCResult_ChannelReadyDecodeErrorZPtr contents; /** - * Whether this CResult_PingDecodeErrorZ represents a success state. + * Whether this CResult_ChannelReadyDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_PingDecodeErrorZ; +} LDKCResult_ChannelReadyDecodeErrorZ; /** - * A pong message to be sent or received from a peer + * An init message to be sent or received from a peer */ -typedef struct MUST_USE_STRUCT LDKPong { +typedef struct MUST_USE_STRUCT LDKInit { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativePong *inner; + LDKnativeInit *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; -} LDKPong; +} LDKInit; /** - * The contents of CResult_PongDecodeErrorZ + * The contents of CResult_InitDecodeErrorZ */ -typedef union LDKCResult_PongDecodeErrorZPtr { +typedef union LDKCResult_InitDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKPong *result; + struct LDKInit *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_PongDecodeErrorZPtr; +} LDKCResult_InitDecodeErrorZPtr; /** - * A CResult_PongDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::Pong on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_InitDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::Init on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_PongDecodeErrorZ { +typedef struct LDKCResult_InitDecodeErrorZ { /** - * The contents of this CResult_PongDecodeErrorZ, accessible via either + * The contents of this CResult_InitDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_PongDecodeErrorZPtr contents; + union LDKCResult_InitDecodeErrorZPtr contents; /** - * Whether this CResult_PongDecodeErrorZ represents a success state. + * Whether this CResult_InitDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_PongDecodeErrorZ; +} LDKCResult_InitDecodeErrorZ; /** - * The contents of CResult_UnsignedChannelAnnouncementDecodeErrorZ + * The contents of CResult_OpenChannelDecodeErrorZ */ -typedef union LDKCResult_UnsignedChannelAnnouncementDecodeErrorZPtr { +typedef union LDKCResult_OpenChannelDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKUnsignedChannelAnnouncement *result; + struct LDKOpenChannel *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_UnsignedChannelAnnouncementDecodeErrorZPtr; +} LDKCResult_OpenChannelDecodeErrorZPtr; /** - * A CResult_UnsignedChannelAnnouncementDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::UnsignedChannelAnnouncement on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_OpenChannelDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::OpenChannel on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ { +typedef struct LDKCResult_OpenChannelDecodeErrorZ { /** - * The contents of this CResult_UnsignedChannelAnnouncementDecodeErrorZ, accessible via either + * The contents of this CResult_OpenChannelDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_UnsignedChannelAnnouncementDecodeErrorZPtr contents; + union LDKCResult_OpenChannelDecodeErrorZPtr contents; /** - * Whether this CResult_UnsignedChannelAnnouncementDecodeErrorZ represents a success state. + * Whether this CResult_OpenChannelDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ; +} LDKCResult_OpenChannelDecodeErrorZ; /** - * The contents of CResult_ChannelAnnouncementDecodeErrorZ + * The contents of CResult_RevokeAndACKDecodeErrorZ */ -typedef union LDKCResult_ChannelAnnouncementDecodeErrorZPtr { +typedef union LDKCResult_RevokeAndACKDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKChannelAnnouncement *result; + struct LDKRevokeAndACK *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_ChannelAnnouncementDecodeErrorZPtr; +} LDKCResult_RevokeAndACKDecodeErrorZPtr; /** - * A CResult_ChannelAnnouncementDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::ChannelAnnouncement on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_RevokeAndACKDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::RevokeAndACK on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_ChannelAnnouncementDecodeErrorZ { +typedef struct LDKCResult_RevokeAndACKDecodeErrorZ { /** - * The contents of this CResult_ChannelAnnouncementDecodeErrorZ, accessible via either + * The contents of this CResult_RevokeAndACKDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_ChannelAnnouncementDecodeErrorZPtr contents; + union LDKCResult_RevokeAndACKDecodeErrorZPtr contents; /** - * Whether this CResult_ChannelAnnouncementDecodeErrorZ represents a success state. + * Whether this CResult_RevokeAndACKDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_ChannelAnnouncementDecodeErrorZ; - - - -/** - * The unsigned part of a channel_update - */ -typedef struct MUST_USE_STRUCT LDKUnsignedChannelUpdate { - /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. - */ - LDKnativeUnsignedChannelUpdate *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; -} LDKUnsignedChannelUpdate; +} LDKCResult_RevokeAndACKDecodeErrorZ; /** - * The contents of CResult_UnsignedChannelUpdateDecodeErrorZ + * The contents of CResult_ShutdownDecodeErrorZ */ -typedef union LDKCResult_UnsignedChannelUpdateDecodeErrorZPtr { +typedef union LDKCResult_ShutdownDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKUnsignedChannelUpdate *result; + struct LDKShutdown *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_UnsignedChannelUpdateDecodeErrorZPtr; +} LDKCResult_ShutdownDecodeErrorZPtr; /** - * A CResult_UnsignedChannelUpdateDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::UnsignedChannelUpdate on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_ShutdownDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::Shutdown on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_UnsignedChannelUpdateDecodeErrorZ { +typedef struct LDKCResult_ShutdownDecodeErrorZ { /** - * The contents of this CResult_UnsignedChannelUpdateDecodeErrorZ, accessible via either + * The contents of this CResult_ShutdownDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_UnsignedChannelUpdateDecodeErrorZPtr contents; + union LDKCResult_ShutdownDecodeErrorZPtr contents; /** - * Whether this CResult_UnsignedChannelUpdateDecodeErrorZ represents a success state. + * Whether this CResult_ShutdownDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_UnsignedChannelUpdateDecodeErrorZ; +} LDKCResult_ShutdownDecodeErrorZ; /** - * The contents of CResult_ChannelUpdateDecodeErrorZ + * The contents of CResult_UpdateFailHTLCDecodeErrorZ */ -typedef union LDKCResult_ChannelUpdateDecodeErrorZPtr { +typedef union LDKCResult_UpdateFailHTLCDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKChannelUpdate *result; + struct LDKUpdateFailHTLC *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_ChannelUpdateDecodeErrorZPtr; +} LDKCResult_UpdateFailHTLCDecodeErrorZPtr; /** - * A CResult_ChannelUpdateDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::ChannelUpdate on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_UpdateFailHTLCDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::UpdateFailHTLC on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_ChannelUpdateDecodeErrorZ { +typedef struct LDKCResult_UpdateFailHTLCDecodeErrorZ { /** - * The contents of this CResult_ChannelUpdateDecodeErrorZ, accessible via either + * The contents of this CResult_UpdateFailHTLCDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_ChannelUpdateDecodeErrorZPtr contents; + union LDKCResult_UpdateFailHTLCDecodeErrorZPtr contents; /** - * Whether this CResult_ChannelUpdateDecodeErrorZ represents a success state. + * Whether this CResult_UpdateFailHTLCDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_ChannelUpdateDecodeErrorZ; +} LDKCResult_UpdateFailHTLCDecodeErrorZ; /** - * The contents of CResult_ErrorMessageDecodeErrorZ + * The contents of CResult_UpdateFailMalformedHTLCDecodeErrorZ */ -typedef union LDKCResult_ErrorMessageDecodeErrorZPtr { +typedef union LDKCResult_UpdateFailMalformedHTLCDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKErrorMessage *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_ErrorMessageDecodeErrorZPtr; - -/** - * A CResult_ErrorMessageDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::ErrorMessage on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_ErrorMessageDecodeErrorZ { - /** - * The contents of this CResult_ErrorMessageDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. - */ - union LDKCResult_ErrorMessageDecodeErrorZPtr contents; - /** - * Whether this CResult_ErrorMessageDecodeErrorZ represents a success state. - */ - 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; + struct LDKUpdateFailMalformedHTLC *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; +} LDKCResult_UpdateFailMalformedHTLCDecodeErrorZPtr; /** - * A CResult_WarningMessageDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::WarningMessage on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_UpdateFailMalformedHTLCDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::UpdateFailMalformedHTLC on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_WarningMessageDecodeErrorZ { +typedef struct LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ { /** - * The contents of this CResult_WarningMessageDecodeErrorZ, accessible via either + * The contents of this CResult_UpdateFailMalformedHTLCDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_WarningMessageDecodeErrorZPtr contents; + union LDKCResult_UpdateFailMalformedHTLCDecodeErrorZPtr contents; /** - * Whether this CResult_WarningMessageDecodeErrorZ represents a success state. + * Whether this CResult_UpdateFailMalformedHTLCDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_WarningMessageDecodeErrorZ; +} LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ; /** - * The unsigned part of a node_announcement + * An update_fee message to be sent or received from a peer */ -typedef struct MUST_USE_STRUCT LDKUnsignedNodeAnnouncement { +typedef struct MUST_USE_STRUCT LDKUpdateFee { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeUnsignedNodeAnnouncement *inner; + LDKnativeUpdateFee *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; -} LDKUnsignedNodeAnnouncement; +} LDKUpdateFee; /** - * The contents of CResult_UnsignedNodeAnnouncementDecodeErrorZ + * The contents of CResult_UpdateFeeDecodeErrorZ */ -typedef union LDKCResult_UnsignedNodeAnnouncementDecodeErrorZPtr { +typedef union LDKCResult_UpdateFeeDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKUnsignedNodeAnnouncement *result; + struct LDKUpdateFee *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_UnsignedNodeAnnouncementDecodeErrorZPtr; +} LDKCResult_UpdateFeeDecodeErrorZPtr; /** - * A CResult_UnsignedNodeAnnouncementDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::UnsignedNodeAnnouncement on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_UpdateFeeDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::UpdateFee on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ { +typedef struct LDKCResult_UpdateFeeDecodeErrorZ { /** - * The contents of this CResult_UnsignedNodeAnnouncementDecodeErrorZ, accessible via either + * The contents of this CResult_UpdateFeeDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_UnsignedNodeAnnouncementDecodeErrorZPtr contents; + union LDKCResult_UpdateFeeDecodeErrorZPtr contents; /** - * Whether this CResult_UnsignedNodeAnnouncementDecodeErrorZ represents a success state. + * Whether this CResult_UpdateFeeDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ; +} LDKCResult_UpdateFeeDecodeErrorZ; /** - * The contents of CResult_NodeAnnouncementDecodeErrorZ + * The contents of CResult_UpdateFulfillHTLCDecodeErrorZ */ -typedef union LDKCResult_NodeAnnouncementDecodeErrorZPtr { +typedef union LDKCResult_UpdateFulfillHTLCDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKNodeAnnouncement *result; + struct LDKUpdateFulfillHTLC *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_NodeAnnouncementDecodeErrorZPtr; +} LDKCResult_UpdateFulfillHTLCDecodeErrorZPtr; /** - * A CResult_NodeAnnouncementDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::NodeAnnouncement on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_UpdateFulfillHTLCDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::UpdateFulfillHTLC on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_NodeAnnouncementDecodeErrorZ { +typedef struct LDKCResult_UpdateFulfillHTLCDecodeErrorZ { /** - * The contents of this CResult_NodeAnnouncementDecodeErrorZ, accessible via either + * The contents of this CResult_UpdateFulfillHTLCDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_NodeAnnouncementDecodeErrorZPtr contents; + union LDKCResult_UpdateFulfillHTLCDecodeErrorZPtr contents; /** - * Whether this CResult_NodeAnnouncementDecodeErrorZ represents a success state. + * Whether this CResult_UpdateFulfillHTLCDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_NodeAnnouncementDecodeErrorZ; +} LDKCResult_UpdateFulfillHTLCDecodeErrorZ; /** - * The contents of CResult_QueryShortChannelIdsDecodeErrorZ + * The contents of CResult_UpdateAddHTLCDecodeErrorZ */ -typedef union LDKCResult_QueryShortChannelIdsDecodeErrorZPtr { +typedef union LDKCResult_UpdateAddHTLCDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKQueryShortChannelIds *result; + struct LDKUpdateAddHTLC *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_QueryShortChannelIdsDecodeErrorZPtr; +} LDKCResult_UpdateAddHTLCDecodeErrorZPtr; /** - * A CResult_QueryShortChannelIdsDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::QueryShortChannelIds on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_UpdateAddHTLCDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::UpdateAddHTLC on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_QueryShortChannelIdsDecodeErrorZ { +typedef struct LDKCResult_UpdateAddHTLCDecodeErrorZ { /** - * The contents of this CResult_QueryShortChannelIdsDecodeErrorZ, accessible via either + * The contents of this CResult_UpdateAddHTLCDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_QueryShortChannelIdsDecodeErrorZPtr contents; + union LDKCResult_UpdateAddHTLCDecodeErrorZPtr contents; /** - * Whether this CResult_QueryShortChannelIdsDecodeErrorZ represents a success state. + * Whether this CResult_UpdateAddHTLCDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_QueryShortChannelIdsDecodeErrorZ; +} LDKCResult_UpdateAddHTLCDecodeErrorZ; /** - * A reply_short_channel_ids_end message is sent as a reply to a - * query_short_channel_ids message. The query recipient makes a best - * effort to respond based on their local network view which may not be - * a perfect view of the network. + * An onion message to be sent or received from a peer */ -typedef struct MUST_USE_STRUCT LDKReplyShortChannelIdsEnd { +typedef struct MUST_USE_STRUCT LDKOnionMessage { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeReplyShortChannelIdsEnd *inner; + LDKnativeOnionMessage *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; -} LDKReplyShortChannelIdsEnd; +} LDKOnionMessage; /** - * The contents of CResult_ReplyShortChannelIdsEndDecodeErrorZ + * The contents of CResult_OnionMessageDecodeErrorZ */ -typedef union LDKCResult_ReplyShortChannelIdsEndDecodeErrorZPtr { +typedef union LDKCResult_OnionMessageDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKReplyShortChannelIdsEnd *result; + struct LDKOnionMessage *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_ReplyShortChannelIdsEndDecodeErrorZPtr; +} LDKCResult_OnionMessageDecodeErrorZPtr; /** - * A CResult_ReplyShortChannelIdsEndDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::ReplyShortChannelIdsEnd on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_OnionMessageDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::OnionMessage on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ { +typedef struct LDKCResult_OnionMessageDecodeErrorZ { /** - * The contents of this CResult_ReplyShortChannelIdsEndDecodeErrorZ, accessible via either + * The contents of this CResult_OnionMessageDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_ReplyShortChannelIdsEndDecodeErrorZPtr contents; + union LDKCResult_OnionMessageDecodeErrorZPtr contents; /** - * Whether this CResult_ReplyShortChannelIdsEndDecodeErrorZ represents a success state. + * Whether this CResult_OnionMessageDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ; +} LDKCResult_OnionMessageDecodeErrorZ; + -/** - * The contents of CResult_QueryChannelRangeDecodeErrorZ - */ -typedef union LDKCResult_QueryChannelRangeDecodeErrorZPtr { - /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. - */ - struct LDKQueryChannelRange *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_QueryChannelRangeDecodeErrorZPtr; /** - * A CResult_QueryChannelRangeDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::QueryChannelRange on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. + * A ping message to be sent or received from a peer */ -typedef struct LDKCResult_QueryChannelRangeDecodeErrorZ { +typedef struct MUST_USE_STRUCT LDKPing { /** - * The contents of this CResult_QueryChannelRangeDecodeErrorZ, 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_QueryChannelRangeDecodeErrorZPtr contents; + LDKnativePing *inner; /** - * Whether this CResult_QueryChannelRangeDecodeErrorZ 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_QueryChannelRangeDecodeErrorZ; + bool is_owned; +} LDKPing; /** - * The contents of CResult_ReplyChannelRangeDecodeErrorZ + * The contents of CResult_PingDecodeErrorZ */ -typedef union LDKCResult_ReplyChannelRangeDecodeErrorZPtr { +typedef union LDKCResult_PingDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKReplyChannelRange *result; + struct LDKPing *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_ReplyChannelRangeDecodeErrorZPtr; +} LDKCResult_PingDecodeErrorZPtr; /** - * A CResult_ReplyChannelRangeDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::ReplyChannelRange on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_PingDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::Ping on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_ReplyChannelRangeDecodeErrorZ { +typedef struct LDKCResult_PingDecodeErrorZ { /** - * The contents of this CResult_ReplyChannelRangeDecodeErrorZ, accessible via either + * The contents of this CResult_PingDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_ReplyChannelRangeDecodeErrorZPtr contents; + union LDKCResult_PingDecodeErrorZPtr contents; /** - * Whether this CResult_ReplyChannelRangeDecodeErrorZ represents a success state. + * Whether this CResult_PingDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_ReplyChannelRangeDecodeErrorZ; +} LDKCResult_PingDecodeErrorZ; /** - * 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. + * A pong message to be sent or received from a peer */ -typedef struct MUST_USE_STRUCT LDKGossipTimestampFilter { +typedef struct MUST_USE_STRUCT LDKPong { /** * A pointer to the opaque Rust object. * Nearly everywhere, 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; + LDKnativePong *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; +} LDKPong; /** - * The contents of CResult_GossipTimestampFilterDecodeErrorZ + * The contents of CResult_PongDecodeErrorZ */ -typedef union LDKCResult_GossipTimestampFilterDecodeErrorZPtr { +typedef union LDKCResult_PongDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKGossipTimestampFilter *result; + struct LDKPong *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_GossipTimestampFilterDecodeErrorZPtr; +} LDKCResult_PongDecodeErrorZPtr; /** - * A CResult_GossipTimestampFilterDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::GossipTimestampFilter on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_PongDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::Pong on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_GossipTimestampFilterDecodeErrorZ { +typedef struct LDKCResult_PongDecodeErrorZ { /** - * The contents of this CResult_GossipTimestampFilterDecodeErrorZ, accessible via either + * The contents of this CResult_PongDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_GossipTimestampFilterDecodeErrorZPtr contents; + union LDKCResult_PongDecodeErrorZPtr contents; /** - * Whether this CResult_GossipTimestampFilterDecodeErrorZ represents a success state. + * Whether this CResult_PongDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_GossipTimestampFilterDecodeErrorZ; +} LDKCResult_PongDecodeErrorZ; /** - * A dynamically-allocated array of crate::lightning::ln::channelmanager::PhantomRouteHintss of arbitrary size. - * This corresponds to std::vector in C++ + * The contents of CResult_UnsignedChannelAnnouncementDecodeErrorZ */ -typedef struct LDKCVec_PhantomRouteHintsZ { +typedef union LDKCResult_UnsignedChannelAnnouncementDecodeErrorZPtr { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKPhantomRouteHints *data; + struct LDKUnsignedChannelAnnouncement *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_PhantomRouteHintsZ; + struct LDKDecodeError *err; +} LDKCResult_UnsignedChannelAnnouncementDecodeErrorZPtr; /** - * When signing using a fallible method either an user-supplied `SignError` or a `CreationError` - * may occur. + * A CResult_UnsignedChannelAnnouncementDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::UnsignedChannelAnnouncement on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef enum LDKSignOrCreationError_Tag { - /** - * An error occurred during signing - */ - LDKSignOrCreationError_SignError, +typedef struct LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ { /** - * An error occurred while building the transaction + * The contents of this CResult_UnsignedChannelAnnouncementDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - LDKSignOrCreationError_CreationError, + union LDKCResult_UnsignedChannelAnnouncementDecodeErrorZPtr contents; /** - * Must be last for serialization purposes + * Whether this CResult_UnsignedChannelAnnouncementDecodeErrorZ represents a success state. */ - LDKSignOrCreationError_Sentinel, -} LDKSignOrCreationError_Tag; - -typedef struct MUST_USE_STRUCT LDKSignOrCreationError { - LDKSignOrCreationError_Tag tag; - union { - struct { - enum LDKCreationError creation_error; - }; - }; -} LDKSignOrCreationError; + bool result_ok; +} LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ; /** - * The contents of CResult_InvoiceSignOrCreationErrorZ + * The contents of CResult_ChannelAnnouncementDecodeErrorZ */ -typedef union LDKCResult_InvoiceSignOrCreationErrorZPtr { +typedef union LDKCResult_ChannelAnnouncementDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKInvoice *result; + struct LDKChannelAnnouncement *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKSignOrCreationError *err; -} LDKCResult_InvoiceSignOrCreationErrorZPtr; + struct LDKDecodeError *err; +} LDKCResult_ChannelAnnouncementDecodeErrorZPtr; /** - * A CResult_InvoiceSignOrCreationErrorZ represents the result of a fallible operation, - * containing a crate::lightning_invoice::Invoice on success and a crate::lightning_invoice::SignOrCreationError on failure. + * A CResult_ChannelAnnouncementDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::ChannelAnnouncement on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_InvoiceSignOrCreationErrorZ { +typedef struct LDKCResult_ChannelAnnouncementDecodeErrorZ { /** - * The contents of this CResult_InvoiceSignOrCreationErrorZ, accessible via either + * The contents of this CResult_ChannelAnnouncementDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_InvoiceSignOrCreationErrorZPtr contents; + union LDKCResult_ChannelAnnouncementDecodeErrorZPtr contents; /** - * Whether this CResult_InvoiceSignOrCreationErrorZ represents a success state. + * Whether this CResult_ChannelAnnouncementDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_InvoiceSignOrCreationErrorZ; +} LDKCResult_ChannelAnnouncementDecodeErrorZ; /** - * A transaction output watched by a [`ChannelMonitor`] for spends on-chain. - * - * Used to convey to a [`Filter`] such an output with a given spending condition. Any transaction - * spending the output must be given to [`ChannelMonitor::block_connected`] either directly or via - * the return value of [`Filter::register_output`]. - * - * If `block_hash` is `Some`, this indicates the output was created in the corresponding block and - * may have been spent there. See [`Filter::register_output`] for details. - * - * [`ChannelMonitor`]: channelmonitor::ChannelMonitor - * [`ChannelMonitor::block_connected`]: channelmonitor::ChannelMonitor::block_connected + * The unsigned part of a channel_update */ -typedef struct MUST_USE_STRUCT LDKWatchedOutput { +typedef struct MUST_USE_STRUCT LDKUnsignedChannelUpdate { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeWatchedOutput *inner; + LDKnativeUnsignedChannelUpdate *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKWatchedOutput; +} LDKUnsignedChannelUpdate; /** - * The `Filter` trait defines behavior for indicating chain activity of interest pertaining to - * channels. - * - * This is useful in order to have a [`Watch`] implementation convey to a chain source which - * transactions to be notified of. Notification may take the form of pre-filtering blocks or, in - * the case of [BIP 157]/[BIP 158], only fetching a block if the compact filter matches. If - * receiving full blocks from a chain source, any further filtering is unnecessary. - * - * After an output has been registered, subsequent block retrievals from the chain source must not - * exclude any transactions matching the new criteria nor any in-block descendants of such - * transactions. - * - * Note that use as part of a [`Watch`] implementation involves reentrancy. Therefore, the `Filter` - * should not block on I/O. Implementations should instead queue the newly monitored data to be - * processed later. Then, in order to block until the data has been processed, any [`Watch`] - * invocation that has called the `Filter` must return [`TemporaryFailure`]. - * - * [`TemporaryFailure`]: ChannelMonitorUpdateErr::TemporaryFailure - * [BIP 157]: https://github.com/bitcoin/bips/blob/master/bip-0157.mediawiki - * [BIP 158]: https://github.com/bitcoin/bips/blob/master/bip-0158.mediawiki + * The contents of CResult_UnsignedChannelUpdateDecodeErrorZ */ -typedef struct LDKFilter { +typedef union LDKCResult_UnsignedChannelUpdateDecodeErrorZPtr { /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - void *this_arg; + struct LDKUnsignedChannelUpdate *result; /** - * Registers interest in a transaction with `txid` and having an output with `script_pubkey` as - * a spending condition. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - void (*register_tx)(const void *this_arg, const uint8_t (*txid)[32], struct LDKu8slice script_pubkey); + struct LDKDecodeError *err; +} LDKCResult_UnsignedChannelUpdateDecodeErrorZPtr; + +/** + * A CResult_UnsignedChannelUpdateDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::UnsignedChannelUpdate on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_UnsignedChannelUpdateDecodeErrorZ { /** - * Registers interest in spends of a transaction output. - * - * Optionally, when `output.block_hash` is set, should return any transaction spending the - * output that is found in the corresponding block along with its index. - * - * This return value is useful for Electrum clients in order to supply in-block descendant - * transactions which otherwise were not included. This is not necessary for other clients if - * such descendant transactions were already included (e.g., when a BIP 157 client provides the - * full block). + * The contents of this CResult_UnsignedChannelUpdateDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKCOption_C2Tuple_usizeTransactionZZ (*register_output)(const void *this_arg, struct LDKWatchedOutput output); + union LDKCResult_UnsignedChannelUpdateDecodeErrorZPtr 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_UnsignedChannelUpdateDecodeErrorZ represents a success state. */ - void (*free)(void *this_arg); -} LDKFilter; + bool result_ok; +} LDKCResult_UnsignedChannelUpdateDecodeErrorZ; /** - * An enum which can either contain a crate::lightning::chain::Filter or not + * The contents of CResult_ChannelUpdateDecodeErrorZ */ -typedef enum LDKCOption_FilterZ_Tag { - /** - * When we're in this state, this COption_FilterZ contains a crate::lightning::chain::Filter - */ - LDKCOption_FilterZ_Some, +typedef union LDKCResult_ChannelUpdateDecodeErrorZPtr { /** - * When we're in this state, this COption_FilterZ contains nothing + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - LDKCOption_FilterZ_None, + struct LDKChannelUpdate *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. */ - LDKCOption_FilterZ_Sentinel, -} LDKCOption_FilterZ_Tag; - -typedef struct LDKCOption_FilterZ { - LDKCOption_FilterZ_Tag tag; - union { - struct { - struct LDKFilter some; - }; - }; -} LDKCOption_FilterZ; - - + struct LDKDecodeError *err; +} LDKCResult_ChannelUpdateDecodeErrorZPtr; /** - * A read-only reference to a current ChannelMonitor. - * - * Note that this holds a mutex in [`ChainMonitor`] and may block other events until it is - * released. + * A CResult_ChannelUpdateDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::ChannelUpdate on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct MUST_USE_STRUCT LDKLockedChannelMonitor { +typedef struct LDKCResult_ChannelUpdateDecodeErrorZ { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, 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_ChannelUpdateDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - LDKnativeLockedChannelMonitor *inner; + union LDKCResult_ChannelUpdateDecodeErrorZPtr 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_ChannelUpdateDecodeErrorZ represents a success state. */ - bool is_owned; -} LDKLockedChannelMonitor; + bool result_ok; +} LDKCResult_ChannelUpdateDecodeErrorZ; /** - * The contents of CResult_LockedChannelMonitorNoneZ + * The contents of CResult_ErrorMessageDecodeErrorZ */ -typedef union LDKCResult_LockedChannelMonitorNoneZPtr { +typedef union LDKCResult_ErrorMessageDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKLockedChannelMonitor *result; + struct LDKErrorMessage *result; /** - * Note that this value is always NULL, as there are no contents in the Err variant + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - void *err; -} LDKCResult_LockedChannelMonitorNoneZPtr; + struct LDKDecodeError *err; +} LDKCResult_ErrorMessageDecodeErrorZPtr; /** - * A CResult_LockedChannelMonitorNoneZ represents the result of a fallible operation, - * containing a crate::lightning::chain::chainmonitor::LockedChannelMonitor on success and a () on failure. + * A CResult_ErrorMessageDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::ErrorMessage on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_LockedChannelMonitorNoneZ { +typedef struct LDKCResult_ErrorMessageDecodeErrorZ { /** - * The contents of this CResult_LockedChannelMonitorNoneZ, accessible via either + * The contents of this CResult_ErrorMessageDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_LockedChannelMonitorNoneZPtr contents; + union LDKCResult_ErrorMessageDecodeErrorZPtr contents; /** - * Whether this CResult_LockedChannelMonitorNoneZ represents a success state. + * Whether this CResult_ErrorMessageDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_LockedChannelMonitorNoneZ; +} LDKCResult_ErrorMessageDecodeErrorZ; /** - * A dynamically-allocated array of crate::lightning::chain::transaction::OutPoints of arbitrary size. - * This corresponds to std::vector in C++ + * The contents of CResult_WarningMessageDecodeErrorZ */ -typedef struct LDKCVec_OutPointZ { +typedef union LDKCResult_WarningMessageDecodeErrorZPtr { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKOutPoint *data; + struct LDKWarningMessage *result; /** - * The number of elements pointed to by `data`. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - uintptr_t datalen; -} LDKCVec_OutPointZ; + struct LDKDecodeError *err; +} LDKCResult_WarningMessageDecodeErrorZPtr; /** - * A trait indicating an object may generate message send events + * 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 LDKMessageSendEventsProvider { - /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. - */ - void *this_arg; +typedef struct LDKCResult_WarningMessageDecodeErrorZ { /** - * Gets the list of pending events which were generated by previous actions, clearing the list - * in the process. + * The contents of this CResult_WarningMessageDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKCVec_MessageSendEventZ (*get_and_clear_pending_msg_events)(const void *this_arg); + union LDKCResult_WarningMessageDecodeErrorZPtr 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_WarningMessageDecodeErrorZ represents a success state. */ - void (*free)(void *this_arg); -} LDKMessageSendEventsProvider; + bool result_ok; +} LDKCResult_WarningMessageDecodeErrorZ; + + /** - * A trait implemented for objects handling events from [`EventsProvider`]. + * The unsigned part of a node_announcement */ -typedef struct LDKEventHandler { +typedef struct MUST_USE_STRUCT LDKUnsignedNodeAnnouncement { /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - void *this_arg; - /** - * Handles the given [`Event`]. - * - * See [`EventsProvider`] for details that must be considered when implementing this method. - */ - void (*handle_event)(const void *this_arg, const struct LDKEvent *NONNULL_PTR event); + LDKnativeUnsignedNodeAnnouncement *inner; /** - * Frees any resources associated with this object given its this_arg pointer. - * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - void (*free)(void *this_arg); -} LDKEventHandler; + bool is_owned; +} LDKUnsignedNodeAnnouncement; /** - * A trait indicating an object may generate events. - * - * Events are processed by passing an [`EventHandler`] to [`process_pending_events`]. - * - * # Requirements - * - * See [`process_pending_events`] for requirements around event processing. - * - * When using this trait, [`process_pending_events`] will call [`handle_event`] for each pending - * event since the last invocation. The handler must either act upon the event immediately - * or preserve it for later handling. - * - * Note, handlers may call back into the provider and thus deadlocking must be avoided. Be sure to - * consult the provider's documentation on the implication of processing events and how a handler - * may safely use the provider (e.g., see [`ChannelManager::process_pending_events`] and - * [`ChainMonitor::process_pending_events`]). - * - * (C-not implementable) As there is likely no reason for a user to implement this trait on their - * own type(s). - * - * [`process_pending_events`]: Self::process_pending_events - * [`handle_event`]: EventHandler::handle_event - * [`ChannelManager::process_pending_events`]: crate::ln::channelmanager::ChannelManager#method.process_pending_events - * [`ChainMonitor::process_pending_events`]: crate::chain::chainmonitor::ChainMonitor#method.process_pending_events + * The contents of CResult_UnsignedNodeAnnouncementDecodeErrorZ */ -typedef struct LDKEventsProvider { +typedef union LDKCResult_UnsignedNodeAnnouncementDecodeErrorZPtr { /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - void *this_arg; + struct LDKUnsignedNodeAnnouncement *result; /** - * Processes any events generated since the last call using the given event handler. - * - * Subsequent calls must only process new events. However, handlers must be capable of handling - * duplicate events across process restarts. This may occur if the provider was recovered from - * an old state (i.e., it hadn't been successfully persisted after processing pending events). + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - void (*process_pending_events)(const void *this_arg, struct LDKEventHandler handler); + struct LDKDecodeError *err; +} LDKCResult_UnsignedNodeAnnouncementDecodeErrorZPtr; + +/** + * A CResult_UnsignedNodeAnnouncementDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::UnsignedNodeAnnouncement on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ { /** - * 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 contents of this CResult_UnsignedNodeAnnouncementDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - void (*free)(void *this_arg); -} LDKEventsProvider; + union LDKCResult_UnsignedNodeAnnouncementDecodeErrorZPtr contents; + /** + * Whether this CResult_UnsignedNodeAnnouncementDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ; /** - * Configuration we set when applicable. - * - * Default::default() provides sane defaults. + * A node_announcement message to be sent or received from a peer */ -typedef struct MUST_USE_STRUCT LDKChannelHandshakeConfig { +typedef struct MUST_USE_STRUCT LDKNodeAnnouncement { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeChannelHandshakeConfig *inner; + LDKnativeNodeAnnouncement *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; -} LDKChannelHandshakeConfig; - - +} LDKNodeAnnouncement; /** - * Optional channel limits which are applied during channel creation. - * - * These limits are only applied to our counterparty's limits, not our own. - * - * Use 0/::max_value() as appropriate to skip checking. - * - * Provides sane defaults for most configurations. - * - * Most additional limits are disabled except those with which specify a default in individual - * field documentation. Note that this may result in barely-usable channels, but since they - * are applied mostly only to incoming channels that's not much of a problem. + * The contents of CResult_NodeAnnouncementDecodeErrorZ */ -typedef struct MUST_USE_STRUCT LDKChannelHandshakeLimits { +typedef union LDKCResult_NodeAnnouncementDecodeErrorZPtr { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, 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. */ - LDKnativeChannelHandshakeLimits *inner; + struct LDKNodeAnnouncement *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; -} LDKChannelHandshakeLimits; + struct LDKDecodeError *err; +} LDKCResult_NodeAnnouncementDecodeErrorZPtr; +/** + * A CResult_NodeAnnouncementDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::NodeAnnouncement on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_NodeAnnouncementDecodeErrorZ { + /** + * The contents of this CResult_NodeAnnouncementDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_NodeAnnouncementDecodeErrorZPtr contents; + /** + * Whether this CResult_NodeAnnouncementDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_NodeAnnouncementDecodeErrorZ; +/** + * The contents of CResult_QueryShortChannelIdsDecodeErrorZ + */ +typedef union LDKCResult_QueryShortChannelIdsDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKQueryShortChannelIds *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_QueryShortChannelIdsDecodeErrorZPtr; /** - * Top-level config which holds ChannelHandshakeLimits and ChannelConfig. - * - * Default::default() provides sane defaults for most configurations - * (but currently with 0 relay fees!) + * A CResult_QueryShortChannelIdsDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::QueryShortChannelIds on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct MUST_USE_STRUCT LDKUserConfig { +typedef struct LDKCResult_QueryShortChannelIdsDecodeErrorZ { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, 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_QueryShortChannelIdsDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - LDKnativeUserConfig *inner; + union LDKCResult_QueryShortChannelIdsDecodeErrorZPtr 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_QueryShortChannelIdsDecodeErrorZ represents a success state. */ - bool is_owned; -} LDKUserConfig; + bool result_ok; +} LDKCResult_QueryShortChannelIdsDecodeErrorZ; /** - * The best known block as identified by its hash and height. + * A reply_short_channel_ids_end message is sent as a reply to a + * query_short_channel_ids message. The query recipient makes a best + * effort to respond based on their local network view which may not be + * a perfect view of the network. */ -typedef struct MUST_USE_STRUCT LDKBestBlock { +typedef struct MUST_USE_STRUCT LDKReplyShortChannelIdsEnd { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeBestBlock *inner; + LDKnativeReplyShortChannelIdsEnd *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; -} LDKBestBlock; +} LDKReplyShortChannelIdsEnd; /** - * The `Listen` trait is used to notify when blocks have been connected or disconnected from the - * chain. - * - * Useful when needing to replay chain data upon startup or as new chain events occur. Clients - * sourcing chain data using a block-oriented API should prefer this interface over [`Confirm`]. - * Such clients fetch the entire header chain whereas clients using [`Confirm`] only fetch headers - * when needed. + * The contents of CResult_ReplyShortChannelIdsEndDecodeErrorZ */ -typedef struct LDKListen { +typedef union LDKCResult_ReplyShortChannelIdsEndDecodeErrorZPtr { /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - void *this_arg; + struct LDKReplyShortChannelIdsEnd *result; /** - * Notifies the listener that a block was added at the given height. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - void (*block_connected)(const void *this_arg, struct LDKu8slice block, uint32_t height); + struct LDKDecodeError *err; +} LDKCResult_ReplyShortChannelIdsEndDecodeErrorZPtr; + +/** + * A CResult_ReplyShortChannelIdsEndDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::ReplyShortChannelIdsEnd on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ { /** - * Notifies the listener that a block was removed at the given height. + * The contents of this CResult_ReplyShortChannelIdsEndDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - void (*block_disconnected)(const void *this_arg, const uint8_t (*header)[80], uint32_t height); + union LDKCResult_ReplyShortChannelIdsEndDecodeErrorZPtr 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_ReplyShortChannelIdsEndDecodeErrorZ represents a success state. */ - void (*free)(void *this_arg); -} LDKListen; + bool result_ok; +} LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ; /** - * The `Confirm` trait is used to notify when transactions have been confirmed on chain or - * unconfirmed during a chain reorganization. - * - * Clients sourcing chain data using a transaction-oriented API should prefer this interface over - * [`Listen`]. For instance, an Electrum client may implement [`Filter`] by subscribing to activity - * related to registered transactions and outputs. Upon notification, it would pass along the - * matching transactions using this interface. - * - * # Use - * - * The intended use is as follows: - * - Call [`transactions_confirmed`] to process any on-chain activity of interest. - * - Call [`transaction_unconfirmed`] to process any transaction returned by [`get_relevant_txids`] - * that has been reorganized out of the chain. - * - Call [`best_block_updated`] whenever a new chain tip becomes available. - * - * # Order - * - * Clients must call these methods in chain order. Specifically: - * - Transactions confirmed in a block must be given before transactions confirmed in a later - * block. - * - Dependent transactions within the same block must be given in topological order, possibly in - * separate calls. - * - Unconfirmed transactions must be given after the original confirmations and before any - * reconfirmation. - * - * See individual method documentation for further details. - * - * [`transactions_confirmed`]: Self::transactions_confirmed - * [`transaction_unconfirmed`]: Self::transaction_unconfirmed - * [`best_block_updated`]: Self::best_block_updated - * [`get_relevant_txids`]: Self::get_relevant_txids + * The contents of CResult_QueryChannelRangeDecodeErrorZ */ -typedef struct LDKConfirm { +typedef union LDKCResult_QueryChannelRangeDecodeErrorZPtr { /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - void *this_arg; + struct LDKQueryChannelRange *result; /** - * Processes transactions confirmed in a block with a given header and height. - * - * Should be called for any transactions registered by [`Filter::register_tx`] or any - * transactions spending an output registered by [`Filter::register_output`]. Such transactions - * appearing in the same block do not need to be included in the same call; instead, multiple - * calls with additional transactions may be made so long as they are made in [chain order]. - * - * May be called before or after [`best_block_updated`] for the corresponding block. However, - * in the event of a chain reorganization, it must not be called with a `header` that is no - * longer in the chain as of the last call to [`best_block_updated`]. - * - * [chain order]: Confirm#Order - * [`best_block_updated`]: Self::best_block_updated + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - void (*transactions_confirmed)(const void *this_arg, const uint8_t (*header)[80], struct LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height); + struct LDKDecodeError *err; +} LDKCResult_QueryChannelRangeDecodeErrorZPtr; + +/** + * A CResult_QueryChannelRangeDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::QueryChannelRange on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_QueryChannelRangeDecodeErrorZ { /** - * Processes a transaction that is no longer confirmed as result of a chain reorganization. - * - * Should be called for any transaction returned by [`get_relevant_txids`] if it has been - * reorganized out of the best chain. Once called, the given transaction should not be returned - * by [`get_relevant_txids`] unless it has been reconfirmed via [`transactions_confirmed`]. - * - * [`get_relevant_txids`]: Self::get_relevant_txids - * [`transactions_confirmed`]: Self::transactions_confirmed + * The contents of this CResult_QueryChannelRangeDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - void (*transaction_unconfirmed)(const void *this_arg, const uint8_t (*txid)[32]); + union LDKCResult_QueryChannelRangeDecodeErrorZPtr contents; /** - * Processes an update to the best header connected at the given height. - * - * Should be called when a new header is available but may be skipped for intermediary blocks - * if they become available at the same time. + * Whether this CResult_QueryChannelRangeDecodeErrorZ represents a success state. */ - void (*best_block_updated)(const void *this_arg, const uint8_t (*header)[80], uint32_t height); + bool result_ok; +} LDKCResult_QueryChannelRangeDecodeErrorZ; + +/** + * The contents of CResult_ReplyChannelRangeDecodeErrorZ + */ +typedef union LDKCResult_ReplyChannelRangeDecodeErrorZPtr { /** - * Returns transactions that should be monitored for reorganization out of the chain. - * - * Should include any transactions passed to [`transactions_confirmed`] that have insufficient - * confirmations to be safe from a chain reorganization. Should not include any transactions - * passed to [`transaction_unconfirmed`] unless later reconfirmed. - * - * May be called to determine the subset of transactions that must still be monitored for - * reorganization. Will be idempotent between calls but may change as a result of calls to the - * other interface methods. Thus, this is useful to determine which transactions may need to be - * given to [`transaction_unconfirmed`]. - * - * [`transactions_confirmed`]: Self::transactions_confirmed - * [`transaction_unconfirmed`]: Self::transaction_unconfirmed + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKCVec_TxidZ (*get_relevant_txids)(const void *this_arg); + struct LDKReplyChannelRange *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); -} LDKConfirm; - - + struct LDKDecodeError *err; +} LDKCResult_ReplyChannelRangeDecodeErrorZPtr; /** - * An opaque identifier describing a specific [`Persist`] method call. + * A CResult_ReplyChannelRangeDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::ReplyChannelRange on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct MUST_USE_STRUCT LDKMonitorUpdateId { +typedef struct LDKCResult_ReplyChannelRangeDecodeErrorZ { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, 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_ReplyChannelRangeDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - LDKnativeMonitorUpdateId *inner; + union LDKCResult_ReplyChannelRangeDecodeErrorZPtr 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_ReplyChannelRangeDecodeErrorZ represents a success state. */ - bool is_owned; -} LDKMonitorUpdateId; + bool result_ok; +} LDKCResult_ReplyChannelRangeDecodeErrorZ; /** - * `Persist` defines behavior for persisting channel monitors: this could mean - * writing once to disk, and/or uploading to one or more backup services. - * - * Each method can return three possible values: - * * If persistence (including any relevant `fsync()` calls) happens immediately, the - * implementation should return `Ok(())`, indicating normal channel operation should continue. - * * If persistence happens asynchronously, implementations should first ensure the - * [`ChannelMonitor`] or [`ChannelMonitorUpdate`] are written durably to disk, and then return - * `Err(ChannelMonitorUpdateErr::TemporaryFailure)` while the update continues in the - * background. Once the update completes, [`ChainMonitor::channel_monitor_updated`] should be - * called with the corresponding [`MonitorUpdateId`]. - * - * Note that unlike the direct [`chain::Watch`] interface, - * [`ChainMonitor::channel_monitor_updated`] must be called once for *each* update which occurs. - * - * * If persistence fails for some reason, implementations should return - * `Err(ChannelMonitorUpdateErr::PermanentFailure)`, in which case the channel will likely be - * closed without broadcasting the latest state. See - * [`ChannelMonitorUpdateErr::PermanentFailure`] for more details. + * The contents of CResult_GossipTimestampFilterDecodeErrorZ */ -typedef struct LDKPersist { +typedef union LDKCResult_GossipTimestampFilterDecodeErrorZPtr { /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - void *this_arg; + struct LDKGossipTimestampFilter *result; /** - * Persist a new channel's data in response to a [`chain::Watch::watch_channel`] call. This is - * called by [`ChannelManager`] for new channels, or may be called directly, e.g. on startup. - * - * The data can be stored any way you want, but the identifier provided by LDK is the - * channel's outpoint (and it is up to you to maintain a correct mapping between the outpoint - * and the stored channel data). Note that you **must** persist every new monitor to disk. - * - * The `update_id` is used to identify this call to [`ChainMonitor::channel_monitor_updated`], - * if you return [`ChannelMonitorUpdateErr::TemporaryFailure`]. - * - * See [`Writeable::write`] on [`ChannelMonitor`] for writing out a `ChannelMonitor` - * and [`ChannelMonitorUpdateErr`] for requirements when returning errors. - * - * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager - * [`Writeable::write`]: crate::util::ser::Writeable::write + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKCResult_NoneChannelMonitorUpdateErrZ (*persist_new_channel)(const void *this_arg, struct LDKOutPoint channel_id, const struct LDKChannelMonitor *NONNULL_PTR data, struct LDKMonitorUpdateId update_id); + struct LDKDecodeError *err; +} LDKCResult_GossipTimestampFilterDecodeErrorZPtr; + +/** + * A CResult_GossipTimestampFilterDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::GossipTimestampFilter on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_GossipTimestampFilterDecodeErrorZ { /** - * Update one channel's data. The provided [`ChannelMonitor`] has already applied the given - * update. - * - * Note that on every update, you **must** persist either the [`ChannelMonitorUpdate`] or the - * updated monitor itself to disk/backups. See the [`Persist`] trait documentation for more - * details. - * - * During blockchain synchronization operations, this may be called with no - * [`ChannelMonitorUpdate`], in which case the full [`ChannelMonitor`] needs to be persisted. - * Note that after the full [`ChannelMonitor`] is persisted any previous - * [`ChannelMonitorUpdate`]s which were persisted should be discarded - they can no longer be - * applied to the persisted [`ChannelMonitor`] as they were already applied. - * - * If an implementer chooses to persist the updates only, they need to make - * sure that all the updates are applied to the `ChannelMonitors` *before* - * the set of channel monitors is given to the `ChannelManager` - * deserialization routine. See [`ChannelMonitor::update_monitor`] for - * applying a monitor update to a monitor. If full `ChannelMonitors` are - * persisted, then there is no need to persist individual updates. - * - * Note that there could be a performance tradeoff between persisting complete - * channel monitors on every update vs. persisting only updates and applying - * them in batches. The size of each monitor grows `O(number of state updates)` - * whereas updates are small and `O(1)`. - * - * The `update_id` is used to identify this call to [`ChainMonitor::channel_monitor_updated`], - * if you return [`ChannelMonitorUpdateErr::TemporaryFailure`]. - * - * See [`Writeable::write`] on [`ChannelMonitor`] for writing out a `ChannelMonitor`, - * [`Writeable::write`] on [`ChannelMonitorUpdate`] for writing out an update, and - * [`ChannelMonitorUpdateErr`] for requirements when returning errors. - * - * [`Writeable::write`]: crate::util::ser::Writeable::write - * - * Note that update (or a relevant inner pointer) may be NULL or all-0s to represent None + * The contents of this CResult_GossipTimestampFilterDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKCResult_NoneChannelMonitorUpdateErrZ (*update_persisted_channel)(const void *this_arg, struct LDKOutPoint channel_id, const struct LDKChannelMonitorUpdate *NONNULL_PTR update, const struct LDKChannelMonitor *NONNULL_PTR data, struct LDKMonitorUpdateId update_id); + union LDKCResult_GossipTimestampFilterDecodeErrorZPtr 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_GossipTimestampFilterDecodeErrorZ represents a success state. */ - void (*free)(void *this_arg); -} LDKPersist; - - + bool result_ok; +} LDKCResult_GossipTimestampFilterDecodeErrorZ; /** - * An implementation of [`chain::Watch`] for monitoring channels. - * - * Connected and disconnected blocks must be provided to `ChainMonitor` as documented by - * [`chain::Watch`]. May be used in conjunction with [`ChannelManager`] to monitor channels locally - * or used independently to monitor channels remotely. See the [module-level documentation] for - * details. - * - * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager - * [module-level documentation]: crate::chain::chainmonitor + * A dynamically-allocated array of crate::lightning::ln::channelmanager::PhantomRouteHintss of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef struct MUST_USE_STRUCT LDKChainMonitor { +typedef struct LDKCVec_PhantomRouteHintsZ { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, 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(). */ - LDKnativeChainMonitor *inner; + struct LDKPhantomRouteHints *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; -} LDKChainMonitor; - - + uintptr_t datalen; +} LDKCVec_PhantomRouteHintsZ; /** - * Simple KeysInterface implementor that takes a 32-byte seed for use as a BIP 32 extended key - * and derives keys from that. - * - * Your node_id is seed/0' - * ChannelMonitor closes may use seed/1' - * Cooperative closes may use seed/2' - * The two close keys may be needed to claim on-chain funds! - * - * This struct cannot be used for nodes that wish to support receiving phantom payments; - * [`PhantomKeysManager`] must be used instead. - * - * Note that switching between this struct and [`PhantomKeysManager`] will invalidate any - * previously issued invoices and attempts to pay previous invoices will fail. + * When signing using a fallible method either an user-supplied `SignError` or a `CreationError` + * may occur. */ -typedef struct MUST_USE_STRUCT LDKKeysManager { +typedef enum LDKSignOrCreationError_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 occurred during signing */ - LDKnativeKeysManager *inner; + LDKSignOrCreationError_SignError, /** - * Indicates that this is the only struct which contains the same pointer. - * Rust 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 occurred while building the transaction */ - bool is_owned; -} LDKKeysManager; - + LDKSignOrCreationError_CreationError, + /** + * Must be last for serialization purposes + */ + LDKSignOrCreationError_Sentinel, +} LDKSignOrCreationError_Tag; +typedef struct MUST_USE_STRUCT LDKSignOrCreationError { + LDKSignOrCreationError_Tag tag; + union { + struct { + enum LDKCreationError creation_error; + }; + }; +} LDKSignOrCreationError; /** - * 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. + * The contents of CResult_InvoiceSignOrCreationErrorZ */ -typedef struct MUST_USE_STRUCT LDKPhantomKeysManager { +typedef union LDKCResult_InvoiceSignOrCreationErrorZPtr { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, 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. */ - LDKnativePhantomKeysManager *inner; + struct LDKInvoice *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; -} LDKPhantomKeysManager; + struct LDKSignOrCreationError *err; +} LDKCResult_InvoiceSignOrCreationErrorZPtr; + +/** + * A CResult_InvoiceSignOrCreationErrorZ represents the result of a fallible operation, + * containing a crate::lightning_invoice::Invoice on success and a crate::lightning_invoice::SignOrCreationError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_InvoiceSignOrCreationErrorZ { + /** + * The contents of this CResult_InvoiceSignOrCreationErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_InvoiceSignOrCreationErrorZPtr contents; + /** + * Whether this CResult_InvoiceSignOrCreationErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_InvoiceSignOrCreationErrorZ; /** - * Chain-related parameters used to construct a new `ChannelManager`. + * A transaction output watched by a [`ChannelMonitor`] for spends on-chain. * - * 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`. + * Used to convey to a [`Filter`] such an output with a given spending condition. Any transaction + * spending the output must be given to [`ChannelMonitor::block_connected`] either directly or via + * [`Confirm::transactions_confirmed`]. + * + * If `block_hash` is `Some`, this indicates the output was created in the corresponding block and + * may have been spent there. See [`Filter::register_output`] for details. + * + * [`ChannelMonitor`]: channelmonitor::ChannelMonitor + * [`ChannelMonitor::block_connected`]: channelmonitor::ChannelMonitor::block_connected */ -typedef struct MUST_USE_STRUCT LDKChainParameters { +typedef struct MUST_USE_STRUCT LDKWatchedOutput { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeChainParameters *inner; + LDKnativeWatchedOutput *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKChainParameters; - -/** - * A 3-byte byte array. - */ -typedef struct LDKThreeBytes { - /** - * The three bytes - */ - uint8_t data[3]; -} LDKThreeBytes; +} LDKWatchedOutput; /** - * A trait to describe an object which can receive channel messages. + * The `Filter` trait defines behavior for indicating chain activity of interest pertaining to + * channels. * - * Messages MAY be called in parallel when they originate from different their_node_ids, however - * they MUST NOT be called in parallel when the two calls have the same their_node_id. + * This is useful in order to have a [`Watch`] implementation convey to a chain source which + * transactions to be notified of. Notification may take the form of pre-filtering blocks or, in + * the case of [BIP 157]/[BIP 158], only fetching a block if the compact filter matches. If + * receiving full blocks from a chain source, any further filtering is unnecessary. + * + * After an output has been registered, subsequent block retrievals from the chain source must not + * exclude any transactions matching the new criteria nor any in-block descendants of such + * transactions. + * + * Note that use as part of a [`Watch`] implementation involves reentrancy. Therefore, the `Filter` + * should not block on I/O. Implementations should instead queue the newly monitored data to be + * processed later. Then, in order to block until the data has been processed, any [`Watch`] + * invocation that has called the `Filter` must return [`InProgress`]. + * + * [`InProgress`]: ChannelMonitorUpdateStatus::InProgress + * [BIP 157]: https://github.com/bitcoin/bips/blob/master/bip-0157.mediawiki + * [BIP 158]: https://github.com/bitcoin/bips/blob/master/bip-0158.mediawiki */ -typedef struct LDKChannelMessageHandler { +typedef struct LDKFilter { /** * An opaque pointer which is passed to your function implementations as an argument. * This has no meaning in the LDK, and can be NULL or any other value. */ void *this_arg; /** - * Handle an incoming open_channel message from the given peer. + * Registers interest in a transaction with `txid` and having an output with `script_pubkey` as + * a spending condition. */ - void (*handle_open_channel)(const void *this_arg, struct LDKPublicKey their_node_id, struct LDKInitFeatures their_features, const struct LDKOpenChannel *NONNULL_PTR msg); + void (*register_tx)(const void *this_arg, const uint8_t (*txid)[32], struct LDKu8slice script_pubkey); /** - * Handle an incoming accept_channel message from the given peer. + * Registers interest in spends of a transaction output. + * + * Note that this method might be called during processing of a new block. You therefore need + * to ensure that also dependent output spents within an already connected block are correctly + * handled, e.g., by re-scanning the block in question whenever new outputs have been + * registered mid-processing. */ - void (*handle_accept_channel)(const void *this_arg, struct LDKPublicKey their_node_id, struct LDKInitFeatures their_features, const struct LDKAcceptChannel *NONNULL_PTR msg); + void (*register_output)(const void *this_arg, struct LDKWatchedOutput output); /** - * Handle an incoming funding_created message from the given peer. + * 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 (*handle_funding_created)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKFundingCreated *NONNULL_PTR msg); + void (*free)(void *this_arg); +} LDKFilter; + +/** + * An enum which can either contain a crate::lightning::chain::Filter or not + */ +typedef enum LDKCOption_FilterZ_Tag { /** - * Handle an incoming funding_signed message from the given peer. + * When we're in this state, this COption_FilterZ contains a crate::lightning::chain::Filter */ - void (*handle_funding_signed)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKFundingSigned *NONNULL_PTR msg); + LDKCOption_FilterZ_Some, /** - * Handle an incoming funding_locked message from the given peer. + * When we're in this state, this COption_FilterZ contains nothing */ - void (*handle_funding_locked)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKFundingLocked *NONNULL_PTR msg); + LDKCOption_FilterZ_None, /** - * Handle an incoming shutdown message from the given peer. + * Must be last for serialization purposes */ - void (*handle_shutdown)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKInitFeatures *NONNULL_PTR their_features, const struct LDKShutdown *NONNULL_PTR msg); + LDKCOption_FilterZ_Sentinel, +} LDKCOption_FilterZ_Tag; + +typedef struct LDKCOption_FilterZ { + LDKCOption_FilterZ_Tag tag; + union { + struct { + struct LDKFilter some; + }; + }; +} LDKCOption_FilterZ; + + + +/** + * A read-only reference to a current ChannelMonitor. + * + * Note that this holds a mutex in [`ChainMonitor`] and may block other events until it is + * released. + */ +typedef struct MUST_USE_STRUCT LDKLockedChannelMonitor { /** - * Handle an incoming closing_signed message from the given peer. + * A pointer to the opaque Rust object. + * Nearly everywhere, 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 (*handle_closing_signed)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKClosingSigned *NONNULL_PTR msg); + LDKnativeLockedChannelMonitor *inner; /** - * Handle an incoming update_add_htlc message from the given peer. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - void (*handle_update_add_htlc)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKUpdateAddHTLC *NONNULL_PTR msg); + bool is_owned; +} LDKLockedChannelMonitor; + +/** + * The contents of CResult_LockedChannelMonitorNoneZ + */ +typedef union LDKCResult_LockedChannelMonitorNoneZPtr { /** - * Handle an incoming update_fulfill_htlc message from the given peer. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - void (*handle_update_fulfill_htlc)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKUpdateFulfillHTLC *NONNULL_PTR msg); + struct LDKLockedChannelMonitor *result; /** - * Handle an incoming update_fail_htlc message from the given peer. + * Note that this value is always NULL, as there are no contents in the Err variant */ - void (*handle_update_fail_htlc)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKUpdateFailHTLC *NONNULL_PTR msg); + void *err; +} LDKCResult_LockedChannelMonitorNoneZPtr; + +/** + * A CResult_LockedChannelMonitorNoneZ represents the result of a fallible operation, + * containing a crate::lightning::chain::chainmonitor::LockedChannelMonitor on success and a () on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_LockedChannelMonitorNoneZ { /** - * Handle an incoming update_fail_malformed_htlc message from the given peer. + * The contents of this CResult_LockedChannelMonitorNoneZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - void (*handle_update_fail_malformed_htlc)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR msg); + union LDKCResult_LockedChannelMonitorNoneZPtr contents; /** - * Handle an incoming commitment_signed message from the given peer. + * Whether this CResult_LockedChannelMonitorNoneZ represents a success state. */ - void (*handle_commitment_signed)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKCommitmentSigned *NONNULL_PTR msg); + bool result_ok; +} LDKCResult_LockedChannelMonitorNoneZ; + +/** + * A dynamically-allocated array of crate::lightning::chain::transaction::OutPoints of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_OutPointZ { /** - * Handle an incoming revoke_and_ack message from the given peer. + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - void (*handle_revoke_and_ack)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKRevokeAndACK *NONNULL_PTR msg); + struct LDKOutPoint *data; /** - * Handle an incoming update_fee message from the given peer. + * The number of elements pointed to by `data`. */ - void (*handle_update_fee)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKUpdateFee *NONNULL_PTR msg); + uintptr_t datalen; +} LDKCVec_OutPointZ; + +/** + * A trait indicating an object may generate message send events + */ +typedef struct LDKMessageSendEventsProvider { /** - * Handle an incoming announcement_signatures message from the given peer. + * 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 (*handle_announcement_signatures)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKAnnouncementSignatures *NONNULL_PTR msg); + void *this_arg; /** - * Indicates a connection to the peer failed/an existing connection was lost. If no connection - * is believed to be possible in the future (eg they're sending us messages we don't - * understand or indicate they require unknown feature bits), no_connection_possible is set - * and any outstanding channels should be failed. + * Gets the list of pending events which were generated by previous actions, clearing the list + * in the process. */ - void (*peer_disconnected)(const void *this_arg, struct LDKPublicKey their_node_id, bool no_connection_possible); + struct LDKCVec_MessageSendEventZ (*get_and_clear_pending_msg_events)(const void *this_arg); /** - * Handle a peer reconnecting, possibly generating channel_reestablish message(s). + * 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 (*peer_connected)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKInit *NONNULL_PTR msg); + void (*free)(void *this_arg); +} LDKMessageSendEventsProvider; + +/** + * A trait indicating an object may generate onion messages to send + */ +typedef struct LDKOnionMessageProvider { /** - * Handle an incoming channel_reestablish message from the given peer. + * 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 (*handle_channel_reestablish)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKChannelReestablish *NONNULL_PTR msg); + void *this_arg; /** - * Handle an incoming channel update from the given peer. + * Gets the next pending onion message for the peer with the given node id. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ - void (*handle_channel_update)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKChannelUpdate *NONNULL_PTR msg); + struct LDKOnionMessage (*next_onion_message_for_peer)(const void *this_arg, struct LDKPublicKey peer_node_id); /** - * Handle an incoming error message from the given peer. + * 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 (*handle_error)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKErrorMessage *NONNULL_PTR msg); + void (*free)(void *this_arg); +} LDKOnionMessageProvider; + +/** + * A trait implemented for objects handling events from [`EventsProvider`]. + */ +typedef struct LDKEventHandler { /** - * Implementation of MessageSendEventsProvider for this object. + * 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 LDKMessageSendEventsProvider MessageSendEventsProvider; + void *this_arg; + /** + * Handles the given [`Event`]. + * + * See [`EventsProvider`] for details that must be considered when implementing this method. + */ + void (*handle_event)(const void *this_arg, const struct LDKEvent *NONNULL_PTR event); /** * Frees any resources associated with this object given its this_arg pointer. * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. */ void (*free)(void *this_arg); -} LDKChannelMessageHandler; - - +} LDKEventHandler; /** - * Arguments for the creation of a ChannelManager that are not deserialized. + * A trait indicating an object may generate events. * - * At a high-level, the process for deserializing a ChannelManager and resuming normal operation - * is: - * 1) Deserialize all stored [`ChannelMonitor`]s. - * 2) Deserialize the [`ChannelManager`] by filling in this struct and calling: - * `<(BlockHash, ChannelManager)>::read(reader, args)` - * This may result in closing some channels if the [`ChannelMonitor`] is newer than the stored - * [`ChannelManager`] state to ensure no loss of funds. Thus, transactions may be broadcasted. - * 3) If you are not fetching full blocks, register all relevant [`ChannelMonitor`] outpoints the - * same way you would handle a [`chain::Filter`] call using - * [`ChannelMonitor::get_outputs_to_watch`] and [`ChannelMonitor::get_funding_txo`]. - * 4) Reconnect blocks on your [`ChannelMonitor`]s. - * 5) Disconnect/connect blocks on the [`ChannelManager`]. - * 6) Re-persist the [`ChannelMonitor`]s to ensure the latest state is on disk. - * Note that if you're using a [`ChainMonitor`] for your [`chain::Watch`] implementation, you - * will likely accomplish this as a side-effect of calling [`chain::Watch::watch_channel`] in - * the next step. - * 7) Move the [`ChannelMonitor`]s into your local [`chain::Watch`]. If you're using a - * [`ChainMonitor`], this is done by calling [`chain::Watch::watch_channel`]. + * Events are processed by passing an [`EventHandler`] to [`process_pending_events`]. * - * Note that the ordering of #4-7 is not of importance, however all four must occur before you - * call any other methods on the newly-deserialized [`ChannelManager`]. + * # Requirements * - * Note that because some channels may be closed during deserialization, it is critical that you - * always deserialize only the latest version of a ChannelManager and ChannelMonitors available to - * you. If you deserialize an old ChannelManager (during which force-closure transactions may be - * broadcast), and then later deserialize a newer version of the same ChannelManager (which will - * not force-close the same channels but consider them live), you may end up revoking a state for - * which you've already broadcasted the transaction. + * When using this trait, [`process_pending_events`] will call [`handle_event`] for each pending + * event since the last invocation. * - * [`ChainMonitor`]: crate::chain::chainmonitor::ChainMonitor + * In order to ensure no [`Event`]s are lost, implementors of this trait will persist [`Event`]s + * and replay any unhandled events on startup. An [`Event`] is considered handled when + * [`process_pending_events`] returns, thus handlers MUST fully handle [`Event`]s and persist any + * relevant changes to disk *before* returning. + * + * Further, because an application may crash between an [`Event`] being handled and the + * implementor of this trait being re-serialized, [`Event`] handling must be idempotent - in + * effect, [`Event`]s may be replayed. + * + * Note, handlers may call back into the provider and thus deadlocking must be avoided. Be sure to + * consult the provider's documentation on the implication of processing events and how a handler + * may safely use the provider (e.g., see [`ChannelManager::process_pending_events`] and + * [`ChainMonitor::process_pending_events`]). + * + * (C-not implementable) As there is likely no reason for a user to implement this trait on their + * own type(s). + * + * [`process_pending_events`]: Self::process_pending_events + * [`handle_event`]: EventHandler::handle_event + * [`ChannelManager::process_pending_events`]: crate::ln::channelmanager::ChannelManager#method.process_pending_events + * [`ChainMonitor::process_pending_events`]: crate::chain::chainmonitor::ChainMonitor#method.process_pending_events */ -typedef struct MUST_USE_STRUCT LDKChannelManagerReadArgs { +typedef struct LDKEventsProvider { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, 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. */ - LDKnativeChannelManagerReadArgs *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. + * Processes any events generated since the last call using the given event handler. + * + * See the trait-level documentation for requirements. */ - bool is_owned; -} LDKChannelManagerReadArgs; + void (*process_pending_events)(const void *this_arg, struct LDKEventHandler handler); + /** + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + */ + void (*free)(void *this_arg); +} LDKEventsProvider; /** - * Proof that the sender knows the per-commitment secret of the previous commitment transaction. - * This is used to convince the recipient that the channel is at a certain commitment - * number even if they lost that data due to a local failure. Of course, the peer may lie - * and even later commitments may have been revoked. + * Lightning TLV uses a custom variable-length integer called BigSize. It is similar to Bitcoin's + * variable-length integers except that it is serialized in big-endian instead of little-endian. + * + * Like Bitcoin's variable-length integer, it exhibits ambiguity in that certain values can be + * encoded in several different ways, which we must check for at deserialization-time. Thus, if + * you're looking for an example of a variable-length integer to use for your own project, move + * along, this is a rather poor design. */ -typedef struct MUST_USE_STRUCT LDKDataLossProtect { +typedef struct MUST_USE_STRUCT LDKBigSize { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeDataLossProtect *inner; + LDKnativeBigSize *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; -} LDKDataLossProtect; +} LDKBigSize; /** - * A trait to describe an object which can receive routing messages. - * - * # Implementor DoS Warnings - * - * For `gossip_queries` messages there are potential DoS vectors when handling - * inbound queries. Implementors using an on-disk network graph should be aware of - * repeated disk I/O for queries accessing different parts of the network graph. + * Trait that handles persisting a [`ChannelManager`], [`NetworkGraph`], and [`WriteableScore`] to disk. */ -typedef struct LDKRoutingMessageHandler { +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. */ void *this_arg; /** - * Handle an incoming node_announcement message, returning true if it should be forwarded on, - * false or returning an Err otherwise. - */ - struct LDKCResult_boolLightningErrorZ (*handle_node_announcement)(const void *this_arg, const struct LDKNodeAnnouncement *NONNULL_PTR msg); - /** - * Handle a channel_announcement message, returning true if it should be forwarded on, false - * or returning an Err otherwise. - */ - struct LDKCResult_boolLightningErrorZ (*handle_channel_announcement)(const void *this_arg, const struct LDKChannelAnnouncement *NONNULL_PTR msg); - /** - * Handle an incoming channel_update message, returning true if it should be forwarded on, - * false or returning an Err otherwise. - */ - struct LDKCResult_boolLightningErrorZ (*handle_channel_update)(const void *this_arg, const struct LDKChannelUpdate *NONNULL_PTR msg); - /** - * Gets a subset of the channel announcements and updates required to dump our routing table - * to a remote node, starting at the short_channel_id indicated by starting_point and - * including the batch_amount entries immediately higher in numerical value than starting_point. - */ - struct LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ (*get_next_channel_announcements)(const void *this_arg, uint64_t starting_point, uint8_t batch_amount); - /** - * Gets a subset of the node announcements required to dump our routing table to a remote node, - * starting at the node *after* the provided publickey and including batch_amount entries - * immediately higher (as defined by ::cmp) than starting_point. - * If None is provided for starting_point, we start at the first node. - * - * Note that starting_point (or a relevant inner pointer) may be NULL or all-0s to represent None - */ - struct LDKCVec_NodeAnnouncementZ (*get_next_node_announcements)(const void *this_arg, struct LDKPublicKey starting_point, uint8_t batch_amount); - /** - * Called when a connection is established with a peer. This can be used to - * 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); - /** - * Handles the reply of a query we initiated to learn about channels - * for a given range of blocks. We can expect to receive one or more - * replies to a single query. - */ - struct LDKCResult_NoneLightningErrorZ (*handle_reply_channel_range)(const void *this_arg, struct LDKPublicKey their_node_id, struct LDKReplyChannelRange msg); - /** - * Handles the reply of a query we initiated asking for routing gossip - * messages for a list of channels. We should receive this message when - * a node has completed its best effort to send us the pertaining routing - * gossip messages. - */ - struct LDKCResult_NoneLightningErrorZ (*handle_reply_short_channel_ids_end)(const void *this_arg, struct LDKPublicKey their_node_id, struct LDKReplyShortChannelIdsEnd msg); - /** - * Handles when a peer asks us to send a list of short_channel_ids - * for the requested range of blocks. + * Persist the given ['ChannelManager'] to disk, returning an error if persistence failed. */ - struct LDKCResult_NoneLightningErrorZ (*handle_query_channel_range)(const void *this_arg, struct LDKPublicKey their_node_id, struct LDKQueryChannelRange msg); + struct LDKCResult_NoneErrorZ (*persist_manager)(const void *this_arg, const struct LDKChannelManager *NONNULL_PTR channel_manager); /** - * Handles when a peer asks us to send routing gossip messages for a - * list of short_channel_ids. + * Persist the given [`NetworkGraph`] to disk, returning an error if persistence failed. */ - struct LDKCResult_NoneLightningErrorZ (*handle_query_short_channel_ids)(const void *this_arg, struct LDKPublicKey their_node_id, struct LDKQueryShortChannelIds msg); + struct LDKCResult_NoneErrorZ (*persist_graph)(const void *this_arg, const struct LDKNetworkGraph *NONNULL_PTR network_graph); /** - * Implementation of MessageSendEventsProvider for this object. + * Persist the given [`WriteableScore`] to disk, returning an error if persistence failed. */ - struct LDKMessageSendEventsProvider MessageSendEventsProvider; + struct LDKCResult_NoneErrorZ (*persist_scorer)(const void *this_arg, const struct LDKWriteableScore *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. */ void (*free)(void *this_arg); -} LDKRoutingMessageHandler; +} LDKPersister; /** - * Trait to be implemented by custom message (unrelated to the channel/gossip LN layers) - * decoders. + * A callback which is called when a [`Future`] completes. + * + * Note that this MUST NOT call back into LDK directly, it must instead schedule actions to be + * taken later. Rust users should use the [`std::future::Future`] implementation for [`Future`] + * instead. + * + * Note that the [`std::future::Future`] implementation may only work for runtimes which schedule + * futures when they receive a wake, rather than immediately executing them. */ -typedef struct LDKCustomMessageReader { +typedef struct LDKFutureCallback { /** * 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; /** - * Decodes a custom message to `CustomMessageType`. If the given message type is known to the - * implementation and the message could be decoded, must return `Ok(Some(message))`. If the - * message type is unknown to the implementation, must return `Ok(None)`. If a decoding error - * occur, must return `Err(DecodeError::X)` where `X` details the encountered error. + * The method which is called. */ - struct LDKCResult_COption_TypeZDecodeErrorZ (*read)(const void *this_arg, uint16_t message_type, struct LDKu8slice buffer); + void (*call)(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); -} LDKCustomMessageReader; +} LDKFutureCallback; + + /** - * Handler for BOLT1-compliant messages. + * A simple future which can complete once, and calls some callback(s) when it does so. */ -typedef struct LDKCustomMessageHandler { - /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. - */ - void *this_arg; +typedef struct MUST_USE_STRUCT LDKFuture { /** - * Called with the message type that was received and the buffer to be read. - * Can return a `MessageHandlingError` if the message could not be handled. + * A pointer to the opaque Rust object. + * Nearly everywhere, 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 LDKCResult_NoneLightningErrorZ (*handle_custom_message)(const void *this_arg, struct LDKType msg, struct LDKPublicKey sender_node_id); + LDKnativeFuture *inner; /** - * Gets the list of pending messages which were generated by the custom message - * handler, clearing the list in the process. The first tuple element must - * correspond to the intended recipients node ids. If no connection to one of the - * specified node does not exist, the message is simply not sent to it. + * Indicates that this is the only struct which contains the same pointer. + * Rust 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_PublicKeyTypeZZ (*get_and_clear_pending_msg)(const void *this_arg); + bool is_owned; +} LDKFuture; + + + +/** + * Configuration we set when applicable. + * + * Default::default() provides sane defaults. + */ +typedef struct MUST_USE_STRUCT LDKChannelHandshakeConfig { /** - * Implementation of CustomMessageReader for this object. + * A pointer to the opaque Rust object. + * Nearly everywhere, 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 LDKCustomMessageReader CustomMessageReader; + LDKnativeChannelHandshakeConfig *inner; /** - * Frees any resources associated with this object given its this_arg pointer. - * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - void (*free)(void *this_arg); -} LDKCustomMessageHandler; + bool is_owned; +} LDKChannelHandshakeConfig; /** - * A dummy struct which implements `RoutingMessageHandler` without storing any routing information - * or doing any processing. You can provide one of these as the route_handler in a MessageHandler. + * Optional channel limits which are applied during channel creation. + * + * These limits are only applied to our counterparty's limits, not our own. + * + * Use 0/::max_value() as appropriate to skip checking. + * + * Provides sane defaults for most configurations. + * + * Most additional limits are disabled except those with which specify a default in individual + * field documentation. Note that this may result in barely-usable channels, but since they + * are applied mostly only to incoming channels that's not much of a problem. */ -typedef struct MUST_USE_STRUCT LDKIgnoringMessageHandler { +typedef struct MUST_USE_STRUCT LDKChannelHandshakeLimits { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeIgnoringMessageHandler *inner; + LDKnativeChannelHandshakeLimits *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; -} LDKIgnoringMessageHandler; +} LDKChannelHandshakeLimits; /** - * A dummy struct which implements `ChannelMessageHandler` without having any channels. - * You can provide one of these as the route_handler in a MessageHandler. + * Top-level config which holds ChannelHandshakeLimits and ChannelConfig. + * + * Default::default() provides sane defaults for most configurations + * (but currently with 0 relay fees!) */ -typedef struct MUST_USE_STRUCT LDKErroringMessageHandler { +typedef struct MUST_USE_STRUCT LDKUserConfig { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeErroringMessageHandler *inner; + LDKnativeUserConfig *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; -} LDKErroringMessageHandler; +} LDKUserConfig; /** - * Provides references to trait impls which handle different types of messages. + * The best known block as identified by its hash and height. */ -typedef struct MUST_USE_STRUCT LDKMessageHandler { +typedef struct MUST_USE_STRUCT LDKBestBlock { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeMessageHandler *inner; + LDKnativeBestBlock *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; -} LDKMessageHandler; +} LDKBestBlock; /** - * Provides an object which can be used to send data to and which uniquely identifies a connection - * to a remote host. You will need to be able to generate multiple of these which meet Eq and - * implement Hash to meet the PeerManager API. + * The `Listen` trait is used to notify when blocks have been connected or disconnected from the + * chain. * - * For efficiency, Clone should be relatively cheap for this type. + * Useful when needing to replay chain data upon startup or as new chain events occur. Clients + * sourcing chain data using a block-oriented API should prefer this interface over [`Confirm`]. + * Such clients fetch the entire header chain whereas clients using [`Confirm`] only fetch headers + * when needed. * - * Two descriptors may compare equal (by [`cmp::Eq`] and [`hash::Hash`]) as long as the original - * has been disconnected, the [`PeerManager`] has been informed of the disconnection (either by it - * having triggered the disconnection or a call to [`PeerManager::socket_disconnected`]), and no - * further calls to the [`PeerManager`] related to the original socket occur. This allows you to - * use a file descriptor for your SocketDescriptor directly, however for simplicity you may wish - * to simply use another value which is guaranteed to be globally unique instead. + * By using [`Listen::filtered_block_connected`] this interface supports clients fetching the + * entire header chain and only blocks with matching transaction data using BIP 157 filters or + * other similar filtering. */ -typedef struct LDKSocketDescriptor { +typedef struct LDKListen { /** * 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; /** - * Attempts to send some data from the given slice to the peer. - * - * Returns the amount of data which was sent, possibly 0 if the socket has since disconnected. - * Note that in the disconnected case, [`PeerManager::socket_disconnected`] must still be - * called and further write attempts may occur until that time. - * - * If the returned size is smaller than `data.len()`, a - * [`PeerManager::write_buffer_space_avail`] call must be made the next time more data can be - * written. Additionally, until a `send_data` event completes fully, no further - * [`PeerManager::read_event`] calls should be made for the same peer! Because this is to - * prevent denial-of-service issues, you should not read or buffer any data from the socket - * until then. - * - * If a [`PeerManager::read_event`] call on this descriptor had previously returned true - * (indicating that read events should be paused to prevent DoS in the send buffer), - * `resume_read` may be set indicating that read events on this descriptor should resume. A - * `resume_read` of false carries no meaning, and should not cause any action. - */ - uintptr_t (*send_data)(void *this_arg, struct LDKu8slice data, bool resume_read); - /** - * Disconnect the socket pointed to by this SocketDescriptor. - * - * You do *not* need to call [`PeerManager::socket_disconnected`] with this socket after this - * call (doing so is a noop). - */ - void (*disconnect_socket)(void *this_arg); - /** - * Checks if two objects are equal given this object's this_arg pointer and another object. + * Notifies the listener that a block was added at the given height, with the transaction data + * possibly filtered. */ - bool (*eq)(const void *this_arg, const struct LDKSocketDescriptor *NONNULL_PTR other_arg); + void (*filtered_block_connected)(const void *this_arg, const uint8_t (*header)[80], struct LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height); /** - * Calculate a succinct non-cryptographic hash for an object given its this_arg pointer. - * This is used, for example, for inclusion of this object in a hash map. + * Notifies the listener that a block was added at the given height. */ - uint64_t (*hash)(const void *this_arg); + void (*block_connected)(const void *this_arg, struct LDKu8slice block, uint32_t height); /** - * Called, if set, after this SocketDescriptor has been cloned into a duplicate object. - * The new SocketDescriptor is provided, and should be mutated as needed to perform a - * deep copy of the object pointed to by this_arg or avoid any double-freeing. + * Notifies the listener that a block was removed at the given height. */ - void (*cloned)(struct LDKSocketDescriptor *NONNULL_PTR new_SocketDescriptor); + void (*block_disconnected)(const void *this_arg, const uint8_t (*header)[80], uint32_t height); /** * 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); -} LDKSocketDescriptor; - - +} LDKListen; /** - * A PeerManager manages a set of peers, described by their [`SocketDescriptor`] and marshalls - * socket events into messages which it passes on to its [`MessageHandler`]. + * The `Confirm` trait is used to notify when transactions have been confirmed on chain or + * unconfirmed during a chain reorganization. * - * Locks are taken internally, so you must never assume that reentrancy from a - * [`SocketDescriptor`] call back into [`PeerManager`] methods will not deadlock. + * Clients sourcing chain data using a transaction-oriented API should prefer this interface over + * [`Listen`]. For instance, an Electrum client may implement [`Filter`] by subscribing to activity + * related to registered transactions and outputs. Upon notification, it would pass along the + * matching transactions using this interface. * - * Calls to [`read_event`] will decode relevant messages and pass them to the - * [`ChannelMessageHandler`], likely doing message processing in-line. Thus, the primary form of - * parallelism in Rust-Lightning is in calls to [`read_event`]. Note, however, that calls to any - * [`PeerManager`] functions related to the same connection must occur only in serial, making new - * calls only after previous ones have returned. + * # Use * - * Rather than using a plain PeerManager, it is preferable to use either a SimpleArcPeerManager - * a SimpleRefPeerManager, for conciseness. See their documentation for more details, but - * essentially you should default to using a SimpleRefPeerManager, and use a - * SimpleArcPeerManager when you require a PeerManager with a static lifetime, such as when - * you're using lightning-net-tokio. + * The intended use is as follows: + * - Call [`transactions_confirmed`] to process any on-chain activity of interest. + * - Call [`transaction_unconfirmed`] to process any transaction returned by [`get_relevant_txids`] + * that has been reorganized out of the chain. + * - Call [`best_block_updated`] whenever a new chain tip becomes available. * - * [`read_event`]: PeerManager::read_event - */ -typedef struct MUST_USE_STRUCT LDKPeerManager { - /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. - */ - LDKnativePeerManager *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; -} LDKPeerManager; - - - -/** - * Static channel fields used to build transactions given per-commitment fields, organized by - * broadcaster/countersignatory. + * # Order * - * This is derived from the holder/counterparty-organized ChannelTransactionParameters via the - * as_holder_broadcastable and as_counterparty_broadcastable functions. + * Clients must call these methods in chain order. Specifically: + * - Transactions confirmed in a block must be given before transactions confirmed in a later + * block. + * - Dependent transactions within the same block must be given in topological order, possibly in + * separate calls. + * - Unconfirmed transactions must be given after the original confirmations and before any + * reconfirmation. + * + * See individual method documentation for further details. + * + * [`transactions_confirmed`]: Self::transactions_confirmed + * [`transaction_unconfirmed`]: Self::transaction_unconfirmed + * [`best_block_updated`]: Self::best_block_updated + * [`get_relevant_txids`]: Self::get_relevant_txids */ -typedef struct MUST_USE_STRUCT LDKDirectedChannelTransactionParameters { +typedef struct LDKConfirm { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, 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. */ - LDKnativeDirectedChannelTransactionParameters *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. + * Processes transactions confirmed in a block with a given header and height. + * + * Should be called for any transactions registered by [`Filter::register_tx`] or any + * transactions spending an output registered by [`Filter::register_output`]. Such transactions + * appearing in the same block do not need to be included in the same call; instead, multiple + * calls with additional transactions may be made so long as they are made in [chain order]. + * + * May be called before or after [`best_block_updated`] for the corresponding block. However, + * in the event of a chain reorganization, it must not be called with a `header` that is no + * longer in the chain as of the last call to [`best_block_updated`]. + * + * [chain order]: Confirm#order + * [`best_block_updated`]: Self::best_block_updated */ - bool is_owned; -} LDKDirectedChannelTransactionParameters; - - - -/** - * A read-only view of [`NetworkGraph`]. - */ -typedef struct MUST_USE_STRUCT LDKReadOnlyNetworkGraph { + void (*transactions_confirmed)(const void *this_arg, const uint8_t (*header)[80], struct LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height); /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * Processes a transaction that is no longer confirmed as result of a chain reorganization. + * + * Should be called for any transaction returned by [`get_relevant_txids`] if it has been + * reorganized out of the best chain. Once called, the given transaction will not be returned + * by [`get_relevant_txids`], unless it has been reconfirmed via [`transactions_confirmed`]. + * + * [`get_relevant_txids`]: Self::get_relevant_txids + * [`transactions_confirmed`]: Self::transactions_confirmed */ - LDKnativeReadOnlyNetworkGraph *inner; + void (*transaction_unconfirmed)(const void *this_arg, const uint8_t (*txid)[32]); /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * Processes an update to the best header connected at the given height. + * + * Should be called when a new header is available but may be skipped for intermediary blocks + * if they become available at the same time. */ - 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 { + void (*best_block_updated)(const void *this_arg, const uint8_t (*header)[80], uint32_t height); /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * Returns transactions that should be monitored for reorganization out of the chain. + * + * Will include any transactions passed to [`transactions_confirmed`] that have insufficient + * confirmations to be safe from a chain reorganization. Will not include any transactions + * passed to [`transaction_unconfirmed`], unless later reconfirmed. + * + * May be called to determine the subset of transactions that must still be monitored for + * reorganization. Will be idempotent between calls but may change as a result of calls to the + * other interface methods. Thus, this is useful to determine which transactions may need to be + * given to [`transaction_unconfirmed`]. + * + * [`transactions_confirmed`]: Self::transactions_confirmed + * [`transaction_unconfirmed`]: Self::transaction_unconfirmed */ - LDKnativeNetGraphMsgHandler *inner; + struct LDKCVec_TxidZ (*get_relevant_txids)(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; -} LDKNetGraphMsgHandler; + void (*free)(void *this_arg); +} LDKConfirm; /** - * A wrapper around [`ChannelInfo`] representing information about the channel as directed from a - * source node to a target node. + * An opaque identifier describing a specific [`Persist`] method call. */ -typedef struct MUST_USE_STRUCT LDKDirectedChannelInfo { +typedef struct MUST_USE_STRUCT LDKMonitorUpdateId { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeDirectedChannelInfo *inner; + LDKnativeMonitorUpdateId *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKDirectedChannelInfo; +} LDKMonitorUpdateId; /** - * The effective capacity of a channel for routing purposes. + * `Persist` defines behavior for persisting channel monitors: this could mean + * writing once to disk, and/or uploading to one or more backup services. * - * While this may be smaller than the actual channel capacity, amounts greater than - * [`Self::as_msat`] should not be routed through the channel. + * Each method can return three possible values: + * * If persistence (including any relevant `fsync()` calls) happens immediately, the + * implementation should return [`ChannelMonitorUpdateStatus::Completed`], indicating normal + * channel operation should continue. + * * If persistence happens asynchronously, implementations should first ensure the + * [`ChannelMonitor`] or [`ChannelMonitorUpdate`] are written durably to disk, and then return + * [`ChannelMonitorUpdateStatus::InProgress`] while the update continues in the background. + * Once the update completes, [`ChainMonitor::channel_monitor_updated`] should be called with + * the corresponding [`MonitorUpdateId`]. + * + * Note that unlike the direct [`chain::Watch`] interface, + * [`ChainMonitor::channel_monitor_updated`] must be called once for *each* update which occurs. + * + * * If persistence fails for some reason, implementations should return + * [`ChannelMonitorUpdateStatus::PermanentFailure`], in which case the channel will likely be + * closed without broadcasting the latest state. See + * [`ChannelMonitorUpdateStatus::PermanentFailure`] for more details. */ -typedef enum LDKEffectiveCapacity_Tag { - /** - * The available liquidity in the channel known from being a channel counterparty, and thus a - * direct hop. - */ - LDKEffectiveCapacity_ExactLiquidity, +typedef struct LDKPersist { /** - * The maximum HTLC amount in one direction as advertised on the gossip network. + * 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. */ - LDKEffectiveCapacity_MaximumHTLC, + void *this_arg; /** - * 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. - * - *\tScoring is in terms of fees willing to be paid in order to avoid routing through a channel. - */ -typedef struct LDKScore { - /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. - */ - void *this_arg; - /** - * Returns the fee in msats willing to be paid to avoid routing `send_amt_msat` through the - * given channel in the direction from `source` to `target`. + * Persist a new channel's data in response to a [`chain::Watch::watch_channel`] call. This is + * called by [`ChannelManager`] for new channels, or may be called directly, e.g. on startup. * - * The channel's capacity (less any other MPP parts that are also being considered for use in - * the same payment) is given by `capacity_msat`. It may be determined from various sources - * such as a chain data, network gossip, or invoice hints. For invoice hints, a capacity near - * [`u64::max_value`] is given to indicate sufficient capacity for the invoice's full amount. - * Thus, implementations should be overflow-safe. - */ - uint64_t (*channel_penalty_msat)(const void *this_arg, uint64_t short_channel_id, uint64_t send_amt_msat, 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. + * The data can be stored any way you want, but the identifier provided by LDK is the + * channel's outpoint (and it is up to you to maintain a correct mapping between the outpoint + * and the stored channel data). Note that you **must** persist every new monitor to disk. + * + * The `update_id` is used to identify this call to [`ChainMonitor::channel_monitor_updated`], + * if you return [`ChannelMonitorUpdateStatus::InProgress`]. + * + * See [`Writeable::write`] on [`ChannelMonitor`] for writing out a `ChannelMonitor` + * and [`ChannelMonitorUpdateStatus`] for requirements when returning errors. + * + * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager + * [`Writeable::write`]: crate::util::ser::Writeable::write */ - void (*payment_path_successful)(void *this_arg, struct LDKCVec_RouteHopZ path); + enum LDKChannelMonitorUpdateStatus (*persist_new_channel)(const void *this_arg, struct LDKOutPoint channel_id, const struct LDKChannelMonitor *NONNULL_PTR data, struct LDKMonitorUpdateId update_id); /** - * Serialize the object into a byte array + * Update one channel's data. The provided [`ChannelMonitor`] has already applied the given + * update. + * + * Note that on every update, you **must** persist either the [`ChannelMonitorUpdate`] or the + * updated monitor itself to disk/backups. See the [`Persist`] trait documentation for more + * details. + * + * During blockchain synchronization operations, this may be called with no + * [`ChannelMonitorUpdate`], in which case the full [`ChannelMonitor`] needs to be persisted. + * Note that after the full [`ChannelMonitor`] is persisted any previous + * [`ChannelMonitorUpdate`]s which were persisted should be discarded - they can no longer be + * applied to the persisted [`ChannelMonitor`] as they were already applied. + * + * If an implementer chooses to persist the updates only, they need to make + * sure that all the updates are applied to the `ChannelMonitors` *before* + * the set of channel monitors is given to the `ChannelManager` + * deserialization routine. See [`ChannelMonitor::update_monitor`] for + * applying a monitor update to a monitor. If full `ChannelMonitors` are + * persisted, then there is no need to persist individual updates. + * + * Note that there could be a performance tradeoff between persisting complete + * channel monitors on every update vs. persisting only updates and applying + * them in batches. The size of each monitor grows `O(number of state updates)` + * whereas updates are small and `O(1)`. + * + * The `update_id` is used to identify this call to [`ChainMonitor::channel_monitor_updated`], + * if you return [`ChannelMonitorUpdateStatus::InProgress`]. + * + * See [`Writeable::write`] on [`ChannelMonitor`] for writing out a `ChannelMonitor`, + * [`Writeable::write`] on [`ChannelMonitorUpdate`] for writing out an update, and + * [`ChannelMonitorUpdateStatus`] for requirements when returning errors. + * + * [`Writeable::write`]: crate::util::ser::Writeable::write + * + * Note that update (or a relevant inner pointer) may be NULL or all-0s to represent None */ - struct LDKCVec_u8Z (*write)(const void *this_arg); + enum LDKChannelMonitorUpdateStatus (*update_persisted_channel)(const void *this_arg, struct LDKOutPoint channel_id, const struct LDKChannelMonitorUpdate *NONNULL_PTR update, const struct LDKChannelMonitor *NONNULL_PTR data, struct LDKMonitorUpdateId update_id); /** * Frees any resources associated with this object given its this_arg pointer. * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. */ void (*free)(void *this_arg); -} LDKScore; +} LDKPersist; + + /** - * A scorer that is accessed under a lock. + * An implementation of [`chain::Watch`] for monitoring channels. * - * Needed so that calls to [`Score::channel_penalty_msat`] in [`find_route`] can be made while - * having shared ownership of a scorer but without requiring internal locking in [`Score`] - * implementations. Internal locking would be detrimental to route finding performance and could - * result in [`Score::channel_penalty_msat`] returning a different value for the same channel. + * Connected and disconnected blocks must be provided to `ChainMonitor` as documented by + * [`chain::Watch`]. May be used in conjunction with [`ChannelManager`] to monitor channels locally + * or used independently to monitor channels remotely. See the [module-level documentation] for + * details. * - * [`find_route`]: crate::routing::router::find_route + * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager + * [module-level documentation]: crate::chain::chainmonitor */ -typedef struct LDKLockableScore { - /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. - */ - void *this_arg; +typedef struct MUST_USE_STRUCT LDKChainMonitor { /** - * Returns the locked scorer. + * A pointer to the opaque Rust object. + * Nearly everywhere, 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 LDKScore (*lock)(const void *this_arg); + LDKnativeChainMonitor *inner; /** - * Frees any resources associated with this object given its this_arg pointer. - * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - void (*free)(void *this_arg); -} LDKLockableScore; + bool is_owned; +} LDKChainMonitor; /** - * A concrete implementation of [`LockableScore`] which supports multi-threading. + * Simple KeysInterface implementor that takes a 32-byte seed for use as a BIP 32 extended key + * and derives keys from that. + * + * Your node_id is seed/0' + * ChannelMonitor closes may use seed/1' + * Cooperative closes may use seed/2' + * The two close keys may be needed to claim on-chain funds! + * + * This struct cannot be used for nodes that wish to support receiving phantom payments; + * [`PhantomKeysManager`] must be used instead. + * + * Note that switching between this struct and [`PhantomKeysManager`] will invalidate any + * previously issued invoices and attempts to pay previous invoices will fail. */ -typedef struct MUST_USE_STRUCT LDKMultiThreadedLockableScore { +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. */ - LDKnativeMultiThreadedLockableScore *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; -} LDKMultiThreadedLockableScore; +} LDKKeysManager; /** - * FilesystemPersister persists channel data on disk, where each channel's - * data is stored in a file named after its funding outpoint. + * Similar to [`KeysManager`], but allows the node using this struct to receive phantom node + * payments. * - * Warning: this module does the best it can with calls to persist data, but it - * can only guarantee that the data is passed to the drive. It is up to the - * drive manufacturers to do the actual persistence properly, which they often - * don't (especially on consumer-grade hardware). Therefore, it is up to the - * user to validate their entire storage stack, to ensure the writes are - * persistent. - * Corollary: especially when dealing with larger amounts of money, it is best - * practice to have multiple channel data backups and not rely only on one - * FilesystemPersister. + * 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 LDKFilesystemPersister { +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. */ - LDKnativeFilesystemPersister *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; -} LDKFilesystemPersister; +} LDKPhantomKeysManager; /** - * `BackgroundProcessor` takes care of tasks that (1) need to happen periodically to keep - * Rust-Lightning running properly, and (2) either can or should be run in the background. Its - * responsibilities are: - * * Processing [`Event`]s with a user-provided [`EventHandler`]. - * * Monitoring whether the [`ChannelManager`] needs to be re-persisted to disk, and if so, - * writing it to disk/backups by invoking the callback given to it at startup. - * [`ChannelManager`] persistence should be done in the background. - * * Calling [`ChannelManager::timer_tick_occurred`] 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. - * - * # Note - * - * If [`ChannelManager`] persistence fails and the persisted manager becomes out-of-date, then - * there is a risk of channels force-closing on startup when the manager realizes it's outdated. - * However, as long as [`ChannelMonitor`] backups are sound, no funds besides those used for - * unilateral chain closure fees are at risk. + * Chain-related parameters used to construct a new `ChannelManager`. * - * [`ChannelMonitor`]: lightning::chain::channelmonitor::ChannelMonitor - * [`Event`]: lightning::util::events::Event - *BackgroundProcessor will immediately stop on drop. It should be stored until shutdown. + * 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 LDKBackgroundProcessor { +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. */ - LDKnativeBackgroundProcessor *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; -} LDKBackgroundProcessor; +} LDKChainParameters; /** - * Trait which handles persisting a [`ChannelManager`] to disk. + * A trait to describe an object which can receive channel messages. * - * [`ChannelManager`]: lightning::ln::channelmanager::ChannelManager + * Messages MAY be called in parallel when they originate from different their_node_ids, however + * they MUST NOT be called in parallel when the two calls have the same their_node_id. */ -typedef struct LDKChannelManagerPersister { +typedef struct LDKChannelMessageHandler { /** * 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; /** - * 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 + * Handle an incoming open_channel message from the given peer. */ - struct LDKCResult_NoneErrorZ (*persist_manager)(const void *this_arg, const struct LDKChannelManager *NONNULL_PTR channel_manager); + void (*handle_open_channel)(const void *this_arg, struct LDKPublicKey their_node_id, struct LDKInitFeatures their_features, const struct LDKOpenChannel *NONNULL_PTR msg); /** - * 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. + * Handle an incoming accept_channel message from the given peer. */ - void (*free)(void *this_arg); -} LDKChannelManagerPersister; - - - -/** - * Data of the `RawInvoice` that is encoded in the data part - */ -typedef struct MUST_USE_STRUCT LDKRawDataPart { + void (*handle_accept_channel)(const void *this_arg, struct LDKPublicKey their_node_id, struct LDKInitFeatures their_features, const struct LDKAcceptChannel *NONNULL_PTR msg); /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * Handle an incoming funding_created message from the given peer. */ - LDKnativeRawDataPart *inner; + void (*handle_funding_created)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKFundingCreated *NONNULL_PTR msg); /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * Handle an incoming funding_signed message from the given peer. */ - bool is_owned; -} LDKRawDataPart; + void (*handle_funding_signed)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKFundingSigned *NONNULL_PTR msg); + /** + * Handle an incoming channel_ready message from the given peer. + */ + void (*handle_channel_ready)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKChannelReady *NONNULL_PTR msg); + /** + * Handle an incoming shutdown message from the given peer. + */ + void (*handle_shutdown)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKInitFeatures *NONNULL_PTR their_features, const struct LDKShutdown *NONNULL_PTR msg); + /** + * Handle an incoming closing_signed message from the given peer. + */ + void (*handle_closing_signed)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKClosingSigned *NONNULL_PTR msg); + /** + * Handle an incoming update_add_htlc message from the given peer. + */ + void (*handle_update_add_htlc)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKUpdateAddHTLC *NONNULL_PTR msg); + /** + * Handle an incoming update_fulfill_htlc message from the given peer. + */ + void (*handle_update_fulfill_htlc)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKUpdateFulfillHTLC *NONNULL_PTR msg); + /** + * Handle an incoming update_fail_htlc message from the given peer. + */ + void (*handle_update_fail_htlc)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKUpdateFailHTLC *NONNULL_PTR msg); + /** + * Handle an incoming update_fail_malformed_htlc message from the given peer. + */ + void (*handle_update_fail_malformed_htlc)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR msg); + /** + * Handle an incoming commitment_signed message from the given peer. + */ + void (*handle_commitment_signed)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKCommitmentSigned *NONNULL_PTR msg); + /** + * Handle an incoming revoke_and_ack message from the given peer. + */ + void (*handle_revoke_and_ack)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKRevokeAndACK *NONNULL_PTR msg); + /** + * Handle an incoming update_fee message from the given peer. + */ + void (*handle_update_fee)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKUpdateFee *NONNULL_PTR msg); + /** + * Handle an incoming announcement_signatures message from the given peer. + */ + void (*handle_announcement_signatures)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKAnnouncementSignatures *NONNULL_PTR msg); + /** + * Indicates a connection to the peer failed/an existing connection was lost. If no connection + * is believed to be possible in the future (eg they're sending us messages we don't + * understand or indicate they require unknown feature bits), no_connection_possible is set + * and any outstanding channels should be failed. + * + * Note that in some rare cases this may be called without a corresponding + * [`Self::peer_connected`]. + */ + void (*peer_disconnected)(const void *this_arg, struct LDKPublicKey their_node_id, bool no_connection_possible); + /** + * Handle a peer reconnecting, possibly generating channel_reestablish message(s). + * + * May return an `Err(())` if the features the peer supports are not sufficient to communicate + * with us. Implementors should be somewhat conservative about doing so, however, as other + * message handlers may still wish to communicate with this peer. + */ + struct LDKCResult_NoneNoneZ (*peer_connected)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKInit *NONNULL_PTR msg); + /** + * Handle an incoming channel_reestablish message from the given peer. + */ + void (*handle_channel_reestablish)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKChannelReestablish *NONNULL_PTR msg); + /** + * Handle an incoming channel update from the given peer. + */ + void (*handle_channel_update)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKChannelUpdate *NONNULL_PTR msg); + /** + * Handle an incoming error message from the given peer. + */ + void (*handle_error)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKErrorMessage *NONNULL_PTR msg); + /** + * Gets the node feature flags which this handler itself supports. All available handlers are + * queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`] + * which are broadcasted in our [`NodeAnnouncement`] message. + */ + struct LDKNodeFeatures (*provided_node_features)(const void *this_arg); + /** + * Gets the init feature flags which should be sent to the given peer. All available handlers + * are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`] + * which are sent in our [`Init`] message. + * + * Note that this method is called before [`Self::peer_connected`]. + */ + struct LDKInitFeatures (*provided_init_features)(const void *this_arg, struct LDKPublicKey their_node_id); + /** + * Implementation of MessageSendEventsProvider for this object. + */ + struct LDKMessageSendEventsProvider MessageSendEventsProvider; + /** + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + */ + void (*free)(void *this_arg); +} LDKChannelMessageHandler; /** - * SHA-256 hash + * Arguments for the creation of a ChannelManager that are not deserialized. + * + * At a high-level, the process for deserializing a ChannelManager and resuming normal operation + * is: + * 1) Deserialize all stored [`ChannelMonitor`]s. + * 2) Deserialize the [`ChannelManager`] by filling in this struct and calling: + * `<(BlockHash, ChannelManager)>::read(reader, args)` + * This may result in closing some channels if the [`ChannelMonitor`] is newer than the stored + * [`ChannelManager`] state to ensure no loss of funds. Thus, transactions may be broadcasted. + * 3) If you are not fetching full blocks, register all relevant [`ChannelMonitor`] outpoints the + * same way you would handle a [`chain::Filter`] call using + * [`ChannelMonitor::get_outputs_to_watch`] and [`ChannelMonitor::get_funding_txo`]. + * 4) Reconnect blocks on your [`ChannelMonitor`]s. + * 5) Disconnect/connect blocks on the [`ChannelManager`]. + * 6) Re-persist the [`ChannelMonitor`]s to ensure the latest state is on disk. + * Note that if you're using a [`ChainMonitor`] for your [`chain::Watch`] implementation, you + * will likely accomplish this as a side-effect of calling [`chain::Watch::watch_channel`] in + * the next step. + * 7) Move the [`ChannelMonitor`]s into your local [`chain::Watch`]. If you're using a + * [`ChainMonitor`], this is done by calling [`chain::Watch::watch_channel`]. + * + * Note that the ordering of #4-7 is not of importance, however all four must occur before you + * call any other methods on the newly-deserialized [`ChannelManager`]. + * + * Note that because some channels may be closed during deserialization, it is critical that you + * always deserialize only the latest version of a ChannelManager and ChannelMonitors available to + * you. If you deserialize an old ChannelManager (during which force-closure transactions may be + * broadcast), and then later deserialize a newer version of the same ChannelManager (which will + * not force-close the same channels but consider them live), you may end up revoking a state for + * which you've already broadcasted the transaction. + * + * [`ChainMonitor`]: crate::chain::chainmonitor::ChainMonitor */ -typedef struct MUST_USE_STRUCT LDKSha256 { +typedef struct MUST_USE_STRUCT LDKChannelManagerReadArgs { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeSha256 *inner; + LDKnativeChannelManagerReadArgs *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKSha256; +} LDKChannelManagerReadArgs; /** - * Positive duration that defines when (relatively to the timestamp) in the future the invoice - * expires + * A set of keys that were HKDF-expanded from an initial call to + * [`KeysInterface::get_inbound_payment_key_material`]. + * + * [`KeysInterface::get_inbound_payment_key_material`]: crate::chain::keysinterface::KeysInterface::get_inbound_payment_key_material */ -typedef struct MUST_USE_STRUCT LDKExpiryTime { +typedef struct MUST_USE_STRUCT LDKExpandedKey { /** * A pointer to the opaque Rust object. * Nearly everywhere, 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; + LDKnativeExpandedKey *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; +} LDKExpandedKey; /** - * `min_final_cltv_expiry` to use for the last HTLC in the route + * Proof that the sender knows the per-commitment secret of the previous commitment transaction. + * This is used to convince the recipient that the channel is at a certain commitment + * number even if they lost that data due to a local failure. Of course, the peer may lie + * and even later commitments may have been revoked. */ -typedef struct MUST_USE_STRUCT LDKMinFinalCltvExpiry { +typedef struct MUST_USE_STRUCT LDKDataLossProtect { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeMinFinalCltvExpiry *inner; + LDKnativeDataLossProtect *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; -} LDKMinFinalCltvExpiry; - -/** - * A 20-byte byte array. - */ -typedef struct LDKTwentyBytes { - /** - * The twenty bytes - */ - uint8_t data[20]; -} LDKTwentyBytes; +} LDKDataLossProtect; /** - * Fallback address in case no LN payment is possible + * A 3-byte byte array. */ -typedef enum LDKFallback_Tag { - LDKFallback_SegWitProgram, - LDKFallback_PubKeyHash, - LDKFallback_ScriptHash, +typedef struct LDKThreeBytes { /** - * Must be last for serialization purposes + * The three bytes */ - LDKFallback_Sentinel, -} LDKFallback_Tag; - -typedef struct LDKFallback_LDKSegWitProgram_Body { - struct LDKu5 version; - struct LDKCVec_u8Z program; -} LDKFallback_LDKSegWitProgram_Body; - -typedef struct MUST_USE_STRUCT LDKFallback { - LDKFallback_Tag tag; - union { - LDKFallback_LDKSegWitProgram_Body seg_wit_program; - struct { - struct LDKTwentyBytes pub_key_hash; - }; - struct { - struct LDKTwentyBytes script_hash; - }; - }; -} LDKFallback; + uint8_t data[3]; +} LDKThreeBytes; /** - * A trait defining behavior of an [`Invoice`] payer. + * A trait to describe an object which can receive routing messages. + * + * # Implementor DoS Warnings + * + * For `gossip_queries` messages there are potential DoS vectors when handling + * inbound queries. Implementors using an on-disk network graph should be aware of + * repeated disk I/O for queries accessing different parts of the network graph. */ -typedef struct LDKPayer { +typedef struct LDKRoutingMessageHandler { /** * 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 payer's node id. + * Handle an incoming node_announcement message, returning true if it should be forwarded on, + * false or returning an Err otherwise. */ - struct LDKPublicKey (*node_id)(const void *this_arg); + struct LDKCResult_boolLightningErrorZ (*handle_node_announcement)(const void *this_arg, const struct LDKNodeAnnouncement *NONNULL_PTR msg); /** - * Returns the payer's channels. + * Handle a channel_announcement message, returning true if it should be forwarded on, false + * or returning an Err otherwise. */ - struct LDKCVec_ChannelDetailsZ (*first_hops)(const void *this_arg); + struct LDKCResult_boolLightningErrorZ (*handle_channel_announcement)(const void *this_arg, const struct LDKChannelAnnouncement *NONNULL_PTR msg); /** - * Sends a payment over the Lightning Network using the given [`Route`]. - * - * Note that payment_secret (or a relevant inner pointer) may be NULL or all-0s to represent None + * Handle an incoming channel_update message, returning true if it should be forwarded on, + * false or returning an Err otherwise. */ - struct LDKCResult_PaymentIdPaymentSendFailureZ (*send_payment)(const void *this_arg, const struct LDKRoute *NONNULL_PTR route, struct LDKThirtyTwoBytes payment_hash, struct LDKThirtyTwoBytes payment_secret); + struct LDKCResult_boolLightningErrorZ (*handle_channel_update)(const void *this_arg, const struct LDKChannelUpdate *NONNULL_PTR msg); /** - * Sends a spontaneous payment over the Lightning Network using the given [`Route`]. + * Gets channel announcements and updates required to dump our routing table to a remote node, + * starting at the short_channel_id indicated by starting_point and including announcements + * for a single channel. */ - struct LDKCResult_PaymentIdPaymentSendFailureZ (*send_spontaneous_payment)(const void *this_arg, const struct LDKRoute *NONNULL_PTR route, struct LDKThirtyTwoBytes payment_preimage); + struct LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ (*get_next_channel_announcement)(const void *this_arg, uint64_t starting_point); /** - * Retries a failed payment path for the [`PaymentId`] using the given [`Route`]. + * Gets a node announcement required to dump our routing table to a remote node, starting at + * the node *after* the provided pubkey and including up to one announcement immediately + * higher (as defined by ::cmp) than starting_point. + * If None is provided for starting_point, we start at the first node. + * + * Note that starting_point (or a relevant inner pointer) may be NULL or all-0s to represent None + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ - struct LDKCResult_NonePaymentSendFailureZ (*retry_payment)(const void *this_arg, const struct LDKRoute *NONNULL_PTR route, struct LDKThirtyTwoBytes payment_id); + struct LDKNodeAnnouncement (*get_next_node_announcement)(const void *this_arg, struct LDKPublicKey starting_point); /** - * Signals that no further retries for the given payment will occur. + * Called when a connection is established with a peer. This can be used to + * perform routing table synchronization using a strategy defined by the + * implementor. + * + * May return an `Err(())` if the features the peer supports are not sufficient to communicate + * with us. Implementors should be somewhat conservative about doing so, however, as other + * message handlers may still wish to communicate with this peer. */ - void (*abandon_payment)(const void *this_arg, struct LDKThirtyTwoBytes payment_id); + struct LDKCResult_NoneNoneZ (*peer_connected)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKInit *NONNULL_PTR init); /** - * 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. + * Handles the reply of a query we initiated to learn about channels + * for a given range of blocks. We can expect to receive one or more + * replies to a single query. */ - void (*free)(void *this_arg); -} LDKPayer; - -/** - * A trait defining behavior for routing an [`Invoice`] payment. - */ -typedef struct LDKRouter { + struct LDKCResult_NoneLightningErrorZ (*handle_reply_channel_range)(const void *this_arg, struct LDKPublicKey their_node_id, struct LDKReplyChannelRange msg); /** - * 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. - */ + * Handles the reply of a query we initiated asking for routing gossip + * messages for a list of channels. We should receive this message when + * a node has completed its best effort to send us the pertaining routing + * gossip messages. + */ + struct LDKCResult_NoneLightningErrorZ (*handle_reply_short_channel_ids_end)(const void *this_arg, struct LDKPublicKey their_node_id, struct LDKReplyShortChannelIdsEnd msg); + /** + * Handles when a peer asks us to send a list of short_channel_ids + * for the requested range of blocks. + */ + struct LDKCResult_NoneLightningErrorZ (*handle_query_channel_range)(const void *this_arg, struct LDKPublicKey their_node_id, struct LDKQueryChannelRange msg); + /** + * Handles when a peer asks us to send routing gossip messages for a + * list of short_channel_ids. + */ + struct LDKCResult_NoneLightningErrorZ (*handle_query_short_channel_ids)(const void *this_arg, struct LDKPublicKey their_node_id, struct LDKQueryShortChannelIds msg); + /** + * Gets the node feature flags which this handler itself supports. All available handlers are + * queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`] + * which are broadcasted in our [`NodeAnnouncement`] message. + */ + struct LDKNodeFeatures (*provided_node_features)(const void *this_arg); + /** + * Gets the init feature flags which should be sent to the given peer. All available handlers + * are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`] + * which are sent in our [`Init`] message. + * + * Note that this method is called before [`Self::peer_connected`]. + */ + struct LDKInitFeatures (*provided_init_features)(const void *this_arg, struct LDKPublicKey their_node_id); + /** + * Implementation of MessageSendEventsProvider for this object. + */ + struct LDKMessageSendEventsProvider MessageSendEventsProvider; + /** + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + */ + void (*free)(void *this_arg); +} LDKRoutingMessageHandler; + +/** + * A trait to describe an object that can receive onion messages. + */ +typedef struct LDKOnionMessageHandler { + /** + * 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; /** - * Finds a [`Route`] between `payer` and `payee` for a payment with the given values. + * Handle an incoming onion_message message from the given peer. + */ + void (*handle_onion_message)(const void *this_arg, struct LDKPublicKey peer_node_id, const struct LDKOnionMessage *NONNULL_PTR msg); + /** + * Called when a connection is established with a peer. Can be used to track which peers + * advertise onion message support and are online. * - * Note that first_hops (or a relevant inner pointer) may be NULL or all-0s to represent None + * May return an `Err(())` if the features the peer supports are not sufficient to communicate + * with us. Implementors should be somewhat conservative about doing so, however, as other + * message handlers may still wish to communicate with this peer. + */ + struct LDKCResult_NoneNoneZ (*peer_connected)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKInit *NONNULL_PTR init); + /** + * Indicates a connection to the peer failed/an existing connection was lost. Allows handlers to + * drop and refuse to forward onion messages to this peer. + * + * Note that in some rare cases this may be called without a corresponding + * [`Self::peer_connected`]. + */ + void (*peer_disconnected)(const void *this_arg, struct LDKPublicKey their_node_id, bool no_connection_possible); + /** + * Gets the node feature flags which this handler itself supports. All available handlers are + * queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`] + * which are broadcasted in our [`NodeAnnouncement`] message. */ - 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); + struct LDKNodeFeatures (*provided_node_features)(const void *this_arg); + /** + * Gets the init feature flags which should be sent to the given peer. All available handlers + * are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`] + * which are sent in our [`Init`] message. + * + * Note that this method is called before [`Self::peer_connected`]. + */ + struct LDKInitFeatures (*provided_init_features)(const void *this_arg, struct LDKPublicKey their_node_id); + /** + * Implementation of OnionMessageProvider for this object. + */ + struct LDKOnionMessageProvider OnionMessageProvider; /** * Frees any resources associated with this object given its this_arg pointer. * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. */ void (*free)(void *this_arg); -} LDKRouter; +} LDKOnionMessageHandler; + +/** + * Trait to be implemented by custom message (unrelated to the channel/gossip LN layers) + * decoders. + */ +typedef struct LDKCustomMessageReader { + /** + * 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; + /** + * Decodes a custom message to `CustomMessageType`. If the given message type is known to the + * implementation and the message could be decoded, must return `Ok(Some(message))`. If the + * message type is unknown to the implementation, must return `Ok(None)`. If a decoding error + * occur, must return `Err(DecodeError::X)` where `X` details the encountered error. + */ + struct LDKCResult_COption_TypeZDecodeErrorZ (*read)(const void *this_arg, uint16_t message_type, struct LDKu8slice buffer); + /** + * 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); +} LDKCustomMessageReader; + +/** + * Handler for BOLT1-compliant messages. + */ +typedef struct LDKCustomMessageHandler { + /** + * 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; + /** + * Called with the message type that was received and the buffer to be read. + * Can return a `MessageHandlingError` if the message could not be handled. + */ + struct LDKCResult_NoneLightningErrorZ (*handle_custom_message)(const void *this_arg, struct LDKType msg, struct LDKPublicKey sender_node_id); + /** + * Gets the list of pending messages which were generated by the custom message + * handler, clearing the list in the process. The first tuple element must + * correspond to the intended recipients node ids. If no connection to one of the + * specified node does not exist, the message is simply not sent to it. + */ + struct LDKCVec_C2Tuple_PublicKeyTypeZZ (*get_and_clear_pending_msg)(const void *this_arg); + /** + * Implementation of CustomMessageReader for this object. + */ + struct LDKCustomMessageReader CustomMessageReader; + /** + * 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); +} LDKCustomMessageHandler; /** - * A utility for paying [`Invoice`]s and sending spontaneous payments. + * A dummy struct which implements `RoutingMessageHandler` without storing any routing information + * or doing any processing. You can provide one of these as the route_handler in a MessageHandler. + */ +typedef struct MUST_USE_STRUCT LDKIgnoringMessageHandler { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeIgnoringMessageHandler *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; +} LDKIgnoringMessageHandler; + +/** + * Handler for custom onion messages. If you are using [`SimpleArcOnionMessenger`], + * [`SimpleRefOnionMessenger`], or prefer to ignore inbound custom onion messages, + * [`IgnoringMessageHandler`] must be provided to [`OnionMessenger::new`]. Otherwise, a custom + * implementation of this trait must be provided, with [`CustomMessage`] specifying the supported + * message types. * - * See [module-level documentation] for details. + * See [`OnionMessenger`] for example usage. * - * [module-level documentation]: crate::payment + * [`IgnoringMessageHandler`]: crate::ln::peer_handler::IgnoringMessageHandler + * [`CustomMessage`]: Self::CustomMessage */ -typedef struct MUST_USE_STRUCT LDKInvoicePayer { +typedef struct LDKCustomOnionMessageHandler { + /** + * 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; + /** + * Called with the custom message that was received. + */ + void (*handle_custom_message)(const void *this_arg, struct LDKCustomOnionMessageContents msg); + /** + * Read a custom message of type `message_type` from `buffer`, returning `Ok(None)` if the + * message type is unknown. + */ + struct LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ (*read_custom_message)(const void *this_arg, uint64_t message_type, struct LDKu8slice buffer); + /** + * 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); +} LDKCustomOnionMessageHandler; + + + +/** + * A dummy struct which implements `ChannelMessageHandler` without having any channels. + * You can provide one of these as the route_handler in a MessageHandler. + */ +typedef struct MUST_USE_STRUCT LDKErroringMessageHandler { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeInvoicePayer *inner; + LDKnativeErroringMessageHandler *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; -} LDKInvoicePayer; +} LDKErroringMessageHandler; + + + +/** + * Provides references to trait impls which handle different types of messages. + */ +typedef struct MUST_USE_STRUCT LDKMessageHandler { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeMessageHandler *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; +} LDKMessageHandler; + +/** + * Provides an object which can be used to send data to and which uniquely identifies a connection + * to a remote host. You will need to be able to generate multiple of these which meet Eq and + * implement Hash to meet the PeerManager API. + * + * For efficiency, Clone should be relatively cheap for this type. + * + * Two descriptors may compare equal (by [`cmp::Eq`] and [`hash::Hash`]) as long as the original + * has been disconnected, the [`PeerManager`] has been informed of the disconnection (either by it + * having triggered the disconnection or a call to [`PeerManager::socket_disconnected`]), and no + * further calls to the [`PeerManager`] related to the original socket occur. This allows you to + * use a file descriptor for your SocketDescriptor directly, however for simplicity you may wish + * to simply use another value which is guaranteed to be globally unique instead. + */ +typedef struct LDKSocketDescriptor { + /** + * 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; + /** + * Attempts to send some data from the given slice to the peer. + * + * Returns the amount of data which was sent, possibly 0 if the socket has since disconnected. + * Note that in the disconnected case, [`PeerManager::socket_disconnected`] must still be + * called and further write attempts may occur until that time. + * + * If the returned size is smaller than `data.len()`, a + * [`PeerManager::write_buffer_space_avail`] call must be made the next time more data can be + * written. Additionally, until a `send_data` event completes fully, no further + * [`PeerManager::read_event`] calls should be made for the same peer! Because this is to + * prevent denial-of-service issues, you should not read or buffer any data from the socket + * until then. + * + * If a [`PeerManager::read_event`] call on this descriptor had previously returned true + * (indicating that read events should be paused to prevent DoS in the send buffer), + * `resume_read` may be set indicating that read events on this descriptor should resume. A + * `resume_read` of false carries no meaning, and should not cause any action. + */ + uintptr_t (*send_data)(void *this_arg, struct LDKu8slice data, bool resume_read); + /** + * Disconnect the socket pointed to by this SocketDescriptor. + * + * You do *not* need to call [`PeerManager::socket_disconnected`] with this socket after this + * call (doing so is a noop). + */ + void (*disconnect_socket)(void *this_arg); + /** + * Checks if two objects are equal given this object's this_arg pointer and another object. + */ + bool (*eq)(const void *this_arg, const struct LDKSocketDescriptor *NONNULL_PTR other_arg); + /** + * Calculate a succinct non-cryptographic hash for an object given its this_arg pointer. + * This is used, for example, for inclusion of this object in a hash map. + */ + uint64_t (*hash)(const void *this_arg); + /** + * Called, if set, after this SocketDescriptor has been cloned into a duplicate object. + * The new SocketDescriptor is provided, and should be mutated as needed to perform a + * deep copy of the object pointed to by this_arg or avoid any double-freeing. + */ + void (*cloned)(struct LDKSocketDescriptor *NONNULL_PTR new_SocketDescriptor); + /** + * 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); +} LDKSocketDescriptor; + + + +/** + * A PeerManager manages a set of peers, described by their [`SocketDescriptor`] and marshalls + * socket events into messages which it passes on to its [`MessageHandler`]. + * + * Locks are taken internally, so you must never assume that reentrancy from a + * [`SocketDescriptor`] call back into [`PeerManager`] methods will not deadlock. + * + * Calls to [`read_event`] will decode relevant messages and pass them to the + * [`ChannelMessageHandler`], likely doing message processing in-line. Thus, the primary form of + * parallelism in Rust-Lightning is in calls to [`read_event`]. Note, however, that calls to any + * [`PeerManager`] functions related to the same connection must occur only in serial, making new + * calls only after previous ones have returned. + * + * Rather than using a plain PeerManager, it is preferable to use either a SimpleArcPeerManager + * a SimpleRefPeerManager, for conciseness. See their documentation for more details, but + * essentially you should default to using a SimpleRefPeerManager, and use a + * SimpleArcPeerManager when you require a PeerManager with a static lifetime, such as when + * you're using lightning-net-tokio. + * + * [`read_event`]: PeerManager::read_event + */ +typedef struct MUST_USE_STRUCT LDKPeerManager { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativePeerManager *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; +} LDKPeerManager; + + + +/** + * Static channel fields used to build transactions given per-commitment fields, organized by + * broadcaster/countersignatory. + * + * This is derived from the holder/counterparty-organized ChannelTransactionParameters via the + * as_holder_broadcastable and as_counterparty_broadcastable functions. + */ +typedef struct MUST_USE_STRUCT LDKDirectedChannelTransactionParameters { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeDirectedChannelTransactionParameters *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; +} LDKDirectedChannelTransactionParameters; + +/** + * Integer in the range `0..=16` + */ +typedef struct LDKWitnessVersion { + uint8_t _0; +} LDKWitnessVersion; + + + +/** + * 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 LDKP2PGossipSync { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeP2PGossipSync *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; +} LDKP2PGossipSync; + + + +/** + * 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; + /** + * The maximum HTLC amount denominated in millisatoshi. + */ + struct LDKCOption_u64Z htlc_maximum_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; + + + +/** + * A concrete implementation of [`LockableScore`] which supports multi-threading. + */ +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. + */ + 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; +} LDKMultiThreadedLockableScore; + + + +/** + * A locked `MultiThreadedLockableScore`. + */ +typedef struct MUST_USE_STRUCT LDKMultiThreadedScoreLock { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeMultiThreadedScoreLock *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; +} LDKMultiThreadedScoreLock; + + + +/** + * Parameters for configuring [`ProbabilisticScorer`]. + * + * 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). + * + * The penalty applied to any channel by the [`ProbabilisticScorer`] is the sum of each of the + * parameters here. + */ +typedef struct MUST_USE_STRUCT LDKProbabilisticScoringParameters { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeProbabilisticScoringParameters *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKProbabilisticScoringParameters; + + + +/** + * A sender, receiver and forwarder of onion messages. In upcoming releases, this object will be + * used to retrieve invoices and fulfill invoice requests from [offers]. Currently, only sending + * and receiving custom onion messages is supported. + * + * # Example + * + * ``` + * # extern crate bitcoin; + * # use bitcoin::hashes::_export::_core::time::Duration; + * # use bitcoin::secp256k1::{PublicKey, Secp256k1, SecretKey}; + * # use lightning::chain::keysinterface::{InMemorySigner, KeysManager, KeysInterface}; + * # use lightning::ln::msgs::DecodeError; + * # use lightning::ln::peer_handler::IgnoringMessageHandler; + * # use lightning::onion_message::messenger::{Destination, OnionMessenger}; + * # use lightning::onion_message::packet::CustomOnionMessageContents; + * # use lightning::onion_message::blinded_route::BlindedRoute; + * # use lightning::util::logger::{Logger, Record}; + * # use lightning::util::ser::{Writeable, Writer}; + * # use lightning::io; + * # use std::sync::Arc; + * # struct FakeLogger {}; + * # impl Logger for FakeLogger { + * # fn log(&self, record: &Record) { unimplemented!() } + * # } + * # let seed = [42u8; 32]; + * # let time = Duration::from_secs(123456); + * # let keys_manager = KeysManager::new(&seed, time.as_secs(), time.subsec_nanos()); + * # let logger = Arc::new(FakeLogger {}); + * # let node_secret = SecretKey::from_slice(&hex::decode(\"0101010101010101010101010101010101010101010101010101010101010101\").unwrap()[..]).unwrap(); + * # let secp_ctx = Secp256k1::new(); + * # let hop_node_id1 = PublicKey::from_secret_key(&secp_ctx, &node_secret); + * # let (hop_node_id2, hop_node_id3, hop_node_id4) = (hop_node_id1, hop_node_id1, hop_node_id1); + * # let destination_node_id = hop_node_id1; + * # let your_custom_message_handler = IgnoringMessageHandler {}; + * // Create the onion messenger. This must use the same `keys_manager` as is passed to your + * // ChannelManager. + * let onion_messenger = OnionMessenger::new(&keys_manager, logger, your_custom_message_handler); + * + * # struct YourCustomMessage {} + * impl Writeable for YourCustomMessage { + * \tfn write(&self, w: &mut W) -> Result<(), io::Error> { + * \t\t# Ok(()) + * \t\t// Write your custom onion message to `w` + * \t} + * } + * impl CustomOnionMessageContents for YourCustomMessage { + * \tfn tlv_type(&self) -> u64 { + * \t\t# let your_custom_message_type = 42; + * \t\tyour_custom_message_type + * \t} + * } + * // Send a custom onion message to a node id. + * let intermediate_hops = [hop_node_id1, hop_node_id2]; + * let reply_path = None; + * # let your_custom_message = YourCustomMessage {}; + * onion_messenger.send_custom_onion_message(&intermediate_hops, Destination::Node(destination_node_id), your_custom_message, reply_path); + * + * // Create a blinded route to yourself, for someone to send an onion message to. + * # let your_node_id = hop_node_id1; + * let hops = [hop_node_id3, hop_node_id4, your_node_id]; + * let blinded_route = BlindedRoute::new(&hops, &keys_manager, &secp_ctx).unwrap(); + * + * // Send a custom onion message to a blinded route. + * # let intermediate_hops = [hop_node_id1, hop_node_id2]; + * let reply_path = None; + * # let your_custom_message = YourCustomMessage {}; + * onion_messenger.send_custom_onion_message(&intermediate_hops, Destination::BlindedRoute(blinded_route), your_custom_message, reply_path); + * ``` + * + * [offers]: + * [`OnionMessenger`]: crate::onion_message::OnionMessenger + */ +typedef struct MUST_USE_STRUCT LDKOnionMessenger { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeOnionMessenger *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; +} LDKOnionMessenger; + +/** + * The destination of an onion message. + */ +typedef enum LDKDestination_Tag { + /** + * We're sending this onion message to a node. + */ + LDKDestination_Node, + /** + * We're sending this onion message to a blinded route. + */ + LDKDestination_BlindedRoute, + /** + * Must be last for serialization purposes + */ + LDKDestination_Sentinel, +} LDKDestination_Tag; + +typedef struct MUST_USE_STRUCT LDKDestination { + LDKDestination_Tag tag; + union { + struct { + struct LDKPublicKey node; + }; + struct { + struct LDKBlindedRoute blinded_route; + }; + }; +} LDKDestination; + + + +/** + * FilesystemPersister persists channel data on disk, where each channel's + * data is stored in a file named after its funding outpoint. + * + * Warning: this module does the best it can with calls to persist data, but it + * can only guarantee that the data is passed to the drive. It is up to the + * drive manufacturers to do the actual persistence properly, which they often + * don't (especially on consumer-grade hardware). Therefore, it is up to the + * user to validate their entire storage stack, to ensure the writes are + * persistent. + * Corollary: especially when dealing with larger amounts of money, it is best + * practice to have multiple channel data backups and not rely only on one + * FilesystemPersister. + */ +typedef struct MUST_USE_STRUCT LDKFilesystemPersister { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeFilesystemPersister *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKFilesystemPersister; + + + +/** + * `BackgroundProcessor` takes care of tasks that (1) need to happen periodically to keep + * Rust-Lightning running properly, and (2) either can or should be run in the background. Its + * responsibilities are: + * * Processing [`Event`]s with a user-provided [`EventHandler`]. + * * Monitoring whether the [`ChannelManager`] needs to be re-persisted to disk, and if so, + * writing it to disk/backups by invoking the callback given to it at startup. + * [`ChannelManager`] persistence should be done in the background. + * * Calling [`ChannelManager::timer_tick_occurred`] and [`PeerManager::timer_tick_occurred`] + * at the appropriate intervals. + * * Calling [`NetworkGraph::remove_stale_channels_and_tracking`] (if a [`GossipSync`] with a + * [`NetworkGraph`] is provided to [`BackgroundProcessor::start`]). + * + * It will also call [`PeerManager::process_events`] periodically though this shouldn't be relied + * upon as doing so may result in high latency. + * + * # Note + * + * If [`ChannelManager`] persistence fails and the persisted manager becomes out-of-date, then + * there is a risk of channels force-closing on startup when the manager realizes it's outdated. + * However, as long as [`ChannelMonitor`] backups are sound, no funds besides those used for + * unilateral chain closure fees are at risk. + * + * [`ChannelMonitor`]: lightning::chain::channelmonitor::ChannelMonitor + * [`Event`]: lightning::util::events::Event + *BackgroundProcessor will immediately stop on drop. It should be stored until shutdown. + */ +typedef struct MUST_USE_STRUCT LDKBackgroundProcessor { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeBackgroundProcessor *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKBackgroundProcessor; + + + +/** + * The main Rapid Gossip Sync object. + * + * See [crate-level documentation] for usage. + * + * [crate-level documentation]: crate + */ +typedef struct MUST_USE_STRUCT LDKRapidGossipSync { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeRapidGossipSync *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; +} LDKRapidGossipSync; + +/** + * Either [`P2PGossipSync`] or [`RapidGossipSync`]. + */ +typedef enum LDKGossipSync_Tag { + /** + * Gossip sync via the lightning peer-to-peer network as defined by BOLT 7. + */ + LDKGossipSync_P2P, + /** + * Rapid gossip sync from a trusted server. + */ + LDKGossipSync_Rapid, + /** + * No gossip sync. + */ + LDKGossipSync_None, + /** + * Must be last for serialization purposes + */ + LDKGossipSync_Sentinel, +} LDKGossipSync_Tag; + +typedef struct MUST_USE_STRUCT LDKGossipSync { + LDKGossipSync_Tag tag; + union { + struct { + /** + * Note that this field is expected to be a reference. + */ + struct LDKP2PGossipSync p2p; + }; + struct { + /** + * Note that this field is expected to be a reference. + */ + struct LDKRapidGossipSync rapid; + }; + }; +} LDKGossipSync; + + + +/** + * Data of the `RawInvoice` that is encoded in the data part + */ +typedef struct MUST_USE_STRUCT LDKRawDataPart { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeRawDataPart *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; +} LDKRawDataPart; + + + +/** + * SHA-256 hash + */ +typedef struct MUST_USE_STRUCT LDKSha256 { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeSha256 *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKSha256; + + + +/** + * Positive duration that defines when (relatively to the timestamp) in the future the invoice + * expires + */ +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 + */ +typedef struct MUST_USE_STRUCT LDKMinFinalCltvExpiry { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeMinFinalCltvExpiry *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; +} LDKMinFinalCltvExpiry; + +/** + * A 20-byte byte array. + */ +typedef struct LDKTwentyBytes { + /** + * The twenty bytes + */ + uint8_t data[20]; +} LDKTwentyBytes; + +/** + * Fallback address in case no LN payment is possible + */ +typedef enum LDKFallback_Tag { + LDKFallback_SegWitProgram, + LDKFallback_PubKeyHash, + LDKFallback_ScriptHash, + /** + * Must be last for serialization purposes + */ + LDKFallback_Sentinel, +} LDKFallback_Tag; + +typedef struct LDKFallback_LDKSegWitProgram_Body { + struct LDKu5 version; + struct LDKCVec_u8Z program; +} LDKFallback_LDKSegWitProgram_Body; + +typedef struct MUST_USE_STRUCT LDKFallback { + LDKFallback_Tag tag; + union { + LDKFallback_LDKSegWitProgram_Body seg_wit_program; + struct { + struct LDKTwentyBytes pub_key_hash; + }; + struct { + struct LDKTwentyBytes script_hash; + }; + }; +} LDKFallback; + +/** + * A trait defining behavior of an [`Invoice`] payer. + */ +typedef struct LDKPayer { + /** + * 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 payer's node id. + */ + struct LDKPublicKey (*node_id)(const void *this_arg); + /** + * Returns the payer's channels. + */ + struct LDKCVec_ChannelDetailsZ (*first_hops)(const void *this_arg); + /** + * Sends a payment over the Lightning Network using the given [`Route`]. + * + * 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. + */ + void (*free)(void *this_arg); +} LDKPayer; + +/** + * A trait defining behavior for routing an [`Invoice`] payment. + */ +typedef struct LDKRouter { + /** + * 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; + /** + * Finds a [`Route`] between `payer` and `payee` for a payment with the given values. + * + * 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 route_params, const uint8_t (*payment_hash)[32], struct LDKCVec_ChannelDetailsZ *first_hops, struct LDKInFlightHtlcs inflight_htlcs); + /** + * Lets the router know that payment through a specific path has failed. + */ + void (*notify_payment_path_failed)(const void *this_arg, struct LDKCVec_RouteHopZ path, uint64_t short_channel_id); + /** + * Lets the router know that payment through a specific path was successful. + */ + void (*notify_payment_path_successful)(const void *this_arg, struct LDKCVec_RouteHopZ path); + /** + * Lets the router know that a payment probe was successful. + */ + void (*notify_payment_probe_successful)(const void *this_arg, struct LDKCVec_RouteHopZ path); + /** + * Lets the router know that a payment probe failed. + */ + void (*notify_payment_probe_failed)(const void *this_arg, struct LDKCVec_RouteHopZ path, uint64_t short_channel_id); + /** + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + */ + void (*free)(void *this_arg); +} LDKRouter; + + + +/** + * 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 { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeInvoicePayer *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; +} LDKInvoicePayer; + +/** + * Strategies available to retry payment path failures for an [`Invoice`]. + * + */ +typedef enum LDKRetry_Tag { + /** + * Max number of attempts to retry payment. + * + * Note that this is the number of *path* failures, not full payment retries. For multi-path + * payments, if this is less than the total number of paths, we will never even retry all of the + * payment's paths. + */ + LDKRetry_Attempts, + /** + * Time elapsed before abandoning retries for a payment. + */ + LDKRetry_Timeout, + /** + * Must be last for serialization purposes + */ + LDKRetry_Sentinel, +} LDKRetry_Tag; + +typedef struct MUST_USE_STRUCT LDKRetry { + LDKRetry_Tag tag; + union { + struct { + uintptr_t attempts; + }; + struct { + uint64_t timeout; + }; + }; +} LDKRetry; + + + +/** + * A [`Router`] implemented using [`find_route`]. + */ +typedef struct MUST_USE_STRUCT LDKDefaultRouter { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeDefaultRouter *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; +} LDKDefaultRouter; + +extern const uintptr_t MAX_BUF_SIZE; + +extern const uint64_t MIN_RELAY_FEE_SAT_PER_1000_WEIGHT; + +extern const uint32_t FEERATE_FLOOR_SATS_PER_KW; + +extern const uint64_t CLOSED_CHANNEL_UPDATE_ID; + +extern const uint32_t ANTI_REORG_DELAY; + +extern const uint16_t BREAKDOWN_TIMEOUT; + +extern const uint16_t MIN_CLTV_EXPIRY_DELTA; + +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 uint8_t DEFAULT_MAX_PATH_COUNT; + +extern const uint64_t MAX_TIMESTAMP; + +extern const uint64_t DEFAULT_EXPIRY_TIME; + +extern const uint64_t DEFAULT_MIN_FINAL_CLTV_EXPIRY; + +extern const uint8_t TAG_PAYMENT_HASH; + +extern const uint8_t TAG_DESCRIPTION; + +extern const uint8_t TAG_PAYEE_PUB_KEY; + +extern const uint8_t TAG_DESCRIPTION_HASH; + +extern const uint8_t TAG_EXPIRY_TIME; + +extern const uint8_t TAG_MIN_FINAL_CLTV_EXPIRY; + +extern const uint8_t TAG_FALLBACK; + +extern const uint8_t TAG_PRIVATE_ROUTE; + +extern const uint8_t TAG_PAYMENT_SECRET; + +extern const uint8_t TAG_FEATURES; + +struct LDKStr _ldk_get_compiled_version(void); + +struct LDKStr _ldk_c_bindings_get_compiled_version(void); + +/** + * Convenience function for constructing a new BigEndianScalar + */ +struct LDKBigEndianScalar BigEndianScalar_new(struct LDKThirtyTwoBytes big_endian_bytes); + +/** + * Creates a new Bech32Error which has the same data as `orig` + */ +struct LDKBech32Error Bech32Error_clone(const struct LDKBech32Error *NONNULL_PTR orig); + +/** + * Releases any memory held by the given `Bech32Error` (which is currently none) + */ +void Bech32Error_free(struct LDKBech32Error o); + +/** + * Frees the data buffer, if data_is_owned is set and datalen > 0. + */ +void Transaction_free(struct LDKTransaction _res); + +/** + * Convenience function for constructing a new TxOut + */ +struct LDKTxOut TxOut_new(struct LDKCVec_u8Z script_pubkey, uint64_t value); + +/** + * Frees the data pointed to by script_pubkey. + */ +void TxOut_free(struct LDKTxOut _res); + +/** + * Creates a new TxOut which has the same data as `orig` but with a new script buffer. + */ +struct LDKTxOut TxOut_clone(const struct LDKTxOut *NONNULL_PTR orig); + +/** + * Frees the data buffer, if chars_is_owned is set and len > 0. + */ +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 + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_PublicKeyZ_free(struct LDKCVec_PublicKeyZ _res); + +/** + * Creates a new CResult_BlindedRouteNoneZ in the success state. + */ +struct LDKCResult_BlindedRouteNoneZ CResult_BlindedRouteNoneZ_ok(struct LDKBlindedRoute o); + +/** + * Creates a new CResult_BlindedRouteNoneZ in the error state. + */ +struct LDKCResult_BlindedRouteNoneZ CResult_BlindedRouteNoneZ_err(void); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_BlindedRouteNoneZ_is_ok(const struct LDKCResult_BlindedRouteNoneZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_BlindedRouteNoneZ. + */ +void CResult_BlindedRouteNoneZ_free(struct LDKCResult_BlindedRouteNoneZ _res); + +/** + * Creates a new CResult_BlindedRouteDecodeErrorZ in the success state. + */ +struct LDKCResult_BlindedRouteDecodeErrorZ CResult_BlindedRouteDecodeErrorZ_ok(struct LDKBlindedRoute o); + +/** + * Creates a new CResult_BlindedRouteDecodeErrorZ in the error state. + */ +struct LDKCResult_BlindedRouteDecodeErrorZ CResult_BlindedRouteDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_BlindedRouteDecodeErrorZ_is_ok(const struct LDKCResult_BlindedRouteDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_BlindedRouteDecodeErrorZ. + */ +void CResult_BlindedRouteDecodeErrorZ_free(struct LDKCResult_BlindedRouteDecodeErrorZ _res); + +/** + * Creates a new CResult_BlindedHopDecodeErrorZ in the success state. + */ +struct LDKCResult_BlindedHopDecodeErrorZ CResult_BlindedHopDecodeErrorZ_ok(struct LDKBlindedHop o); + +/** + * Creates a new CResult_BlindedHopDecodeErrorZ in the error state. + */ +struct LDKCResult_BlindedHopDecodeErrorZ CResult_BlindedHopDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_BlindedHopDecodeErrorZ_is_ok(const struct LDKCResult_BlindedHopDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_BlindedHopDecodeErrorZ. + */ +void CResult_BlindedHopDecodeErrorZ_free(struct LDKCResult_BlindedHopDecodeErrorZ _res); + +/** + * 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. + */ +struct LDKCResult_SecretKeyErrorZ CResult_SecretKeyErrorZ_ok(struct LDKSecretKey o); + +/** + * Creates a new CResult_SecretKeyErrorZ in the error state. + */ +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. + */ +struct LDKCResult_PublicKeyErrorZ CResult_PublicKeyErrorZ_ok(struct LDKPublicKey o); + +/** + * Creates a new CResult_PublicKeyErrorZ in the error state. + */ +struct LDKCResult_PublicKeyErrorZ CResult_PublicKeyErrorZ_err(enum LDKSecp256k1Error e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_PublicKeyErrorZ_is_ok(const struct LDKCResult_PublicKeyErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_PublicKeyErrorZ. + */ +void CResult_PublicKeyErrorZ_free(struct LDKCResult_PublicKeyErrorZ _res); + +/** + * Creates a new CResult_PublicKeyErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_PublicKeyErrorZ CResult_PublicKeyErrorZ_clone(const struct LDKCResult_PublicKeyErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_TxCreationKeysDecodeErrorZ in the success state. + */ +struct LDKCResult_TxCreationKeysDecodeErrorZ CResult_TxCreationKeysDecodeErrorZ_ok(struct LDKTxCreationKeys o); + +/** + * Creates a new CResult_TxCreationKeysDecodeErrorZ in the error state. + */ +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. + */ +void CResult_TxCreationKeysDecodeErrorZ_free(struct LDKCResult_TxCreationKeysDecodeErrorZ _res); + +/** + * Creates a new CResult_TxCreationKeysDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_TxCreationKeysDecodeErrorZ CResult_TxCreationKeysDecodeErrorZ_clone(const struct LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_ChannelPublicKeysDecodeErrorZ in the success state. + */ +struct LDKCResult_ChannelPublicKeysDecodeErrorZ CResult_ChannelPublicKeysDecodeErrorZ_ok(struct LDKChannelPublicKeys o); + +/** + * Creates a new CResult_ChannelPublicKeysDecodeErrorZ in the error state. + */ +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. + */ +void CResult_ChannelPublicKeysDecodeErrorZ_free(struct LDKCResult_ChannelPublicKeysDecodeErrorZ _res); + +/** + * Creates a new CResult_ChannelPublicKeysDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_ChannelPublicKeysDecodeErrorZ CResult_ChannelPublicKeysDecodeErrorZ_clone(const struct LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_TxCreationKeysErrorZ in the success state. + */ +struct LDKCResult_TxCreationKeysErrorZ CResult_TxCreationKeysErrorZ_ok(struct LDKTxCreationKeys o); + +/** + * Creates a new CResult_TxCreationKeysErrorZ in the error state. + */ +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. + */ +void CResult_TxCreationKeysErrorZ_free(struct LDKCResult_TxCreationKeysErrorZ _res); + +/** + * Creates a new CResult_TxCreationKeysErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_TxCreationKeysErrorZ CResult_TxCreationKeysErrorZ_clone(const struct LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR orig); + +/** + * Constructs a new COption_u32Z containing a u32 + */ +struct LDKCOption_u32Z COption_u32Z_some(uint32_t o); + +/** + * Constructs a new COption_u32Z containing nothing + */ +struct LDKCOption_u32Z COption_u32Z_none(void); + +/** + * Frees any resources associated with the u32, if we are in the Some state + */ +void COption_u32Z_free(struct LDKCOption_u32Z _res); + +/** + * Creates a new COption_u32Z which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCOption_u32Z COption_u32Z_clone(const struct LDKCOption_u32Z *NONNULL_PTR orig); + +/** + * Creates a new CResult_HTLCOutputInCommitmentDecodeErrorZ in the success state. + */ +struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(struct LDKHTLCOutputInCommitment o); + +/** + * Creates a new CResult_HTLCOutputInCommitmentDecodeErrorZ in the error state. + */ +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. + */ +void CResult_HTLCOutputInCommitmentDecodeErrorZ_free(struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res); + +/** + * Creates a new CResult_HTLCOutputInCommitmentDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +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. + */ +struct LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(struct LDKCounterpartyChannelTransactionParameters o); + +/** + * Creates a new CResult_CounterpartyChannelTransactionParametersDecodeErrorZ in the error state. + */ +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. + */ +void CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(struct LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res); + +/** + * Creates a new CResult_CounterpartyChannelTransactionParametersDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(const struct LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_ChannelTransactionParametersDecodeErrorZ in the success state. + */ +struct LDKCResult_ChannelTransactionParametersDecodeErrorZ CResult_ChannelTransactionParametersDecodeErrorZ_ok(struct LDKChannelTransactionParameters o); + +/** + * Creates a new CResult_ChannelTransactionParametersDecodeErrorZ in the error state. + */ +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. + */ +void CResult_ChannelTransactionParametersDecodeErrorZ_free(struct LDKCResult_ChannelTransactionParametersDecodeErrorZ _res); + +/** + * Creates a new CResult_ChannelTransactionParametersDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_ChannelTransactionParametersDecodeErrorZ CResult_ChannelTransactionParametersDecodeErrorZ_clone(const struct LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR orig); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_SignatureZ_free(struct LDKCVec_SignatureZ _res); + +/** + * Creates a new CResult_HolderCommitmentTransactionDecodeErrorZ in the success state. + */ +struct LDKCResult_HolderCommitmentTransactionDecodeErrorZ CResult_HolderCommitmentTransactionDecodeErrorZ_ok(struct LDKHolderCommitmentTransaction o); + +/** + * Creates a new CResult_HolderCommitmentTransactionDecodeErrorZ in the error state. + */ +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. + */ +void CResult_HolderCommitmentTransactionDecodeErrorZ_free(struct LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res); + +/** + * Creates a new CResult_HolderCommitmentTransactionDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_HolderCommitmentTransactionDecodeErrorZ CResult_HolderCommitmentTransactionDecodeErrorZ_clone(const struct LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_BuiltCommitmentTransactionDecodeErrorZ in the success state. + */ +struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(struct LDKBuiltCommitmentTransaction o); + +/** + * Creates a new CResult_BuiltCommitmentTransactionDecodeErrorZ in the error state. + */ +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. + */ +void CResult_BuiltCommitmentTransactionDecodeErrorZ_free(struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res); + +/** + * Creates a new CResult_BuiltCommitmentTransactionDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(const struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_TrustedClosingTransactionNoneZ in the success state. + */ +struct LDKCResult_TrustedClosingTransactionNoneZ CResult_TrustedClosingTransactionNoneZ_ok(struct LDKTrustedClosingTransaction o); + +/** + * Creates a new CResult_TrustedClosingTransactionNoneZ in the error state. + */ +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. + */ +void CResult_TrustedClosingTransactionNoneZ_free(struct LDKCResult_TrustedClosingTransactionNoneZ _res); + +/** + * Creates a new CResult_CommitmentTransactionDecodeErrorZ in the success state. + */ +struct LDKCResult_CommitmentTransactionDecodeErrorZ CResult_CommitmentTransactionDecodeErrorZ_ok(struct LDKCommitmentTransaction o); + +/** + * Creates a new CResult_CommitmentTransactionDecodeErrorZ in the error state. + */ +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. + */ +void CResult_CommitmentTransactionDecodeErrorZ_free(struct LDKCResult_CommitmentTransactionDecodeErrorZ _res); + +/** + * Creates a new CResult_CommitmentTransactionDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_CommitmentTransactionDecodeErrorZ CResult_CommitmentTransactionDecodeErrorZ_clone(const struct LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_TrustedCommitmentTransactionNoneZ in the success state. + */ +struct LDKCResult_TrustedCommitmentTransactionNoneZ CResult_TrustedCommitmentTransactionNoneZ_ok(struct LDKTrustedCommitmentTransaction o); + +/** + * Creates a new CResult_TrustedCommitmentTransactionNoneZ in the error state. + */ +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. + */ +void CResult_TrustedCommitmentTransactionNoneZ_free(struct LDKCResult_TrustedCommitmentTransactionNoneZ _res); + +/** + * Creates a new CResult_CVec_SignatureZNoneZ in the success state. + */ +struct LDKCResult_CVec_SignatureZNoneZ CResult_CVec_SignatureZNoneZ_ok(struct LDKCVec_SignatureZ o); + +/** + * Creates a new CResult_CVec_SignatureZNoneZ in the error state. + */ +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. + */ +void CResult_CVec_SignatureZNoneZ_free(struct LDKCResult_CVec_SignatureZNoneZ _res); + +/** + * Creates a new CResult_CVec_SignatureZNoneZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_CVec_SignatureZNoneZ CResult_CVec_SignatureZNoneZ_clone(const struct LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_ShutdownScriptDecodeErrorZ in the success state. + */ +struct LDKCResult_ShutdownScriptDecodeErrorZ CResult_ShutdownScriptDecodeErrorZ_ok(struct LDKShutdownScript o); + +/** + * Creates a new CResult_ShutdownScriptDecodeErrorZ in the error state. + */ +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. + */ +void CResult_ShutdownScriptDecodeErrorZ_free(struct LDKCResult_ShutdownScriptDecodeErrorZ _res); + +/** + * Creates a new CResult_ShutdownScriptDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_ShutdownScriptDecodeErrorZ CResult_ShutdownScriptDecodeErrorZ_clone(const struct LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_ShutdownScriptInvalidShutdownScriptZ in the success state. + */ +struct LDKCResult_ShutdownScriptInvalidShutdownScriptZ CResult_ShutdownScriptInvalidShutdownScriptZ_ok(struct LDKShutdownScript o); + +/** + * Creates a new CResult_ShutdownScriptInvalidShutdownScriptZ in the error state. + */ +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); + +/** + * Constructs a new COption_WriteableScoreZ containing a crate::lightning::routing::scoring::WriteableScore + */ +struct LDKCOption_WriteableScoreZ COption_WriteableScoreZ_some(struct LDKWriteableScore o); + +/** + * Constructs a new COption_WriteableScoreZ containing nothing + */ +struct LDKCOption_WriteableScoreZ COption_WriteableScoreZ_none(void); + +/** + * Frees any resources associated with the crate::lightning::routing::scoring::WriteableScore, if we are in the Some state + */ +void COption_WriteableScoreZ_free(struct LDKCOption_WriteableScoreZ _res); + +/** + * Creates a new CResult_NoneErrorZ in the success state. + */ +struct LDKCResult_NoneErrorZ CResult_NoneErrorZ_ok(void); + +/** + * Creates a new CResult_NoneErrorZ in the error state. + */ +struct LDKCResult_NoneErrorZ CResult_NoneErrorZ_err(enum LDKIOError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_NoneErrorZ_is_ok(const struct LDKCResult_NoneErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_NoneErrorZ. + */ +void CResult_NoneErrorZ_free(struct LDKCResult_NoneErrorZ _res); + +/** + * Creates a new CResult_NoneErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_NoneErrorZ CResult_NoneErrorZ_clone(const struct LDKCResult_NoneErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_RouteHopDecodeErrorZ in the success state. + */ +struct LDKCResult_RouteHopDecodeErrorZ CResult_RouteHopDecodeErrorZ_ok(struct LDKRouteHop o); + +/** + * Creates a new CResult_RouteHopDecodeErrorZ in the error state. + */ +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. + */ +void CResult_RouteHopDecodeErrorZ_free(struct LDKCResult_RouteHopDecodeErrorZ _res); + +/** + * Creates a new CResult_RouteHopDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_RouteHopDecodeErrorZ CResult_RouteHopDecodeErrorZ_clone(const struct LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR orig); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_RouteHopZ_free(struct LDKCVec_RouteHopZ _res); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_CVec_RouteHopZZ_free(struct LDKCVec_CVec_RouteHopZZ _res); + +/** + * Creates a new CResult_RouteDecodeErrorZ in the success state. + */ +struct LDKCResult_RouteDecodeErrorZ CResult_RouteDecodeErrorZ_ok(struct LDKRoute o); + +/** + * Creates a new CResult_RouteDecodeErrorZ in the error state. + */ +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. + */ +void CResult_RouteDecodeErrorZ_free(struct LDKCResult_RouteDecodeErrorZ _res); + +/** + * Creates a new CResult_RouteDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_RouteDecodeErrorZ CResult_RouteDecodeErrorZ_clone(const struct LDKCResult_RouteDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_RouteParametersDecodeErrorZ in the success state. + */ +struct LDKCResult_RouteParametersDecodeErrorZ CResult_RouteParametersDecodeErrorZ_ok(struct LDKRouteParameters o); + +/** + * Creates a new CResult_RouteParametersDecodeErrorZ in the error state. + */ +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. + */ +void CResult_RouteParametersDecodeErrorZ_free(struct LDKCResult_RouteParametersDecodeErrorZ _res); + +/** + * Creates a new CResult_RouteParametersDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_RouteParametersDecodeErrorZ CResult_RouteParametersDecodeErrorZ_clone(const struct LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR orig); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_RouteHintZ_free(struct LDKCVec_RouteHintZ _res); + +/** + * Constructs a new COption_u64Z containing a u64 + */ +struct LDKCOption_u64Z COption_u64Z_some(uint64_t o); + +/** + * Constructs a new COption_u64Z containing nothing + */ +struct LDKCOption_u64Z COption_u64Z_none(void); + +/** + * Frees any resources associated with the u64, if we are in the Some state + */ +void COption_u64Z_free(struct LDKCOption_u64Z _res); + +/** + * Creates a new COption_u64Z which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCOption_u64Z COption_u64Z_clone(const struct LDKCOption_u64Z *NONNULL_PTR orig); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_u64Z_free(struct LDKCVec_u64Z _res); + +/** + * 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_PaymentPurposeDecodeErrorZ in the success state. + */ +struct LDKCResult_PaymentPurposeDecodeErrorZ CResult_PaymentPurposeDecodeErrorZ_ok(struct LDKPaymentPurpose o); + +/** + * Creates a new CResult_PaymentPurposeDecodeErrorZ in the error state. + */ +struct LDKCResult_PaymentPurposeDecodeErrorZ CResult_PaymentPurposeDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_PaymentPurposeDecodeErrorZ_is_ok(const struct LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_PaymentPurposeDecodeErrorZ. + */ +void CResult_PaymentPurposeDecodeErrorZ_free(struct LDKCResult_PaymentPurposeDecodeErrorZ _res); + +/** + * Creates a new CResult_PaymentPurposeDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_PaymentPurposeDecodeErrorZ CResult_PaymentPurposeDecodeErrorZ_clone(const struct LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR orig); + +/** + * Constructs a new COption_ClosureReasonZ containing a crate::lightning::util::events::ClosureReason + */ +struct LDKCOption_ClosureReasonZ COption_ClosureReasonZ_some(struct LDKClosureReason o); + +/** + * Constructs a new COption_ClosureReasonZ containing nothing + */ +struct LDKCOption_ClosureReasonZ COption_ClosureReasonZ_none(void); + +/** + * Frees any resources associated with the crate::lightning::util::events::ClosureReason, if we are in the Some state + */ +void COption_ClosureReasonZ_free(struct LDKCOption_ClosureReasonZ _res); + +/** + * Creates a new COption_ClosureReasonZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCOption_ClosureReasonZ COption_ClosureReasonZ_clone(const struct LDKCOption_ClosureReasonZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_COption_ClosureReasonZDecodeErrorZ in the success state. + */ +struct LDKCResult_COption_ClosureReasonZDecodeErrorZ CResult_COption_ClosureReasonZDecodeErrorZ_ok(struct LDKCOption_ClosureReasonZ o); + +/** + * Creates a new CResult_COption_ClosureReasonZDecodeErrorZ in the error state. + */ +struct LDKCResult_COption_ClosureReasonZDecodeErrorZ CResult_COption_ClosureReasonZDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(const struct LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_COption_ClosureReasonZDecodeErrorZ. + */ +void CResult_COption_ClosureReasonZDecodeErrorZ_free(struct LDKCResult_COption_ClosureReasonZDecodeErrorZ _res); + +/** + * Creates a new CResult_COption_ClosureReasonZDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_COption_ClosureReasonZDecodeErrorZ CResult_COption_ClosureReasonZDecodeErrorZ_clone(const struct LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR orig); + +/** + * Constructs a new COption_HTLCDestinationZ containing a crate::lightning::util::events::HTLCDestination + */ +struct LDKCOption_HTLCDestinationZ COption_HTLCDestinationZ_some(struct LDKHTLCDestination o); + +/** + * Constructs a new COption_HTLCDestinationZ containing nothing + */ +struct LDKCOption_HTLCDestinationZ COption_HTLCDestinationZ_none(void); + +/** + * Frees any resources associated with the crate::lightning::util::events::HTLCDestination, if we are in the Some state + */ +void COption_HTLCDestinationZ_free(struct LDKCOption_HTLCDestinationZ _res); + +/** + * Creates a new COption_HTLCDestinationZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCOption_HTLCDestinationZ COption_HTLCDestinationZ_clone(const struct LDKCOption_HTLCDestinationZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_COption_HTLCDestinationZDecodeErrorZ in the success state. + */ +struct LDKCResult_COption_HTLCDestinationZDecodeErrorZ CResult_COption_HTLCDestinationZDecodeErrorZ_ok(struct LDKCOption_HTLCDestinationZ o); + +/** + * Creates a new CResult_COption_HTLCDestinationZDecodeErrorZ in the error state. + */ +struct LDKCResult_COption_HTLCDestinationZDecodeErrorZ CResult_COption_HTLCDestinationZDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_COption_HTLCDestinationZDecodeErrorZ_is_ok(const struct LDKCResult_COption_HTLCDestinationZDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_COption_HTLCDestinationZDecodeErrorZ. + */ +void CResult_COption_HTLCDestinationZDecodeErrorZ_free(struct LDKCResult_COption_HTLCDestinationZDecodeErrorZ _res); + +/** + * Creates a new CResult_COption_HTLCDestinationZDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_COption_HTLCDestinationZDecodeErrorZ CResult_COption_HTLCDestinationZDecodeErrorZ_clone(const struct LDKCResult_COption_HTLCDestinationZDecodeErrorZ *NONNULL_PTR orig); + +/** + * Constructs a new COption_NetworkUpdateZ containing a crate::lightning::routing::gossip::NetworkUpdate + */ +struct LDKCOption_NetworkUpdateZ COption_NetworkUpdateZ_some(struct LDKNetworkUpdate o); + +/** + * Constructs a new COption_NetworkUpdateZ containing nothing + */ +struct LDKCOption_NetworkUpdateZ COption_NetworkUpdateZ_none(void); + +/** + * Frees any resources associated with the crate::lightning::routing::gossip::NetworkUpdate, if we are in the Some state + */ +void COption_NetworkUpdateZ_free(struct LDKCOption_NetworkUpdateZ _res); + +/** + * Creates a new COption_NetworkUpdateZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCOption_NetworkUpdateZ COption_NetworkUpdateZ_clone(const struct LDKCOption_NetworkUpdateZ *NONNULL_PTR orig); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_SpendableOutputDescriptorZ_free(struct LDKCVec_SpendableOutputDescriptorZ _res); + +/** + * Constructs a new COption_EventZ containing a crate::lightning::util::events::Event + */ +struct LDKCOption_EventZ COption_EventZ_some(struct LDKEvent o); + +/** + * Constructs a new COption_EventZ containing nothing + */ +struct LDKCOption_EventZ COption_EventZ_none(void); + +/** + * Frees any resources associated with the crate::lightning::util::events::Event, if we are in the Some state + */ +void COption_EventZ_free(struct LDKCOption_EventZ _res); + +/** + * Creates a new COption_EventZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCOption_EventZ COption_EventZ_clone(const struct LDKCOption_EventZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_COption_EventZDecodeErrorZ in the success state. + */ +struct LDKCResult_COption_EventZDecodeErrorZ CResult_COption_EventZDecodeErrorZ_ok(struct LDKCOption_EventZ o); + +/** + * Creates a new CResult_COption_EventZDecodeErrorZ in the error state. + */ +struct LDKCResult_COption_EventZDecodeErrorZ CResult_COption_EventZDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_COption_EventZDecodeErrorZ_is_ok(const struct LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_COption_EventZDecodeErrorZ. + */ +void CResult_COption_EventZDecodeErrorZ_free(struct LDKCResult_COption_EventZDecodeErrorZ _res); + +/** + * Creates a new CResult_COption_EventZDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_COption_EventZDecodeErrorZ CResult_COption_EventZDecodeErrorZ_clone(const struct LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR orig); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_MessageSendEventZ_free(struct LDKCVec_MessageSendEventZ _res); + +/** + * 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); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_MonitorEventZ_free(struct LDKCVec_MonitorEventZ _res); + +/** + * Creates a new tuple which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone(const struct LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR orig); + +/** + * Creates a new C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ from the contained elements. + */ +struct LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_new(struct LDKOutPoint a, struct LDKCVec_MonitorEventZ b, struct LDKPublicKey c); + +/** + * Frees any resources used by the C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ. + */ +void C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_free(struct LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ _res); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ_free(struct LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ _res); + +/** + * Creates a new CResult_FixedPenaltyScorerDecodeErrorZ in the success state. + */ +struct LDKCResult_FixedPenaltyScorerDecodeErrorZ CResult_FixedPenaltyScorerDecodeErrorZ_ok(struct LDKFixedPenaltyScorer o); + +/** + * Creates a new CResult_FixedPenaltyScorerDecodeErrorZ in the error state. + */ +struct LDKCResult_FixedPenaltyScorerDecodeErrorZ CResult_FixedPenaltyScorerDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_FixedPenaltyScorerDecodeErrorZ_is_ok(const struct LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_FixedPenaltyScorerDecodeErrorZ. + */ +void CResult_FixedPenaltyScorerDecodeErrorZ_free(struct LDKCResult_FixedPenaltyScorerDecodeErrorZ _res); + +/** + * Creates a new CResult_FixedPenaltyScorerDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_FixedPenaltyScorerDecodeErrorZ CResult_FixedPenaltyScorerDecodeErrorZ_clone(const struct LDKCResult_FixedPenaltyScorerDecodeErrorZ *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_u64u64Z C2Tuple_u64u64Z_clone(const struct LDKC2Tuple_u64u64Z *NONNULL_PTR orig); + +/** + * Creates a new C2Tuple_u64u64Z from the contained elements. + */ +struct LDKC2Tuple_u64u64Z C2Tuple_u64u64Z_new(uint64_t a, uint64_t b); + +/** + * Frees any resources used by the C2Tuple_u64u64Z. + */ +void C2Tuple_u64u64Z_free(struct LDKC2Tuple_u64u64Z _res); + +/** + * Constructs a new COption_C2Tuple_u64u64ZZ containing a crate::c_types::derived::C2Tuple_u64u64Z + */ +struct LDKCOption_C2Tuple_u64u64ZZ COption_C2Tuple_u64u64ZZ_some(struct LDKC2Tuple_u64u64Z o); + +/** + * Constructs a new COption_C2Tuple_u64u64ZZ containing nothing + */ +struct LDKCOption_C2Tuple_u64u64ZZ COption_C2Tuple_u64u64ZZ_none(void); + +/** + * Frees any resources associated with the crate::c_types::derived::C2Tuple_u64u64Z, if we are in the Some state + */ +void COption_C2Tuple_u64u64ZZ_free(struct LDKCOption_C2Tuple_u64u64ZZ _res); + +/** + * Creates a new COption_C2Tuple_u64u64ZZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCOption_C2Tuple_u64u64ZZ COption_C2Tuple_u64u64ZZ_clone(const struct LDKCOption_C2Tuple_u64u64ZZ *NONNULL_PTR orig); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_NodeIdZ_free(struct LDKCVec_NodeIdZ _res); + +/** + * Creates a new CResult_ProbabilisticScorerDecodeErrorZ in the success state. + */ +struct LDKCResult_ProbabilisticScorerDecodeErrorZ CResult_ProbabilisticScorerDecodeErrorZ_ok(struct LDKProbabilisticScorer o); + +/** + * Creates a new CResult_ProbabilisticScorerDecodeErrorZ in the error state. + */ +struct LDKCResult_ProbabilisticScorerDecodeErrorZ CResult_ProbabilisticScorerDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_ProbabilisticScorerDecodeErrorZ_is_ok(const struct LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_ProbabilisticScorerDecodeErrorZ. + */ +void CResult_ProbabilisticScorerDecodeErrorZ_free(struct LDKCResult_ProbabilisticScorerDecodeErrorZ _res); + +/** + * Creates a new CResult_InitFeaturesDecodeErrorZ in the success state. + */ +struct LDKCResult_InitFeaturesDecodeErrorZ CResult_InitFeaturesDecodeErrorZ_ok(struct LDKInitFeatures o); + +/** + * Creates a new CResult_InitFeaturesDecodeErrorZ in the error state. + */ +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_InitFeaturesDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_InitFeaturesDecodeErrorZ CResult_InitFeaturesDecodeErrorZ_clone(const struct LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_ChannelFeaturesDecodeErrorZ in the success state. + */ +struct LDKCResult_ChannelFeaturesDecodeErrorZ CResult_ChannelFeaturesDecodeErrorZ_ok(struct LDKChannelFeatures o); + +/** + * Creates a new CResult_ChannelFeaturesDecodeErrorZ in the error state. + */ +struct LDKCResult_ChannelFeaturesDecodeErrorZ CResult_ChannelFeaturesDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_ChannelFeaturesDecodeErrorZ_is_ok(const struct LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_ChannelFeaturesDecodeErrorZ. + */ +void CResult_ChannelFeaturesDecodeErrorZ_free(struct LDKCResult_ChannelFeaturesDecodeErrorZ _res); + +/** + * Creates a new CResult_ChannelFeaturesDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_ChannelFeaturesDecodeErrorZ CResult_ChannelFeaturesDecodeErrorZ_clone(const struct LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_NodeFeaturesDecodeErrorZ in the success state. + */ +struct LDKCResult_NodeFeaturesDecodeErrorZ CResult_NodeFeaturesDecodeErrorZ_ok(struct LDKNodeFeatures o); + +/** + * Creates a new CResult_NodeFeaturesDecodeErrorZ in the error state. + */ +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_NodeFeaturesDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_NodeFeaturesDecodeErrorZ CResult_NodeFeaturesDecodeErrorZ_clone(const struct LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_InvoiceFeaturesDecodeErrorZ in the success state. + */ +struct LDKCResult_InvoiceFeaturesDecodeErrorZ CResult_InvoiceFeaturesDecodeErrorZ_ok(struct LDKInvoiceFeatures o); + +/** + * Creates a new CResult_InvoiceFeaturesDecodeErrorZ in the error state. + */ +struct LDKCResult_InvoiceFeaturesDecodeErrorZ CResult_InvoiceFeaturesDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_InvoiceFeaturesDecodeErrorZ_is_ok(const struct LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_InvoiceFeaturesDecodeErrorZ. + */ +void CResult_InvoiceFeaturesDecodeErrorZ_free(struct LDKCResult_InvoiceFeaturesDecodeErrorZ _res); + +/** + * Creates a new CResult_InvoiceFeaturesDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_InvoiceFeaturesDecodeErrorZ CResult_InvoiceFeaturesDecodeErrorZ_clone(const struct LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_ChannelTypeFeaturesDecodeErrorZ in the success state. + */ +struct LDKCResult_ChannelTypeFeaturesDecodeErrorZ CResult_ChannelTypeFeaturesDecodeErrorZ_ok(struct LDKChannelTypeFeatures o); + +/** + * Creates a new CResult_ChannelTypeFeaturesDecodeErrorZ in the error state. + */ +struct LDKCResult_ChannelTypeFeaturesDecodeErrorZ CResult_ChannelTypeFeaturesDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(const struct LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_ChannelTypeFeaturesDecodeErrorZ. + */ +void CResult_ChannelTypeFeaturesDecodeErrorZ_free(struct LDKCResult_ChannelTypeFeaturesDecodeErrorZ _res); + +/** + * Creates a new CResult_ChannelTypeFeaturesDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_ChannelTypeFeaturesDecodeErrorZ CResult_ChannelTypeFeaturesDecodeErrorZ_clone(const struct LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_NodeIdDecodeErrorZ in the success state. + */ +struct LDKCResult_NodeIdDecodeErrorZ CResult_NodeIdDecodeErrorZ_ok(struct LDKNodeId o); + +/** + * Creates a new CResult_NodeIdDecodeErrorZ in the error state. + */ +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. + */ +void CResult_NodeIdDecodeErrorZ_free(struct LDKCResult_NodeIdDecodeErrorZ _res); + +/** + * Creates a new CResult_NodeIdDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +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 + */ +struct LDKCOption_AccessZ COption_AccessZ_some(struct LDKAccess o); + +/** + * Constructs a new COption_AccessZ containing nothing + */ +struct LDKCOption_AccessZ COption_AccessZ_none(void); + +/** + * Frees any resources associated with the crate::lightning::chain::Access, if we are in the Some state + */ +void COption_AccessZ_free(struct LDKCOption_AccessZ _res); + +/** + * Creates a new CResult_boolLightningErrorZ in the success state. + */ +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); + +/** + * 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. + */ +void CResult_boolLightningErrorZ_free(struct LDKCResult_boolLightningErrorZ _res); + +/** + * Creates a new CResult_boolLightningErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_boolLightningErrorZ CResult_boolLightningErrorZ_clone(const struct LDKCResult_boolLightningErrorZ *NONNULL_PTR orig); + +/** + * Creates a new tuple which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(const struct LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR orig); + +/** + * Creates a new C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ from the contained elements. + */ +struct LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(struct LDKChannelAnnouncement a, struct LDKChannelUpdate b, struct LDKChannelUpdate c); + +/** + * Frees any resources used by the C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ. + */ +void C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(struct LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res); + +/** + * Constructs a new COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ containing a crate::c_types::derived::C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ + */ +struct LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_some(struct LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ o); + +/** + * Constructs a new COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ containing nothing + */ +struct LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_none(void); + +/** + * Frees any resources associated with the crate::c_types::derived::C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ, if we are in the Some state + */ +void COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(struct LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res); + +/** + * Creates a new COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const struct LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_NoneLightningErrorZ in the success state. + */ +struct LDKCResult_NoneLightningErrorZ CResult_NoneLightningErrorZ_ok(void); + +/** + * Creates a new CResult_NoneLightningErrorZ in the error state. + */ +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. + */ +void CResult_NoneLightningErrorZ_free(struct LDKCResult_NoneLightningErrorZ _res); + +/** + * Creates a new CResult_NoneLightningErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_NoneLightningErrorZ CResult_NoneLightningErrorZ_clone(const struct LDKCResult_NoneLightningErrorZ *NONNULL_PTR orig); + +/** + * 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_ChannelUpdateInfoDecodeErrorZ CResult_ChannelUpdateInfoDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_ChannelUpdateInfoDecodeErrorZ_is_ok(const struct LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_ChannelUpdateInfoDecodeErrorZ. + */ +void CResult_ChannelUpdateInfoDecodeErrorZ_free(struct LDKCResult_ChannelUpdateInfoDecodeErrorZ _res); + +/** + * Creates a new CResult_ChannelUpdateInfoDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_ChannelUpdateInfoDecodeErrorZ CResult_ChannelUpdateInfoDecodeErrorZ_clone(const struct LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_ChannelInfoDecodeErrorZ in the success state. + */ +struct LDKCResult_ChannelInfoDecodeErrorZ CResult_ChannelInfoDecodeErrorZ_ok(struct LDKChannelInfo o); + +/** + * Creates a new CResult_ChannelInfoDecodeErrorZ in the error state. + */ +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. + */ +void CResult_ChannelInfoDecodeErrorZ_free(struct LDKCResult_ChannelInfoDecodeErrorZ _res); + +/** + * Creates a new CResult_ChannelInfoDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_ChannelInfoDecodeErrorZ CResult_ChannelInfoDecodeErrorZ_clone(const struct LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_RoutingFeesDecodeErrorZ in the success state. + */ +struct LDKCResult_RoutingFeesDecodeErrorZ CResult_RoutingFeesDecodeErrorZ_ok(struct LDKRoutingFees o); + +/** + * Creates a new CResult_RoutingFeesDecodeErrorZ in the error state. + */ +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. + */ +void CResult_RoutingFeesDecodeErrorZ_free(struct LDKCResult_RoutingFeesDecodeErrorZ _res); + +/** + * Creates a new CResult_RoutingFeesDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_RoutingFeesDecodeErrorZ CResult_RoutingFeesDecodeErrorZ_clone(const struct LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR orig); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_NetAddressZ_free(struct LDKCVec_NetAddressZ _res); + +/** + * Creates a new CResult_NodeAnnouncementInfoDecodeErrorZ in the success state. + */ +struct LDKCResult_NodeAnnouncementInfoDecodeErrorZ CResult_NodeAnnouncementInfoDecodeErrorZ_ok(struct LDKNodeAnnouncementInfo o); + +/** + * Creates a new CResult_NodeAnnouncementInfoDecodeErrorZ in the error state. + */ +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. + */ +void CResult_NodeAnnouncementInfoDecodeErrorZ_free(struct LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res); + +/** + * Creates a new CResult_NodeAnnouncementInfoDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_NodeAnnouncementInfoDecodeErrorZ CResult_NodeAnnouncementInfoDecodeErrorZ_clone(const struct LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_NodeAliasDecodeErrorZ in the success state. + */ +struct LDKCResult_NodeAliasDecodeErrorZ CResult_NodeAliasDecodeErrorZ_ok(struct LDKNodeAlias o); + +/** + * Creates a new CResult_NodeAliasDecodeErrorZ in the error state. + */ +struct LDKCResult_NodeAliasDecodeErrorZ CResult_NodeAliasDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_NodeAliasDecodeErrorZ_is_ok(const struct LDKCResult_NodeAliasDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_NodeAliasDecodeErrorZ. + */ +void CResult_NodeAliasDecodeErrorZ_free(struct LDKCResult_NodeAliasDecodeErrorZ _res); + +/** + * Creates a new CResult_NodeAliasDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_NodeAliasDecodeErrorZ CResult_NodeAliasDecodeErrorZ_clone(const struct LDKCResult_NodeAliasDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_NodeInfoDecodeErrorZ in the success state. + */ +struct LDKCResult_NodeInfoDecodeErrorZ CResult_NodeInfoDecodeErrorZ_ok(struct LDKNodeInfo o); + +/** + * Creates a new CResult_NodeInfoDecodeErrorZ in the error state. + */ +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. + */ +void CResult_NodeInfoDecodeErrorZ_free(struct LDKCResult_NodeInfoDecodeErrorZ _res); + +/** + * Creates a new CResult_NodeInfoDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_NodeInfoDecodeErrorZ CResult_NodeInfoDecodeErrorZ_clone(const struct LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_NetworkGraphDecodeErrorZ in the success state. + */ +struct LDKCResult_NetworkGraphDecodeErrorZ CResult_NetworkGraphDecodeErrorZ_ok(struct LDKNetworkGraph o); + +/** + * Creates a new CResult_NetworkGraphDecodeErrorZ in the error state. + */ +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. + */ +void CResult_NetworkGraphDecodeErrorZ_free(struct LDKCResult_NetworkGraphDecodeErrorZ _res); + +/** + * Constructs a new COption_CVec_NetAddressZZ containing a crate::c_types::derived::CVec_NetAddressZ + */ +struct LDKCOption_CVec_NetAddressZZ COption_CVec_NetAddressZZ_some(struct LDKCVec_NetAddressZ o); + +/** + * Constructs a new COption_CVec_NetAddressZZ containing nothing + */ +struct LDKCOption_CVec_NetAddressZZ COption_CVec_NetAddressZZ_none(void); +/** + * Frees any resources associated with the crate::c_types::derived::CVec_NetAddressZ, if we are in the Some state + */ +void COption_CVec_NetAddressZZ_free(struct LDKCOption_CVec_NetAddressZZ _res); +/** + * Creates a new COption_CVec_NetAddressZZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCOption_CVec_NetAddressZZ COption_CVec_NetAddressZZ_clone(const struct LDKCOption_CVec_NetAddressZZ *NONNULL_PTR orig); /** - * Number of attempts to retry payment path failures for an [`Invoice`]. - * - * Note that this is the number of *path* failures, not full payment retries. For multi-path - * payments, if this is less than the total number of paths, we will never even retry all of the - * payment's paths. + * Creates a new CResult_DelayedPaymentOutputDescriptorDecodeErrorZ in the success state. */ -typedef struct MUST_USE_STRUCT LDKRetryAttempts { - /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. - */ - LDKnativeRetryAttempts *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; -} LDKRetryAttempts; +struct LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(struct LDKDelayedPaymentOutputDescriptor o); +/** + * Creates a new CResult_DelayedPaymentOutputDescriptorDecodeErrorZ in the error state. + */ +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); /** - * A [`Router`] implemented using [`find_route`]. + * Frees any resources used by the CResult_DelayedPaymentOutputDescriptorDecodeErrorZ. */ -typedef struct MUST_USE_STRUCT LDKDefaultRouter { - /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. - */ - LDKnativeDefaultRouter *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; -} LDKDefaultRouter; +void CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(struct LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res); -extern const uintptr_t MAX_BUF_SIZE; +/** + * Creates a new CResult_DelayedPaymentOutputDescriptorDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(const struct LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR orig); -extern const uint64_t MIN_RELAY_FEE_SAT_PER_1000_WEIGHT; +/** + * Creates a new CResult_StaticPaymentOutputDescriptorDecodeErrorZ in the success state. + */ +struct LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(struct LDKStaticPaymentOutputDescriptor o); -extern const uint64_t CLOSED_CHANNEL_UPDATE_ID; +/** + * Creates a new CResult_StaticPaymentOutputDescriptorDecodeErrorZ in the error state. + */ +struct LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(struct LDKDecodeError e); -extern const uint32_t ANTI_REORG_DELAY; +/** + * Checks if the given object is currently in the success state + */ +bool CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(const struct LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR o); -extern const uint16_t BREAKDOWN_TIMEOUT; +/** + * Frees any resources used by the CResult_StaticPaymentOutputDescriptorDecodeErrorZ. + */ +void CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(struct LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res); -extern const uint16_t MIN_CLTV_EXPIRY_DELTA; +/** + * Creates a new CResult_StaticPaymentOutputDescriptorDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(const struct LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR orig); -extern const uint32_t MIN_FINAL_CLTV_EXPIRY; +/** + * Creates a new CResult_SpendableOutputDescriptorDecodeErrorZ in the success state. + */ +struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ CResult_SpendableOutputDescriptorDecodeErrorZ_ok(struct LDKSpendableOutputDescriptor o); -extern const uintptr_t REVOKEABLE_REDEEMSCRIPT_MAX_LENGTH; +/** + * Creates a new CResult_SpendableOutputDescriptorDecodeErrorZ in the error state. + */ +struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ CResult_SpendableOutputDescriptorDecodeErrorZ_err(struct LDKDecodeError e); -extern const uint64_t UNKNOWN_CHANNEL_CAPACITY_MSAT; +/** + * Checks if the given object is currently in the success state + */ +bool CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(const struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR o); -extern const uint32_t DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA; +/** + * Frees any resources used by the CResult_SpendableOutputDescriptorDecodeErrorZ. + */ +void CResult_SpendableOutputDescriptorDecodeErrorZ_free(struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res); -extern const uint64_t MAX_TIMESTAMP; +/** + * Creates a new CResult_SpendableOutputDescriptorDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ CResult_SpendableOutputDescriptorDecodeErrorZ_clone(const struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR orig); -extern const uint64_t DEFAULT_EXPIRY_TIME; +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_PaymentPreimageZ_free(struct LDKCVec_PaymentPreimageZ _res); -extern const uint64_t DEFAULT_MIN_FINAL_CLTV_EXPIRY; +/** + * Creates a new tuple which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKC2Tuple_SignatureCVec_SignatureZZ C2Tuple_SignatureCVec_SignatureZZ_clone(const struct LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR orig); -extern const uint8_t TAG_PAYMENT_HASH; +/** + * Creates a new C2Tuple_SignatureCVec_SignatureZZ from the contained elements. + */ +struct LDKC2Tuple_SignatureCVec_SignatureZZ C2Tuple_SignatureCVec_SignatureZZ_new(struct LDKSignature a, struct LDKCVec_SignatureZ b); -extern const uint8_t TAG_DESCRIPTION; +/** + * Frees any resources used by the C2Tuple_SignatureCVec_SignatureZZ. + */ +void C2Tuple_SignatureCVec_SignatureZZ_free(struct LDKC2Tuple_SignatureCVec_SignatureZZ _res); -extern const uint8_t TAG_PAYEE_PUB_KEY; +/** + * Creates a new CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ in the success state. + */ +struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(struct LDKC2Tuple_SignatureCVec_SignatureZZ o); -extern const uint8_t TAG_DESCRIPTION_HASH; +/** + * Creates a new CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ in the error state. + */ +struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err(void); -extern const uint8_t TAG_EXPIRY_TIME; +/** + * 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); -extern const uint8_t TAG_MIN_FINAL_CLTV_EXPIRY; +/** + * Frees any resources used by the CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ. + */ +void CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res); -extern const uint8_t TAG_FALLBACK; +/** + * Creates a new CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(const struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR orig); -extern const uint8_t TAG_PRIVATE_ROUTE; +/** + * Creates a new CResult_SignatureNoneZ in the success state. + */ +struct LDKCResult_SignatureNoneZ CResult_SignatureNoneZ_ok(struct LDKSignature o); -extern const uint8_t TAG_PAYMENT_SECRET; +/** + * Creates a new CResult_SignatureNoneZ in the error state. + */ +struct LDKCResult_SignatureNoneZ CResult_SignatureNoneZ_err(void); -extern const uint8_t TAG_FEATURES; +/** + * Checks if the given object is currently in the success state + */ +bool CResult_SignatureNoneZ_is_ok(const struct LDKCResult_SignatureNoneZ *NONNULL_PTR o); -struct LDKStr _ldk_get_compiled_version(void); +/** + * Frees any resources used by the CResult_SignatureNoneZ. + */ +void CResult_SignatureNoneZ_free(struct LDKCResult_SignatureNoneZ _res); -struct LDKStr _ldk_c_bindings_get_compiled_version(void); +/** + * Creates a new CResult_SignatureNoneZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_SignatureNoneZ CResult_SignatureNoneZ_clone(const struct LDKCResult_SignatureNoneZ *NONNULL_PTR orig); /** - * Frees the data buffer, if data_is_owned is set and datalen > 0. + * Creates a new tuple which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -void Transaction_free(struct LDKTransaction _res); +struct LDKC2Tuple_SignatureSignatureZ C2Tuple_SignatureSignatureZ_clone(const struct LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR orig); /** - * Convenience function for constructing a new TxOut + * Creates a new C2Tuple_SignatureSignatureZ from the contained elements. */ -struct LDKTxOut TxOut_new(struct LDKCVec_u8Z script_pubkey, uint64_t value); +struct LDKC2Tuple_SignatureSignatureZ C2Tuple_SignatureSignatureZ_new(struct LDKSignature a, struct LDKSignature b); /** - * Frees the data pointed to by script_pubkey. + * Frees any resources used by the C2Tuple_SignatureSignatureZ. */ -void TxOut_free(struct LDKTxOut _res); +void C2Tuple_SignatureSignatureZ_free(struct LDKC2Tuple_SignatureSignatureZ _res); /** - * Creates a new TxOut which has the same data as `orig` but with a new script buffer. + * Creates a new CResult_C2Tuple_SignatureSignatureZNoneZ in the success state. */ -struct LDKTxOut TxOut_clone(const struct LDKTxOut *NONNULL_PTR orig); +struct LDKCResult_C2Tuple_SignatureSignatureZNoneZ CResult_C2Tuple_SignatureSignatureZNoneZ_ok(struct LDKC2Tuple_SignatureSignatureZ o); /** - * Frees the data buffer, if chars_is_owned is set and len > 0. + * Creates a new CResult_C2Tuple_SignatureSignatureZNoneZ in the error state. */ -void Str_free(struct LDKStr _res); +struct LDKCResult_C2Tuple_SignatureSignatureZNoneZ CResult_C2Tuple_SignatureSignatureZNoneZ_err(void); -#if defined(LDK_DEBUG_BUILD) /** - * This function exists for memory safety testing purposes. It should never be used in production - * code + * Checks if the given object is currently in the success state */ -const void *__unmangle_inner_ptr(const void *ptr); -#endif +bool CResult_C2Tuple_SignatureSignatureZNoneZ_is_ok(const struct LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR o); /** - * Creates a new CResult_NoneNoneZ in the success state. + * Frees any resources used by the CResult_C2Tuple_SignatureSignatureZNoneZ. */ -struct LDKCResult_NoneNoneZ CResult_NoneNoneZ_ok(void); +void CResult_C2Tuple_SignatureSignatureZNoneZ_free(struct LDKCResult_C2Tuple_SignatureSignatureZNoneZ _res); /** - * Creates a new CResult_NoneNoneZ in the error state. + * 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_NoneNoneZ CResult_NoneNoneZ_err(void); +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_NoneNoneZ_is_ok(const struct LDKCResult_NoneNoneZ *NONNULL_PTR o); +bool CResult_SecretKeyNoneZ_is_ok(const struct LDKCResult_SecretKeyNoneZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_NoneNoneZ. + * Frees any resources used by the CResult_SecretKeyNoneZ. */ -void CResult_NoneNoneZ_free(struct LDKCResult_NoneNoneZ _res); +void CResult_SecretKeyNoneZ_free(struct LDKCResult_SecretKeyNoneZ _res); /** - * Creates a new CResult_NoneNoneZ which has the same data as `orig` + * Creates a new CResult_SecretKeyNoneZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_NoneNoneZ CResult_NoneNoneZ_clone(const struct LDKCResult_NoneNoneZ *NONNULL_PTR orig); +struct LDKCResult_SecretKeyNoneZ CResult_SecretKeyNoneZ_clone(const struct LDKCResult_SecretKeyNoneZ *NONNULL_PTR orig); /** - * Creates a new CResult_CounterpartyCommitmentSecretsDecodeErrorZ in the success state. + * Creates a new CResult_PublicKeyNoneZ in the success state. */ -struct LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok(struct LDKCounterpartyCommitmentSecrets o); +struct LDKCResult_PublicKeyNoneZ CResult_PublicKeyNoneZ_ok(struct LDKPublicKey o); /** - * Creates a new CResult_CounterpartyCommitmentSecretsDecodeErrorZ in the error state. + * Creates a new CResult_PublicKeyNoneZ in the error state. */ -struct LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_PublicKeyNoneZ CResult_PublicKeyNoneZ_err(void); /** * Checks if the given object is currently in the success state */ -bool CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok(const struct LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR o); +bool CResult_PublicKeyNoneZ_is_ok(const struct LDKCResult_PublicKeyNoneZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_CounterpartyCommitmentSecretsDecodeErrorZ. + * Frees any resources used by the CResult_PublicKeyNoneZ. */ -void CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free(struct LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ _res); +void CResult_PublicKeyNoneZ_free(struct LDKCResult_PublicKeyNoneZ _res); /** - * Creates a new CResult_CounterpartyCommitmentSecretsDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_PublicKeyNoneZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(const struct LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_PublicKeyNoneZ CResult_PublicKeyNoneZ_clone(const struct LDKCResult_PublicKeyNoneZ *NONNULL_PTR orig); /** - * Creates a new CResult_SecretKeyErrorZ in the success state. + * Constructs a new COption_ScalarZ containing a crate::c_types::BigEndianScalar */ -struct LDKCResult_SecretKeyErrorZ CResult_SecretKeyErrorZ_ok(struct LDKSecretKey o); +struct LDKCOption_ScalarZ COption_ScalarZ_some(struct LDKBigEndianScalar o); + +/** + * Constructs a new COption_ScalarZ containing nothing + */ +struct LDKCOption_ScalarZ COption_ScalarZ_none(void); + +/** + * Frees any resources associated with the crate::c_types::BigEndianScalar, if we are in the Some state + */ +void COption_ScalarZ_free(struct LDKCOption_ScalarZ _res); + +/** + * Creates a new CResult_SharedSecretNoneZ in the success state. + */ +struct LDKCResult_SharedSecretNoneZ CResult_SharedSecretNoneZ_ok(struct LDKThirtyTwoBytes o); /** - * Creates a new CResult_SecretKeyErrorZ in the error state. + * Creates a new CResult_SharedSecretNoneZ in the error state. */ -struct LDKCResult_SecretKeyErrorZ CResult_SecretKeyErrorZ_err(enum LDKSecp256k1Error e); +struct LDKCResult_SharedSecretNoneZ CResult_SharedSecretNoneZ_err(void); /** * Checks if the given object is currently in the success state */ -bool CResult_SecretKeyErrorZ_is_ok(const struct LDKCResult_SecretKeyErrorZ *NONNULL_PTR o); +bool CResult_SharedSecretNoneZ_is_ok(const struct LDKCResult_SharedSecretNoneZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_SecretKeyErrorZ. + * Frees any resources used by the CResult_SharedSecretNoneZ. */ -void CResult_SecretKeyErrorZ_free(struct LDKCResult_SecretKeyErrorZ _res); +void CResult_SharedSecretNoneZ_free(struct LDKCResult_SharedSecretNoneZ _res); /** - * Creates a new CResult_SecretKeyErrorZ which has the same data as `orig` + * Creates a new CResult_SharedSecretNoneZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_SecretKeyErrorZ CResult_SecretKeyErrorZ_clone(const struct LDKCResult_SecretKeyErrorZ *NONNULL_PTR orig); +struct LDKCResult_SharedSecretNoneZ CResult_SharedSecretNoneZ_clone(const struct LDKCResult_SharedSecretNoneZ *NONNULL_PTR orig); /** - * Creates a new CResult_PublicKeyErrorZ in the success state. + * Creates a new CResult_SignDecodeErrorZ in the success state. */ -struct LDKCResult_PublicKeyErrorZ CResult_PublicKeyErrorZ_ok(struct LDKPublicKey o); +struct LDKCResult_SignDecodeErrorZ CResult_SignDecodeErrorZ_ok(struct LDKSign o); /** - * Creates a new CResult_PublicKeyErrorZ in the error state. + * Creates a new CResult_SignDecodeErrorZ in the error state. */ -struct LDKCResult_PublicKeyErrorZ CResult_PublicKeyErrorZ_err(enum LDKSecp256k1Error e); +struct LDKCResult_SignDecodeErrorZ CResult_SignDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_PublicKeyErrorZ_is_ok(const struct LDKCResult_PublicKeyErrorZ *NONNULL_PTR o); +bool CResult_SignDecodeErrorZ_is_ok(const struct LDKCResult_SignDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_PublicKeyErrorZ. + * Frees any resources used by the CResult_SignDecodeErrorZ. */ -void CResult_PublicKeyErrorZ_free(struct LDKCResult_PublicKeyErrorZ _res); +void CResult_SignDecodeErrorZ_free(struct LDKCResult_SignDecodeErrorZ _res); /** - * Creates a new CResult_PublicKeyErrorZ which has the same data as `orig` + * Creates a new CResult_SignDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_PublicKeyErrorZ CResult_PublicKeyErrorZ_clone(const struct LDKCResult_PublicKeyErrorZ *NONNULL_PTR orig); +struct LDKCResult_SignDecodeErrorZ CResult_SignDecodeErrorZ_clone(const struct LDKCResult_SignDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_TxCreationKeysDecodeErrorZ in the success state. + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -struct LDKCResult_TxCreationKeysDecodeErrorZ CResult_TxCreationKeysDecodeErrorZ_ok(struct LDKTxCreationKeys o); +void CVec_u5Z_free(struct LDKCVec_u5Z _res); /** - * Creates a new CResult_TxCreationKeysDecodeErrorZ in the error state. + * Creates a new CResult_RecoverableSignatureNoneZ in the success state. */ -struct LDKCResult_TxCreationKeysDecodeErrorZ CResult_TxCreationKeysDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_RecoverableSignatureNoneZ CResult_RecoverableSignatureNoneZ_ok(struct LDKRecoverableSignature o); /** - * Checks if the given object is currently in the success state + * Creates a new CResult_RecoverableSignatureNoneZ in the error state. */ -bool CResult_TxCreationKeysDecodeErrorZ_is_ok(const struct LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR o); +struct LDKCResult_RecoverableSignatureNoneZ CResult_RecoverableSignatureNoneZ_err(void); /** - * Frees any resources used by the CResult_TxCreationKeysDecodeErrorZ. + * Checks if the given object is currently in the success state */ -void CResult_TxCreationKeysDecodeErrorZ_free(struct LDKCResult_TxCreationKeysDecodeErrorZ _res); +bool CResult_RecoverableSignatureNoneZ_is_ok(const struct LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR o); /** - * Creates a new CResult_TxCreationKeysDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Frees any resources used by the CResult_RecoverableSignatureNoneZ. */ -struct LDKCResult_TxCreationKeysDecodeErrorZ CResult_TxCreationKeysDecodeErrorZ_clone(const struct LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR orig); +void CResult_RecoverableSignatureNoneZ_free(struct LDKCResult_RecoverableSignatureNoneZ _res); /** - * Creates a new CResult_ChannelPublicKeysDecodeErrorZ in the success state. + * Creates a new CResult_RecoverableSignatureNoneZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_ChannelPublicKeysDecodeErrorZ CResult_ChannelPublicKeysDecodeErrorZ_ok(struct LDKChannelPublicKeys o); +struct LDKCResult_RecoverableSignatureNoneZ CResult_RecoverableSignatureNoneZ_clone(const struct LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR orig); /** - * Creates a new CResult_ChannelPublicKeysDecodeErrorZ in the error state. + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -struct LDKCResult_ChannelPublicKeysDecodeErrorZ CResult_ChannelPublicKeysDecodeErrorZ_err(struct LDKDecodeError e); +void CVec_u8Z_free(struct LDKCVec_u8Z _res); /** - * Checks if the given object is currently in the success state + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -bool CResult_ChannelPublicKeysDecodeErrorZ_is_ok(const struct LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR o); +void CVec_CVec_u8ZZ_free(struct LDKCVec_CVec_u8ZZ _res); /** - * Frees any resources used by the CResult_ChannelPublicKeysDecodeErrorZ. + * Creates a new CResult_CVec_CVec_u8ZZNoneZ in the success state. */ -void CResult_ChannelPublicKeysDecodeErrorZ_free(struct LDKCResult_ChannelPublicKeysDecodeErrorZ _res); +struct LDKCResult_CVec_CVec_u8ZZNoneZ CResult_CVec_CVec_u8ZZNoneZ_ok(struct LDKCVec_CVec_u8ZZ o); /** - * Creates a new CResult_ChannelPublicKeysDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Creates a new CResult_CVec_CVec_u8ZZNoneZ in the error state. */ -struct LDKCResult_ChannelPublicKeysDecodeErrorZ CResult_ChannelPublicKeysDecodeErrorZ_clone(const struct LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_CVec_CVec_u8ZZNoneZ CResult_CVec_CVec_u8ZZNoneZ_err(void); /** - * Creates a new CResult_TxCreationKeysErrorZ in the success state. + * Checks if the given object is currently in the success state */ -struct LDKCResult_TxCreationKeysErrorZ CResult_TxCreationKeysErrorZ_ok(struct LDKTxCreationKeys o); +bool CResult_CVec_CVec_u8ZZNoneZ_is_ok(const struct LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR o); /** - * Creates a new CResult_TxCreationKeysErrorZ in the error state. + * Frees any resources used by the CResult_CVec_CVec_u8ZZNoneZ. */ -struct LDKCResult_TxCreationKeysErrorZ CResult_TxCreationKeysErrorZ_err(enum LDKSecp256k1Error e); +void CResult_CVec_CVec_u8ZZNoneZ_free(struct LDKCResult_CVec_CVec_u8ZZNoneZ _res); /** - * Checks if the given object is currently in the success state + * Creates a new CResult_CVec_CVec_u8ZZNoneZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -bool CResult_TxCreationKeysErrorZ_is_ok(const struct LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR o); +struct LDKCResult_CVec_CVec_u8ZZNoneZ CResult_CVec_CVec_u8ZZNoneZ_clone(const struct LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR orig); /** - * Frees any resources used by the CResult_TxCreationKeysErrorZ. + * Creates a new CResult_InMemorySignerDecodeErrorZ in the success state. */ -void CResult_TxCreationKeysErrorZ_free(struct LDKCResult_TxCreationKeysErrorZ _res); +struct LDKCResult_InMemorySignerDecodeErrorZ CResult_InMemorySignerDecodeErrorZ_ok(struct LDKInMemorySigner o); /** - * Creates a new CResult_TxCreationKeysErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Creates a new CResult_InMemorySignerDecodeErrorZ in the error state. */ -struct LDKCResult_TxCreationKeysErrorZ CResult_TxCreationKeysErrorZ_clone(const struct LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR orig); +struct LDKCResult_InMemorySignerDecodeErrorZ CResult_InMemorySignerDecodeErrorZ_err(struct LDKDecodeError e); /** - * Constructs a new COption_u32Z containing a u32 + * Checks if the given object is currently in the success state */ -struct LDKCOption_u32Z COption_u32Z_some(uint32_t o); +bool CResult_InMemorySignerDecodeErrorZ_is_ok(const struct LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR o); /** - * Constructs a new COption_u32Z containing nothing + * Frees any resources used by the CResult_InMemorySignerDecodeErrorZ. */ -struct LDKCOption_u32Z COption_u32Z_none(void); +void CResult_InMemorySignerDecodeErrorZ_free(struct LDKCResult_InMemorySignerDecodeErrorZ _res); /** - * Frees any resources associated with the u32, if we are in the Some state + * Creates a new CResult_InMemorySignerDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -void COption_u32Z_free(struct LDKCOption_u32Z _res); +struct LDKCResult_InMemorySignerDecodeErrorZ CResult_InMemorySignerDecodeErrorZ_clone(const struct LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new COption_u32Z which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -struct LDKCOption_u32Z COption_u32Z_clone(const struct LDKCOption_u32Z *NONNULL_PTR orig); +void CVec_TxOutZ_free(struct LDKCVec_TxOutZ _res); /** - * Creates a new CResult_HTLCOutputInCommitmentDecodeErrorZ in the success state. + * Creates a new CResult_TransactionNoneZ in the success state. */ -struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(struct LDKHTLCOutputInCommitment o); +struct LDKCResult_TransactionNoneZ CResult_TransactionNoneZ_ok(struct LDKTransaction o); /** - * Creates a new CResult_HTLCOutputInCommitmentDecodeErrorZ in the error state. + * Creates a new CResult_TransactionNoneZ in the error state. */ -struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ CResult_HTLCOutputInCommitmentDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_TransactionNoneZ CResult_TransactionNoneZ_err(void); /** * Checks if the given object is currently in the success state */ -bool CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(const struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR o); +bool CResult_TransactionNoneZ_is_ok(const struct LDKCResult_TransactionNoneZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_HTLCOutputInCommitmentDecodeErrorZ. + * Frees any resources used by the CResult_TransactionNoneZ. */ -void CResult_HTLCOutputInCommitmentDecodeErrorZ_free(struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res); +void CResult_TransactionNoneZ_free(struct LDKCResult_TransactionNoneZ _res); /** - * Creates a new CResult_HTLCOutputInCommitmentDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_TransactionNoneZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(const struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_TransactionNoneZ CResult_TransactionNoneZ_clone(const struct LDKCResult_TransactionNoneZ *NONNULL_PTR orig); /** - * Constructs a new COption_NoneZ containing a + * Creates a new C2Tuple_BlockHashChannelMonitorZ from the contained elements. */ -enum LDKCOption_NoneZ COption_NoneZ_some(void); +struct LDKC2Tuple_BlockHashChannelMonitorZ C2Tuple_BlockHashChannelMonitorZ_new(struct LDKThirtyTwoBytes a, struct LDKChannelMonitor b); /** - * Constructs a new COption_NoneZ containing nothing + * Frees any resources used by the C2Tuple_BlockHashChannelMonitorZ. */ -enum LDKCOption_NoneZ COption_NoneZ_none(void); +void C2Tuple_BlockHashChannelMonitorZ_free(struct LDKC2Tuple_BlockHashChannelMonitorZ _res); /** - * Frees any resources associated with the , if we are in the Some state + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -void COption_NoneZ_free(enum LDKCOption_NoneZ _res); +void CVec_C2Tuple_BlockHashChannelMonitorZZ_free(struct LDKCVec_C2Tuple_BlockHashChannelMonitorZZ _res); /** - * Creates a new CResult_CounterpartyChannelTransactionParametersDecodeErrorZ in the success state. + * Creates a new CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ in the success state. */ -struct LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(struct LDKCounterpartyChannelTransactionParameters o); +struct LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(struct LDKCVec_C2Tuple_BlockHashChannelMonitorZZ o); /** - * Creates a new CResult_CounterpartyChannelTransactionParametersDecodeErrorZ in the error state. + * Creates a new CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ in the error state. */ -struct LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(struct LDKDecodeError e); +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_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(const struct LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR o); - -/** - * Frees any resources used by the CResult_CounterpartyChannelTransactionParametersDecodeErrorZ. - */ -void CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(struct LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res); +bool CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_is_ok(const struct LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR o); /** - * Creates a new CResult_CounterpartyChannelTransactionParametersDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Frees any resources used by the CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ. */ -struct LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(const struct LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR orig); +void CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(struct LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ _res); /** - * Creates a new CResult_ChannelTransactionParametersDecodeErrorZ in the success state. + * Constructs a new COption_u16Z containing a u16 */ -struct LDKCResult_ChannelTransactionParametersDecodeErrorZ CResult_ChannelTransactionParametersDecodeErrorZ_ok(struct LDKChannelTransactionParameters o); +struct LDKCOption_u16Z COption_u16Z_some(uint16_t o); /** - * Creates a new CResult_ChannelTransactionParametersDecodeErrorZ in the error state. + * Constructs a new COption_u16Z containing nothing */ -struct LDKCResult_ChannelTransactionParametersDecodeErrorZ CResult_ChannelTransactionParametersDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCOption_u16Z COption_u16Z_none(void); /** - * Checks if the given object is currently in the success state + * Frees any resources associated with the u16, if we are in the Some state */ -bool CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(const struct LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR o); +void COption_u16Z_free(struct LDKCOption_u16Z _res); /** - * Frees any resources used by the CResult_ChannelTransactionParametersDecodeErrorZ. + * Creates a new COption_u16Z which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -void CResult_ChannelTransactionParametersDecodeErrorZ_free(struct LDKCResult_ChannelTransactionParametersDecodeErrorZ _res); +struct LDKCOption_u16Z COption_u16Z_clone(const struct LDKCOption_u16Z *NONNULL_PTR orig); /** - * Creates a new CResult_ChannelTransactionParametersDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Creates a new CResult_NoneAPIErrorZ in the success state. */ -struct LDKCResult_ChannelTransactionParametersDecodeErrorZ CResult_ChannelTransactionParametersDecodeErrorZ_clone(const struct LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_NoneAPIErrorZ CResult_NoneAPIErrorZ_ok(void); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Creates a new CResult_NoneAPIErrorZ in the error state. */ -void CVec_SignatureZ_free(struct LDKCVec_SignatureZ _res); +struct LDKCResult_NoneAPIErrorZ CResult_NoneAPIErrorZ_err(struct LDKAPIError e); /** - * Creates a new CResult_HolderCommitmentTransactionDecodeErrorZ in the success state. + * Checks if the given object is currently in the success state */ -struct LDKCResult_HolderCommitmentTransactionDecodeErrorZ CResult_HolderCommitmentTransactionDecodeErrorZ_ok(struct LDKHolderCommitmentTransaction o); +bool CResult_NoneAPIErrorZ_is_ok(const struct LDKCResult_NoneAPIErrorZ *NONNULL_PTR o); /** - * Creates a new CResult_HolderCommitmentTransactionDecodeErrorZ in the error state. + * Frees any resources used by the CResult_NoneAPIErrorZ. */ -struct LDKCResult_HolderCommitmentTransactionDecodeErrorZ CResult_HolderCommitmentTransactionDecodeErrorZ_err(struct LDKDecodeError e); +void CResult_NoneAPIErrorZ_free(struct LDKCResult_NoneAPIErrorZ _res); /** - * Checks if the given object is currently in the success state + * Creates a new CResult_NoneAPIErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -bool CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(const struct LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR o); +struct LDKCResult_NoneAPIErrorZ CResult_NoneAPIErrorZ_clone(const struct LDKCResult_NoneAPIErrorZ *NONNULL_PTR orig); /** - * Frees any resources used by the CResult_HolderCommitmentTransactionDecodeErrorZ. + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -void CResult_HolderCommitmentTransactionDecodeErrorZ_free(struct LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res); +void CVec_CResult_NoneAPIErrorZZ_free(struct LDKCVec_CResult_NoneAPIErrorZZ _res); /** - * Creates a new CResult_HolderCommitmentTransactionDecodeErrorZ 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_HolderCommitmentTransactionDecodeErrorZ CResult_HolderCommitmentTransactionDecodeErrorZ_clone(const struct LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR orig); +void CVec_APIErrorZ_free(struct LDKCVec_APIErrorZ _res); /** - * Creates a new CResult_BuiltCommitmentTransactionDecodeErrorZ in the success state. + * Creates a new CResult__u832APIErrorZ in the success state. */ -struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(struct LDKBuiltCommitmentTransaction o); +struct LDKCResult__u832APIErrorZ CResult__u832APIErrorZ_ok(struct LDKThirtyTwoBytes o); /** - * Creates a new CResult_BuiltCommitmentTransactionDecodeErrorZ in the error state. + * Creates a new CResult__u832APIErrorZ in the error state. */ -struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ CResult_BuiltCommitmentTransactionDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult__u832APIErrorZ CResult__u832APIErrorZ_err(struct LDKAPIError e); /** * Checks if the given object is currently in the success state */ -bool CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(const struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR o); +bool CResult__u832APIErrorZ_is_ok(const struct LDKCResult__u832APIErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_BuiltCommitmentTransactionDecodeErrorZ. + * Frees any resources used by the CResult__u832APIErrorZ. */ -void CResult_BuiltCommitmentTransactionDecodeErrorZ_free(struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res); +void CResult__u832APIErrorZ_free(struct LDKCResult__u832APIErrorZ _res); /** - * Creates a new CResult_BuiltCommitmentTransactionDecodeErrorZ which has the same data as `orig` + * Creates a new CResult__u832APIErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(const struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult__u832APIErrorZ CResult__u832APIErrorZ_clone(const struct LDKCResult__u832APIErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_TrustedClosingTransactionNoneZ in the success state. + * Creates a new CResult_PaymentIdPaymentSendFailureZ in the success state. */ -struct LDKCResult_TrustedClosingTransactionNoneZ CResult_TrustedClosingTransactionNoneZ_ok(struct LDKTrustedClosingTransaction o); +struct LDKCResult_PaymentIdPaymentSendFailureZ CResult_PaymentIdPaymentSendFailureZ_ok(struct LDKThirtyTwoBytes o); /** - * Creates a new CResult_TrustedClosingTransactionNoneZ in the error state. + * Creates a new CResult_PaymentIdPaymentSendFailureZ in the error state. */ -struct LDKCResult_TrustedClosingTransactionNoneZ CResult_TrustedClosingTransactionNoneZ_err(void); +struct LDKCResult_PaymentIdPaymentSendFailureZ CResult_PaymentIdPaymentSendFailureZ_err(struct LDKPaymentSendFailure e); /** * 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. - */ -void CResult_TrustedClosingTransactionNoneZ_free(struct LDKCResult_TrustedClosingTransactionNoneZ _res); +bool CResult_PaymentIdPaymentSendFailureZ_is_ok(const struct LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR o); /** - * Creates a new CResult_CommitmentTransactionDecodeErrorZ in the success state. + * Frees any resources used by the CResult_PaymentIdPaymentSendFailureZ. */ -struct LDKCResult_CommitmentTransactionDecodeErrorZ CResult_CommitmentTransactionDecodeErrorZ_ok(struct LDKCommitmentTransaction o); +void CResult_PaymentIdPaymentSendFailureZ_free(struct LDKCResult_PaymentIdPaymentSendFailureZ _res); /** - * Creates a new CResult_CommitmentTransactionDecodeErrorZ in the error state. + * Creates a new CResult_PaymentIdPaymentSendFailureZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_CommitmentTransactionDecodeErrorZ CResult_CommitmentTransactionDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_PaymentIdPaymentSendFailureZ CResult_PaymentIdPaymentSendFailureZ_clone(const struct LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR orig); /** - * Checks if the given object is currently in the success state + * Creates a new CResult_NonePaymentSendFailureZ in the success state. */ -bool CResult_CommitmentTransactionDecodeErrorZ_is_ok(const struct LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR o); +struct LDKCResult_NonePaymentSendFailureZ CResult_NonePaymentSendFailureZ_ok(void); /** - * Frees any resources used by the CResult_CommitmentTransactionDecodeErrorZ. + * Creates a new CResult_NonePaymentSendFailureZ in the error state. */ -void CResult_CommitmentTransactionDecodeErrorZ_free(struct LDKCResult_CommitmentTransactionDecodeErrorZ _res); +struct LDKCResult_NonePaymentSendFailureZ CResult_NonePaymentSendFailureZ_err(struct LDKPaymentSendFailure e); /** - * Creates a new CResult_CommitmentTransactionDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Checks if the given object is currently in the success state */ -struct LDKCResult_CommitmentTransactionDecodeErrorZ CResult_CommitmentTransactionDecodeErrorZ_clone(const struct LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR orig); +bool CResult_NonePaymentSendFailureZ_is_ok(const struct LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR o); /** - * Creates a new CResult_TrustedCommitmentTransactionNoneZ in the success state. + * Frees any resources used by the CResult_NonePaymentSendFailureZ. */ -struct LDKCResult_TrustedCommitmentTransactionNoneZ CResult_TrustedCommitmentTransactionNoneZ_ok(struct LDKTrustedCommitmentTransaction o); +void CResult_NonePaymentSendFailureZ_free(struct LDKCResult_NonePaymentSendFailureZ _res); /** - * Creates a new CResult_TrustedCommitmentTransactionNoneZ in the error state. + * Creates a new CResult_NonePaymentSendFailureZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_TrustedCommitmentTransactionNoneZ CResult_TrustedCommitmentTransactionNoneZ_err(void); +struct LDKCResult_NonePaymentSendFailureZ CResult_NonePaymentSendFailureZ_clone(const struct LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR orig); /** - * Checks if the given object is currently in the success state + * Creates a new tuple which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -bool CResult_TrustedCommitmentTransactionNoneZ_is_ok(const struct LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR o); +struct LDKC2Tuple_PaymentHashPaymentIdZ C2Tuple_PaymentHashPaymentIdZ_clone(const struct LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR orig); /** - * Frees any resources used by the CResult_TrustedCommitmentTransactionNoneZ. + * Creates a new C2Tuple_PaymentHashPaymentIdZ from the contained elements. */ -void CResult_TrustedCommitmentTransactionNoneZ_free(struct LDKCResult_TrustedCommitmentTransactionNoneZ _res); +struct LDKC2Tuple_PaymentHashPaymentIdZ C2Tuple_PaymentHashPaymentIdZ_new(struct LDKThirtyTwoBytes a, struct LDKThirtyTwoBytes b); /** - * Creates a new CResult_CVec_SignatureZNoneZ in the success state. + * Frees any resources used by the C2Tuple_PaymentHashPaymentIdZ. */ -struct LDKCResult_CVec_SignatureZNoneZ CResult_CVec_SignatureZNoneZ_ok(struct LDKCVec_SignatureZ o); +void C2Tuple_PaymentHashPaymentIdZ_free(struct LDKC2Tuple_PaymentHashPaymentIdZ _res); /** - * Creates a new CResult_CVec_SignatureZNoneZ in the error state. + * Creates a new CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ in the success state. */ -struct LDKCResult_CVec_SignatureZNoneZ CResult_CVec_SignatureZNoneZ_err(void); +struct LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(struct LDKC2Tuple_PaymentHashPaymentIdZ o); /** - * Checks if the given object is currently in the success state + * Creates a new CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ in the error state. */ -bool CResult_CVec_SignatureZNoneZ_is_ok(const struct LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR o); +struct LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(struct LDKPaymentSendFailure e); /** - * Frees any resources used by the CResult_CVec_SignatureZNoneZ. + * Checks if the given object is currently in the success state */ -void CResult_CVec_SignatureZNoneZ_free(struct LDKCResult_CVec_SignatureZNoneZ _res); +bool CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok(const struct LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR o); /** - * Creates a new CResult_CVec_SignatureZNoneZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Frees any resources used by the CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ. */ -struct LDKCResult_CVec_SignatureZNoneZ CResult_CVec_SignatureZNoneZ_clone(const struct LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR orig); +void CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(struct LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ _res); /** - * Creates a new CResult_ShutdownScriptDecodeErrorZ in the success state. + * Creates a new CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_ShutdownScriptDecodeErrorZ CResult_ShutdownScriptDecodeErrorZ_ok(struct LDKShutdownScript o); +struct LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(const struct LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR orig); /** - * Creates a new CResult_ShutdownScriptDecodeErrorZ in the error state. + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -struct LDKCResult_ShutdownScriptDecodeErrorZ CResult_ShutdownScriptDecodeErrorZ_err(struct LDKDecodeError e); +void CVec_ThirtyTwoBytesZ_free(struct LDKCVec_ThirtyTwoBytesZ _res); /** - * Checks if the given object is currently in the success state + * Creates a new tuple which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -bool CResult_ShutdownScriptDecodeErrorZ_is_ok(const struct LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR o); +struct LDKC2Tuple_PaymentHashPaymentSecretZ C2Tuple_PaymentHashPaymentSecretZ_clone(const struct LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR orig); /** - * Frees any resources used by the CResult_ShutdownScriptDecodeErrorZ. + * Creates a new C2Tuple_PaymentHashPaymentSecretZ from the contained elements. */ -void CResult_ShutdownScriptDecodeErrorZ_free(struct LDKCResult_ShutdownScriptDecodeErrorZ _res); +struct LDKC2Tuple_PaymentHashPaymentSecretZ C2Tuple_PaymentHashPaymentSecretZ_new(struct LDKThirtyTwoBytes a, struct LDKThirtyTwoBytes b); /** - * Creates a new CResult_ShutdownScriptDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Frees any resources used by the C2Tuple_PaymentHashPaymentSecretZ. */ -struct LDKCResult_ShutdownScriptDecodeErrorZ CResult_ShutdownScriptDecodeErrorZ_clone(const struct LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR orig); +void C2Tuple_PaymentHashPaymentSecretZ_free(struct LDKC2Tuple_PaymentHashPaymentSecretZ _res); /** - * Creates a new CResult_ShutdownScriptInvalidShutdownScriptZ in the success state. + * Creates a new CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ in the success state. */ -struct LDKCResult_ShutdownScriptInvalidShutdownScriptZ CResult_ShutdownScriptInvalidShutdownScriptZ_ok(struct LDKShutdownScript o); +struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok(struct LDKC2Tuple_PaymentHashPaymentSecretZ o); /** - * Creates a new CResult_ShutdownScriptInvalidShutdownScriptZ in the error state. + * Creates a new CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ in the error state. */ -struct LDKCResult_ShutdownScriptInvalidShutdownScriptZ CResult_ShutdownScriptInvalidShutdownScriptZ_err(struct LDKInvalidShutdownScript e); +struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err(void); /** * Checks if the given object is currently in the success state */ -bool CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(const struct LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR o); +bool CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok(const struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_ShutdownScriptInvalidShutdownScriptZ. + * Frees any resources used by the CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ. */ -void CResult_ShutdownScriptInvalidShutdownScriptZ_free(struct LDKCResult_ShutdownScriptInvalidShutdownScriptZ _res); +void CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free(struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ _res); /** - * Creates a new CResult_ShutdownScriptInvalidShutdownScriptZ which has the same data as `orig` + * Creates a new CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_ShutdownScriptInvalidShutdownScriptZ CResult_ShutdownScriptInvalidShutdownScriptZ_clone(const struct LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR orig); +struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(const struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR orig); /** - * Creates a new CResult_NoneErrorZ in the success state. + * Creates a new CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ in the success state. */ -struct LDKCResult_NoneErrorZ CResult_NoneErrorZ_ok(void); +struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok(struct LDKC2Tuple_PaymentHashPaymentSecretZ o); /** - * Creates a new CResult_NoneErrorZ in the error state. + * Creates a new CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ in the error state. */ -struct LDKCResult_NoneErrorZ CResult_NoneErrorZ_err(enum LDKIOError e); +struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err(struct LDKAPIError e); /** * Checks if the given object is currently in the success state */ -bool CResult_NoneErrorZ_is_ok(const struct LDKCResult_NoneErrorZ *NONNULL_PTR o); +bool CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok(const struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_NoneErrorZ. + * Frees any resources used by the CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ. */ -void CResult_NoneErrorZ_free(struct LDKCResult_NoneErrorZ _res); +void CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free(struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ _res); /** - * Creates a new CResult_NoneErrorZ which has the same data as `orig` + * 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_NoneErrorZ CResult_NoneErrorZ_clone(const struct LDKCResult_NoneErrorZ *NONNULL_PTR orig); +struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(const struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_RouteHopDecodeErrorZ in the success state. + * Creates a new CResult_PaymentSecretNoneZ in the success state. */ -struct LDKCResult_RouteHopDecodeErrorZ CResult_RouteHopDecodeErrorZ_ok(struct LDKRouteHop o); +struct LDKCResult_PaymentSecretNoneZ CResult_PaymentSecretNoneZ_ok(struct LDKThirtyTwoBytes o); /** - * Creates a new CResult_RouteHopDecodeErrorZ in the error state. + * Creates a new CResult_PaymentSecretNoneZ in the error state. */ -struct LDKCResult_RouteHopDecodeErrorZ CResult_RouteHopDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_PaymentSecretNoneZ CResult_PaymentSecretNoneZ_err(void); /** * Checks if the given object is currently in the success state */ -bool CResult_RouteHopDecodeErrorZ_is_ok(const struct LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR o); +bool CResult_PaymentSecretNoneZ_is_ok(const struct LDKCResult_PaymentSecretNoneZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_RouteHopDecodeErrorZ. + * Frees any resources used by the CResult_PaymentSecretNoneZ. */ -void CResult_RouteHopDecodeErrorZ_free(struct LDKCResult_RouteHopDecodeErrorZ _res); +void CResult_PaymentSecretNoneZ_free(struct LDKCResult_PaymentSecretNoneZ _res); /** - * Creates a new CResult_RouteHopDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_PaymentSecretNoneZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_RouteHopDecodeErrorZ CResult_RouteHopDecodeErrorZ_clone(const struct LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR orig); - -/** - * Frees the buffer pointed to by `data` if `datalen` is non-0. - */ -void CVec_RouteHopZ_free(struct LDKCVec_RouteHopZ _res); - -/** - * Frees the buffer pointed to by `data` if `datalen` is non-0. - */ -void CVec_CVec_RouteHopZZ_free(struct LDKCVec_CVec_RouteHopZZ _res); +struct LDKCResult_PaymentSecretNoneZ CResult_PaymentSecretNoneZ_clone(const struct LDKCResult_PaymentSecretNoneZ *NONNULL_PTR orig); /** - * Creates a new CResult_RouteDecodeErrorZ in the success state. + * Creates a new CResult_PaymentSecretAPIErrorZ in the success state. */ -struct LDKCResult_RouteDecodeErrorZ CResult_RouteDecodeErrorZ_ok(struct LDKRoute o); +struct LDKCResult_PaymentSecretAPIErrorZ CResult_PaymentSecretAPIErrorZ_ok(struct LDKThirtyTwoBytes o); /** - * Creates a new CResult_RouteDecodeErrorZ in the error state. + * Creates a new CResult_PaymentSecretAPIErrorZ in the error state. */ -struct LDKCResult_RouteDecodeErrorZ CResult_RouteDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_PaymentSecretAPIErrorZ CResult_PaymentSecretAPIErrorZ_err(struct LDKAPIError e); /** * Checks if the given object is currently in the success state */ -bool CResult_RouteDecodeErrorZ_is_ok(const struct LDKCResult_RouteDecodeErrorZ *NONNULL_PTR o); +bool CResult_PaymentSecretAPIErrorZ_is_ok(const struct LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_RouteDecodeErrorZ. + * Frees any resources used by the CResult_PaymentSecretAPIErrorZ. */ -void CResult_RouteDecodeErrorZ_free(struct LDKCResult_RouteDecodeErrorZ _res); +void CResult_PaymentSecretAPIErrorZ_free(struct LDKCResult_PaymentSecretAPIErrorZ _res); /** - * Creates a new CResult_RouteDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_PaymentSecretAPIErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_RouteDecodeErrorZ CResult_RouteDecodeErrorZ_clone(const struct LDKCResult_RouteDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_PaymentSecretAPIErrorZ CResult_PaymentSecretAPIErrorZ_clone(const struct LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_RouteParametersDecodeErrorZ in the success state. + * Creates a new CResult_PaymentPreimageAPIErrorZ in the success state. */ -struct LDKCResult_RouteParametersDecodeErrorZ CResult_RouteParametersDecodeErrorZ_ok(struct LDKRouteParameters o); +struct LDKCResult_PaymentPreimageAPIErrorZ CResult_PaymentPreimageAPIErrorZ_ok(struct LDKThirtyTwoBytes o); /** - * Creates a new CResult_RouteParametersDecodeErrorZ in the error state. + * Creates a new CResult_PaymentPreimageAPIErrorZ in the error state. */ -struct LDKCResult_RouteParametersDecodeErrorZ CResult_RouteParametersDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_PaymentPreimageAPIErrorZ CResult_PaymentPreimageAPIErrorZ_err(struct LDKAPIError e); /** * Checks if the given object is currently in the success state */ -bool CResult_RouteParametersDecodeErrorZ_is_ok(const struct LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR o); +bool CResult_PaymentPreimageAPIErrorZ_is_ok(const struct LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_RouteParametersDecodeErrorZ. + * Frees any resources used by the CResult_PaymentPreimageAPIErrorZ. */ -void CResult_RouteParametersDecodeErrorZ_free(struct LDKCResult_RouteParametersDecodeErrorZ _res); +void CResult_PaymentPreimageAPIErrorZ_free(struct LDKCResult_PaymentPreimageAPIErrorZ _res); /** - * Creates a new CResult_RouteParametersDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_PaymentPreimageAPIErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_RouteParametersDecodeErrorZ CResult_RouteParametersDecodeErrorZ_clone(const struct LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_PaymentPreimageAPIErrorZ CResult_PaymentPreimageAPIErrorZ_clone(const struct LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR orig); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Creates a new CResult_CounterpartyForwardingInfoDecodeErrorZ in the success state. */ -void CVec_RouteHintZ_free(struct LDKCVec_RouteHintZ _res); +struct LDKCResult_CounterpartyForwardingInfoDecodeErrorZ CResult_CounterpartyForwardingInfoDecodeErrorZ_ok(struct LDKCounterpartyForwardingInfo o); /** - * Constructs a new COption_u64Z containing a u64 + * Creates a new CResult_CounterpartyForwardingInfoDecodeErrorZ in the error state. */ -struct LDKCOption_u64Z COption_u64Z_some(uint64_t o); +struct LDKCResult_CounterpartyForwardingInfoDecodeErrorZ CResult_CounterpartyForwardingInfoDecodeErrorZ_err(struct LDKDecodeError e); /** - * Constructs a new COption_u64Z containing nothing + * Checks if the given object is currently in the success state */ -struct LDKCOption_u64Z COption_u64Z_none(void); +bool CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok(const struct LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources associated with the u64, if we are in the Some state + * Frees any resources used by the CResult_CounterpartyForwardingInfoDecodeErrorZ. */ -void COption_u64Z_free(struct LDKCOption_u64Z _res); +void CResult_CounterpartyForwardingInfoDecodeErrorZ_free(struct LDKCResult_CounterpartyForwardingInfoDecodeErrorZ _res); /** - * Creates a new COption_u64Z which has the same data as `orig` + * Creates a new CResult_CounterpartyForwardingInfoDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCOption_u64Z COption_u64Z_clone(const struct LDKCOption_u64Z *NONNULL_PTR orig); +struct LDKCResult_CounterpartyForwardingInfoDecodeErrorZ CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(const struct LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_PaymentParametersDecodeErrorZ in the success state. + * Creates a new CResult_ChannelCounterpartyDecodeErrorZ in the success state. */ -struct LDKCResult_PaymentParametersDecodeErrorZ CResult_PaymentParametersDecodeErrorZ_ok(struct LDKPaymentParameters o); +struct LDKCResult_ChannelCounterpartyDecodeErrorZ CResult_ChannelCounterpartyDecodeErrorZ_ok(struct LDKChannelCounterparty o); /** - * Creates a new CResult_PaymentParametersDecodeErrorZ in the error state. + * Creates a new CResult_ChannelCounterpartyDecodeErrorZ in the error state. */ -struct LDKCResult_PaymentParametersDecodeErrorZ CResult_PaymentParametersDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_ChannelCounterpartyDecodeErrorZ CResult_ChannelCounterpartyDecodeErrorZ_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); +bool CResult_ChannelCounterpartyDecodeErrorZ_is_ok(const struct LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_PaymentParametersDecodeErrorZ. + * Frees any resources used by the CResult_ChannelCounterpartyDecodeErrorZ. */ -void CResult_PaymentParametersDecodeErrorZ_free(struct LDKCResult_PaymentParametersDecodeErrorZ _res); +void CResult_ChannelCounterpartyDecodeErrorZ_free(struct LDKCResult_ChannelCounterpartyDecodeErrorZ _res); /** - * Creates a new CResult_PaymentParametersDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_ChannelCounterpartyDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -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); +struct LDKCResult_ChannelCounterpartyDecodeErrorZ CResult_ChannelCounterpartyDecodeErrorZ_clone(const struct LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_RouteHintDecodeErrorZ in the success state. + * Creates a new CResult_ChannelDetailsDecodeErrorZ in the success state. */ -struct LDKCResult_RouteHintDecodeErrorZ CResult_RouteHintDecodeErrorZ_ok(struct LDKRouteHint o); +struct LDKCResult_ChannelDetailsDecodeErrorZ CResult_ChannelDetailsDecodeErrorZ_ok(struct LDKChannelDetails o); /** - * Creates a new CResult_RouteHintDecodeErrorZ in the error state. + * Creates a new CResult_ChannelDetailsDecodeErrorZ in the error state. */ -struct LDKCResult_RouteHintDecodeErrorZ CResult_RouteHintDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_ChannelDetailsDecodeErrorZ CResult_ChannelDetailsDecodeErrorZ_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); +bool CResult_ChannelDetailsDecodeErrorZ_is_ok(const struct LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_RouteHintDecodeErrorZ. + * Frees any resources used by the CResult_ChannelDetailsDecodeErrorZ. */ -void CResult_RouteHintDecodeErrorZ_free(struct LDKCResult_RouteHintDecodeErrorZ _res); +void CResult_ChannelDetailsDecodeErrorZ_free(struct LDKCResult_ChannelDetailsDecodeErrorZ _res); /** - * Creates a new CResult_RouteHintDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_ChannelDetailsDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_RouteHintDecodeErrorZ CResult_RouteHintDecodeErrorZ_clone(const struct LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_ChannelDetailsDecodeErrorZ CResult_ChannelDetailsDecodeErrorZ_clone(const struct LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_RouteHintHopDecodeErrorZ in the success state. + * Creates a new CResult_PhantomRouteHintsDecodeErrorZ in the success state. */ -struct LDKCResult_RouteHintHopDecodeErrorZ CResult_RouteHintHopDecodeErrorZ_ok(struct LDKRouteHintHop o); +struct LDKCResult_PhantomRouteHintsDecodeErrorZ CResult_PhantomRouteHintsDecodeErrorZ_ok(struct LDKPhantomRouteHints o); /** - * Creates a new CResult_RouteHintHopDecodeErrorZ in the error state. + * Creates a new CResult_PhantomRouteHintsDecodeErrorZ in the error state. */ -struct LDKCResult_RouteHintHopDecodeErrorZ CResult_RouteHintHopDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_PhantomRouteHintsDecodeErrorZ CResult_PhantomRouteHintsDecodeErrorZ_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); +bool CResult_PhantomRouteHintsDecodeErrorZ_is_ok(const struct LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_RouteHintHopDecodeErrorZ. + * Frees any resources used by the CResult_PhantomRouteHintsDecodeErrorZ. */ -void CResult_RouteHintHopDecodeErrorZ_free(struct LDKCResult_RouteHintHopDecodeErrorZ _res); +void CResult_PhantomRouteHintsDecodeErrorZ_free(struct LDKCResult_PhantomRouteHintsDecodeErrorZ _res); /** - * Creates a new CResult_RouteHintHopDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_PhantomRouteHintsDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_RouteHintHopDecodeErrorZ CResult_RouteHintHopDecodeErrorZ_clone(const struct LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR orig); +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. */ -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); +void CVec_ChannelMonitorZ_free(struct LDKCVec_ChannelMonitorZ _res); /** - * Creates a new CResult_RouteLightningErrorZ in the error state. + * Creates a new C2Tuple_BlockHashChannelManagerZ from the contained elements. */ -struct LDKCResult_RouteLightningErrorZ CResult_RouteLightningErrorZ_err(struct LDKLightningError e); +struct LDKC2Tuple_BlockHashChannelManagerZ C2Tuple_BlockHashChannelManagerZ_new(struct LDKThirtyTwoBytes a, struct LDKChannelManager b); /** - * Checks if the given object is currently in the success state + * Frees any resources used by the C2Tuple_BlockHashChannelManagerZ. */ -bool CResult_RouteLightningErrorZ_is_ok(const struct LDKCResult_RouteLightningErrorZ *NONNULL_PTR o); +void C2Tuple_BlockHashChannelManagerZ_free(struct LDKC2Tuple_BlockHashChannelManagerZ _res); /** - * Frees any resources used by the CResult_RouteLightningErrorZ. + * Creates a new CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ in the success state. */ -void CResult_RouteLightningErrorZ_free(struct LDKCResult_RouteLightningErrorZ _res); +struct LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(struct LDKC2Tuple_BlockHashChannelManagerZ o); /** - * Creates a new CResult_RouteLightningErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Creates a new CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ in the error state. */ -struct LDKCResult_RouteLightningErrorZ CResult_RouteLightningErrorZ_clone(const struct LDKCResult_RouteLightningErrorZ *NONNULL_PTR orig); +struct LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(struct LDKDecodeError e); /** - * Creates a new CResult_TxOutAccessErrorZ in the success state. + * Checks if the given object is currently in the success state */ -struct LDKCResult_TxOutAccessErrorZ CResult_TxOutAccessErrorZ_ok(struct LDKTxOut o); +bool CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok(const struct LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR o); /** - * Creates a new CResult_TxOutAccessErrorZ in the error state. + * Frees any resources used by the CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ. */ -struct LDKCResult_TxOutAccessErrorZ CResult_TxOutAccessErrorZ_err(enum LDKAccessError e); +void CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(struct LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res); /** - * Checks if the given object is currently in the success state + * Creates a new CResult_ChannelConfigDecodeErrorZ in the success state. */ -bool CResult_TxOutAccessErrorZ_is_ok(const struct LDKCResult_TxOutAccessErrorZ *NONNULL_PTR o); +struct LDKCResult_ChannelConfigDecodeErrorZ CResult_ChannelConfigDecodeErrorZ_ok(struct LDKChannelConfig o); /** - * Frees any resources used by the CResult_TxOutAccessErrorZ. + * Creates a new CResult_ChannelConfigDecodeErrorZ in the error state. */ -void CResult_TxOutAccessErrorZ_free(struct LDKCResult_TxOutAccessErrorZ _res); +struct LDKCResult_ChannelConfigDecodeErrorZ CResult_ChannelConfigDecodeErrorZ_err(struct LDKDecodeError e); /** - * Creates a new CResult_TxOutAccessErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Checks if the given object is currently in the success state */ -struct LDKCResult_TxOutAccessErrorZ CResult_TxOutAccessErrorZ_clone(const struct LDKCResult_TxOutAccessErrorZ *NONNULL_PTR orig); +bool CResult_ChannelConfigDecodeErrorZ_is_ok(const struct LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR o); /** - * Creates a new tuple which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Frees any resources used by the CResult_ChannelConfigDecodeErrorZ. */ -struct LDKC2Tuple_usizeTransactionZ C2Tuple_usizeTransactionZ_clone(const struct LDKC2Tuple_usizeTransactionZ *NONNULL_PTR orig); +void CResult_ChannelConfigDecodeErrorZ_free(struct LDKCResult_ChannelConfigDecodeErrorZ _res); /** - * Creates a new C2Tuple_usizeTransactionZ from the contained elements. + * Creates a new CResult_ChannelConfigDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKC2Tuple_usizeTransactionZ C2Tuple_usizeTransactionZ_new(uintptr_t a, struct LDKTransaction b); +struct LDKCResult_ChannelConfigDecodeErrorZ CResult_ChannelConfigDecodeErrorZ_clone(const struct LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR orig); /** - * Frees any resources used by the C2Tuple_usizeTransactionZ. + * Creates a new CResult_OutPointDecodeErrorZ in the success state. */ -void C2Tuple_usizeTransactionZ_free(struct LDKC2Tuple_usizeTransactionZ _res); +struct LDKCResult_OutPointDecodeErrorZ CResult_OutPointDecodeErrorZ_ok(struct LDKOutPoint o); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Creates a new CResult_OutPointDecodeErrorZ in the error state. */ -void CVec_C2Tuple_usizeTransactionZZ_free(struct LDKCVec_C2Tuple_usizeTransactionZZ _res); +struct LDKCResult_OutPointDecodeErrorZ CResult_OutPointDecodeErrorZ_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_OutPointDecodeErrorZ_is_ok(const struct LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR o); /** - * Creates a new CResult_NoneChannelMonitorUpdateErrZ in the success state. + * Frees any resources used by the CResult_OutPointDecodeErrorZ. */ -struct LDKCResult_NoneChannelMonitorUpdateErrZ CResult_NoneChannelMonitorUpdateErrZ_ok(void); +void CResult_OutPointDecodeErrorZ_free(struct LDKCResult_OutPointDecodeErrorZ _res); /** - * Creates a new CResult_NoneChannelMonitorUpdateErrZ in the error state. + * Creates a new CResult_OutPointDecodeErrorZ 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_OutPointDecodeErrorZ CResult_OutPointDecodeErrorZ_clone(const struct LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR orig); /** - * Checks if the given object is currently in the success state + * Constructs a new COption_TypeZ containing a crate::lightning::ln::wire::Type */ -bool CResult_NoneChannelMonitorUpdateErrZ_is_ok(const struct LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR o); +struct LDKCOption_TypeZ COption_TypeZ_some(struct LDKType o); /** - * Frees any resources used by the CResult_NoneChannelMonitorUpdateErrZ. + * Constructs a new COption_TypeZ containing nothing */ -void CResult_NoneChannelMonitorUpdateErrZ_free(struct LDKCResult_NoneChannelMonitorUpdateErrZ _res); +struct LDKCOption_TypeZ COption_TypeZ_none(void); /** - * Creates a new CResult_NoneChannelMonitorUpdateErrZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Frees any resources associated with the crate::lightning::ln::wire::Type, if we are in the Some state */ -struct LDKCResult_NoneChannelMonitorUpdateErrZ CResult_NoneChannelMonitorUpdateErrZ_clone(const struct LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR orig); +void COption_TypeZ_free(struct LDKCOption_TypeZ _res); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Creates a new CResult_COption_TypeZDecodeErrorZ in the success state. */ -void CVec_MonitorEventZ_free(struct LDKCVec_MonitorEventZ _res); +struct LDKCResult_COption_TypeZDecodeErrorZ CResult_COption_TypeZDecodeErrorZ_ok(struct LDKCOption_TypeZ o); /** - * Constructs a new COption_C2Tuple_usizeTransactionZZ containing a crate::c_types::derived::C2Tuple_usizeTransactionZ + * Creates a new CResult_COption_TypeZDecodeErrorZ in the error state. */ -struct LDKCOption_C2Tuple_usizeTransactionZZ COption_C2Tuple_usizeTransactionZZ_some(struct LDKC2Tuple_usizeTransactionZ o); +struct LDKCResult_COption_TypeZDecodeErrorZ CResult_COption_TypeZDecodeErrorZ_err(struct LDKDecodeError e); /** - * Constructs a new COption_C2Tuple_usizeTransactionZZ containing nothing + * Checks if the given object is currently in the success state */ -struct LDKCOption_C2Tuple_usizeTransactionZZ COption_C2Tuple_usizeTransactionZZ_none(void); +bool CResult_COption_TypeZDecodeErrorZ_is_ok(const struct LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources associated with the crate::c_types::derived::C2Tuple_usizeTransactionZ, if we are in the Some state + * Frees any resources used by the CResult_COption_TypeZDecodeErrorZ. */ -void COption_C2Tuple_usizeTransactionZZ_free(struct LDKCOption_C2Tuple_usizeTransactionZZ _res); +void CResult_COption_TypeZDecodeErrorZ_free(struct LDKCResult_COption_TypeZDecodeErrorZ _res); /** - * 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_PaymentIdPaymentErrorZ in the success state. */ -struct LDKCOption_C2Tuple_usizeTransactionZZ COption_C2Tuple_usizeTransactionZZ_clone(const struct LDKCOption_C2Tuple_usizeTransactionZZ *NONNULL_PTR orig); +struct LDKCResult_PaymentIdPaymentErrorZ CResult_PaymentIdPaymentErrorZ_ok(struct LDKThirtyTwoBytes o); /** - * Constructs a new COption_ClosureReasonZ containing a crate::lightning::util::events::ClosureReason + * Creates a new CResult_PaymentIdPaymentErrorZ in the error state. */ -struct LDKCOption_ClosureReasonZ COption_ClosureReasonZ_some(struct LDKClosureReason o); +struct LDKCResult_PaymentIdPaymentErrorZ CResult_PaymentIdPaymentErrorZ_err(struct LDKPaymentError e); /** - * Constructs a new COption_ClosureReasonZ containing nothing + * Checks if the given object is currently in the success state */ -struct LDKCOption_ClosureReasonZ COption_ClosureReasonZ_none(void); +bool CResult_PaymentIdPaymentErrorZ_is_ok(const struct LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR o); /** - * Frees any resources associated with the crate::lightning::util::events::ClosureReason, if we are in the Some state + * Frees any resources used by the CResult_PaymentIdPaymentErrorZ. */ -void COption_ClosureReasonZ_free(struct LDKCOption_ClosureReasonZ _res); +void CResult_PaymentIdPaymentErrorZ_free(struct LDKCResult_PaymentIdPaymentErrorZ _res); /** - * Creates a new COption_ClosureReasonZ which has the same data as `orig` + * Creates a new CResult_PaymentIdPaymentErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCOption_ClosureReasonZ COption_ClosureReasonZ_clone(const struct LDKCOption_ClosureReasonZ *NONNULL_PTR orig); +struct LDKCResult_PaymentIdPaymentErrorZ CResult_PaymentIdPaymentErrorZ_clone(const struct LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_COption_ClosureReasonZDecodeErrorZ in the success state. + * Creates a new CResult_InFlightHtlcsDecodeErrorZ in the success state. */ -struct LDKCResult_COption_ClosureReasonZDecodeErrorZ CResult_COption_ClosureReasonZDecodeErrorZ_ok(struct LDKCOption_ClosureReasonZ o); +struct LDKCResult_InFlightHtlcsDecodeErrorZ CResult_InFlightHtlcsDecodeErrorZ_ok(struct LDKInFlightHtlcs o); /** - * Creates a new CResult_COption_ClosureReasonZDecodeErrorZ in the error state. + * Creates a new CResult_InFlightHtlcsDecodeErrorZ in the error state. */ -struct LDKCResult_COption_ClosureReasonZDecodeErrorZ CResult_COption_ClosureReasonZDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_InFlightHtlcsDecodeErrorZ CResult_InFlightHtlcsDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(const struct LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR o); +bool CResult_InFlightHtlcsDecodeErrorZ_is_ok(const struct LDKCResult_InFlightHtlcsDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_COption_ClosureReasonZDecodeErrorZ. + * Frees any resources used by the CResult_InFlightHtlcsDecodeErrorZ. */ -void CResult_COption_ClosureReasonZDecodeErrorZ_free(struct LDKCResult_COption_ClosureReasonZDecodeErrorZ _res); +void CResult_InFlightHtlcsDecodeErrorZ_free(struct LDKCResult_InFlightHtlcsDecodeErrorZ _res); /** - * Creates a new CResult_COption_ClosureReasonZDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Creates a new CResult_SiPrefixParseErrorZ in the success state. */ -struct LDKCResult_COption_ClosureReasonZDecodeErrorZ CResult_COption_ClosureReasonZDecodeErrorZ_clone(const struct LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_SiPrefixParseErrorZ CResult_SiPrefixParseErrorZ_ok(enum LDKSiPrefix o); /** - * Constructs a new COption_NetworkUpdateZ containing a crate::lightning::routing::network_graph::NetworkUpdate + * Creates a new CResult_SiPrefixParseErrorZ in the error state. */ -struct LDKCOption_NetworkUpdateZ COption_NetworkUpdateZ_some(struct LDKNetworkUpdate o); +struct LDKCResult_SiPrefixParseErrorZ CResult_SiPrefixParseErrorZ_err(struct LDKParseError e); /** - * Constructs a new COption_NetworkUpdateZ containing nothing + * Checks if the given object is currently in the success state */ -struct LDKCOption_NetworkUpdateZ COption_NetworkUpdateZ_none(void); +bool CResult_SiPrefixParseErrorZ_is_ok(const struct LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR o); /** - * Frees any resources associated with the crate::lightning::routing::network_graph::NetworkUpdate, if we are in the Some state + * Frees any resources used by the CResult_SiPrefixParseErrorZ. */ -void COption_NetworkUpdateZ_free(struct LDKCOption_NetworkUpdateZ _res); +void CResult_SiPrefixParseErrorZ_free(struct LDKCResult_SiPrefixParseErrorZ _res); /** - * Creates a new COption_NetworkUpdateZ which has the same data as `orig` + * Creates a new CResult_SiPrefixParseErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCOption_NetworkUpdateZ COption_NetworkUpdateZ_clone(const struct LDKCOption_NetworkUpdateZ *NONNULL_PTR orig); +struct LDKCResult_SiPrefixParseErrorZ CResult_SiPrefixParseErrorZ_clone(const struct LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR orig); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Creates a new CResult_InvoiceParseOrSemanticErrorZ in the success state. */ -void CVec_SpendableOutputDescriptorZ_free(struct LDKCVec_SpendableOutputDescriptorZ _res); +struct LDKCResult_InvoiceParseOrSemanticErrorZ CResult_InvoiceParseOrSemanticErrorZ_ok(struct LDKInvoice o); /** - * Constructs a new COption_EventZ containing a crate::lightning::util::events::Event + * Creates a new CResult_InvoiceParseOrSemanticErrorZ in the error state. */ -struct LDKCOption_EventZ COption_EventZ_some(struct LDKEvent o); +struct LDKCResult_InvoiceParseOrSemanticErrorZ CResult_InvoiceParseOrSemanticErrorZ_err(struct LDKParseOrSemanticError e); /** - * Constructs a new COption_EventZ containing nothing + * Checks if the given object is currently in the success state */ -struct LDKCOption_EventZ COption_EventZ_none(void); +bool CResult_InvoiceParseOrSemanticErrorZ_is_ok(const struct LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR o); /** - * Frees any resources associated with the crate::lightning::util::events::Event, if we are in the Some state + * Frees any resources used by the CResult_InvoiceParseOrSemanticErrorZ. */ -void COption_EventZ_free(struct LDKCOption_EventZ _res); +void CResult_InvoiceParseOrSemanticErrorZ_free(struct LDKCResult_InvoiceParseOrSemanticErrorZ _res); /** - * Creates a new COption_EventZ which has the same data as `orig` + * Creates a new CResult_InvoiceParseOrSemanticErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCOption_EventZ COption_EventZ_clone(const struct LDKCOption_EventZ *NONNULL_PTR orig); +struct LDKCResult_InvoiceParseOrSemanticErrorZ CResult_InvoiceParseOrSemanticErrorZ_clone(const struct LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_COption_EventZDecodeErrorZ in the success state. + * Creates a new CResult_SignedRawInvoiceParseErrorZ in the success state. */ -struct LDKCResult_COption_EventZDecodeErrorZ CResult_COption_EventZDecodeErrorZ_ok(struct LDKCOption_EventZ o); +struct LDKCResult_SignedRawInvoiceParseErrorZ CResult_SignedRawInvoiceParseErrorZ_ok(struct LDKSignedRawInvoice o); /** - * Creates a new CResult_COption_EventZDecodeErrorZ in the error state. + * Creates a new CResult_SignedRawInvoiceParseErrorZ in the error state. */ -struct LDKCResult_COption_EventZDecodeErrorZ CResult_COption_EventZDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_SignedRawInvoiceParseErrorZ CResult_SignedRawInvoiceParseErrorZ_err(struct LDKParseError e); /** * Checks if the given object is currently in the success state */ -bool CResult_COption_EventZDecodeErrorZ_is_ok(const struct LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR o); +bool CResult_SignedRawInvoiceParseErrorZ_is_ok(const struct LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_COption_EventZDecodeErrorZ. + * Frees any resources used by the CResult_SignedRawInvoiceParseErrorZ. */ -void CResult_COption_EventZDecodeErrorZ_free(struct LDKCResult_COption_EventZDecodeErrorZ _res); +void CResult_SignedRawInvoiceParseErrorZ_free(struct LDKCResult_SignedRawInvoiceParseErrorZ _res); /** - * Creates a new CResult_COption_EventZDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_SignedRawInvoiceParseErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_COption_EventZDecodeErrorZ CResult_COption_EventZDecodeErrorZ_clone(const struct LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_SignedRawInvoiceParseErrorZ CResult_SignedRawInvoiceParseErrorZ_clone(const struct LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR orig); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Creates a new tuple which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -void CVec_MessageSendEventZ_free(struct LDKCVec_MessageSendEventZ _res); +struct LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(const struct LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR orig); /** - * Creates a new CResult_FixedPenaltyScorerDecodeErrorZ in the success state. + * Creates a new C3Tuple_RawInvoice_u832InvoiceSignatureZ from the contained elements. */ -struct LDKCResult_FixedPenaltyScorerDecodeErrorZ CResult_FixedPenaltyScorerDecodeErrorZ_ok(struct LDKFixedPenaltyScorer o); +struct LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(struct LDKRawInvoice a, struct LDKThirtyTwoBytes b, struct LDKInvoiceSignature c); /** - * Creates a new CResult_FixedPenaltyScorerDecodeErrorZ in the error state. + * Frees any resources used by the C3Tuple_RawInvoice_u832InvoiceSignatureZ. */ -struct LDKCResult_FixedPenaltyScorerDecodeErrorZ CResult_FixedPenaltyScorerDecodeErrorZ_err(struct LDKDecodeError e); +void C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(struct LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res); /** - * Checks if the given object is currently in the success state + * Creates a new CResult_PayeePubKeyErrorZ in the success state. */ -bool CResult_FixedPenaltyScorerDecodeErrorZ_is_ok(const struct LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR o); +struct LDKCResult_PayeePubKeyErrorZ CResult_PayeePubKeyErrorZ_ok(struct LDKPayeePubKey o); /** - * Frees any resources used by the CResult_FixedPenaltyScorerDecodeErrorZ. + * Creates a new CResult_PayeePubKeyErrorZ in the error state. */ -void CResult_FixedPenaltyScorerDecodeErrorZ_free(struct LDKCResult_FixedPenaltyScorerDecodeErrorZ _res); +struct LDKCResult_PayeePubKeyErrorZ CResult_PayeePubKeyErrorZ_err(enum LDKSecp256k1Error e); /** - * 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_PayeePubKeyErrorZ_is_ok(const struct LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR o); /** - * Creates a new CResult_ScoringParametersDecodeErrorZ in the error state. + * Frees any resources used by the CResult_PayeePubKeyErrorZ. */ -struct LDKCResult_ScoringParametersDecodeErrorZ CResult_ScoringParametersDecodeErrorZ_err(struct LDKDecodeError e); +void CResult_PayeePubKeyErrorZ_free(struct LDKCResult_PayeePubKeyErrorZ _res); /** - * Checks if the given object is currently in the success state + * Creates a new CResult_PayeePubKeyErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -bool CResult_ScoringParametersDecodeErrorZ_is_ok(const struct LDKCResult_ScoringParametersDecodeErrorZ *NONNULL_PTR o); +struct LDKCResult_PayeePubKeyErrorZ CResult_PayeePubKeyErrorZ_clone(const struct LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR orig); /** - * Frees any resources used by the CResult_ScoringParametersDecodeErrorZ. + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -void CResult_ScoringParametersDecodeErrorZ_free(struct LDKCResult_ScoringParametersDecodeErrorZ _res); +void CVec_PrivateRouteZ_free(struct LDKCVec_PrivateRouteZ _res); /** - * Creates a new CResult_ScorerDecodeErrorZ in the success state. + * Creates a new CResult_PositiveTimestampCreationErrorZ in the success state. */ -struct LDKCResult_ScorerDecodeErrorZ CResult_ScorerDecodeErrorZ_ok(struct LDKScorer o); +struct LDKCResult_PositiveTimestampCreationErrorZ CResult_PositiveTimestampCreationErrorZ_ok(struct LDKPositiveTimestamp o); /** - * Creates a new CResult_ScorerDecodeErrorZ in the error state. + * Creates a new CResult_PositiveTimestampCreationErrorZ in the error state. */ -struct LDKCResult_ScorerDecodeErrorZ CResult_ScorerDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_PositiveTimestampCreationErrorZ CResult_PositiveTimestampCreationErrorZ_err(enum LDKCreationError e); /** * Checks if the given object is currently in the success state */ -bool CResult_ScorerDecodeErrorZ_is_ok(const struct LDKCResult_ScorerDecodeErrorZ *NONNULL_PTR o); +bool CResult_PositiveTimestampCreationErrorZ_is_ok(const struct LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_ScorerDecodeErrorZ. + * Frees any resources used by the CResult_PositiveTimestampCreationErrorZ. */ -void CResult_ScorerDecodeErrorZ_free(struct LDKCResult_ScorerDecodeErrorZ _res); +void CResult_PositiveTimestampCreationErrorZ_free(struct LDKCResult_PositiveTimestampCreationErrorZ _res); /** - * Creates a new CResult_ProbabilisticScoringParametersDecodeErrorZ in the success state. + * Creates a new CResult_PositiveTimestampCreationErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_ProbabilisticScoringParametersDecodeErrorZ CResult_ProbabilisticScoringParametersDecodeErrorZ_ok(struct LDKProbabilisticScoringParameters o); +struct LDKCResult_PositiveTimestampCreationErrorZ CResult_PositiveTimestampCreationErrorZ_clone(const struct LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_ProbabilisticScoringParametersDecodeErrorZ in the error state. + * Creates a new CResult_NoneSemanticErrorZ in the success state. */ -struct LDKCResult_ProbabilisticScoringParametersDecodeErrorZ CResult_ProbabilisticScoringParametersDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_NoneSemanticErrorZ CResult_NoneSemanticErrorZ_ok(void); /** - * Checks if the given object is currently in the success state + * Creates a new CResult_NoneSemanticErrorZ in the error state. */ -bool CResult_ProbabilisticScoringParametersDecodeErrorZ_is_ok(const struct LDKCResult_ProbabilisticScoringParametersDecodeErrorZ *NONNULL_PTR o); +struct LDKCResult_NoneSemanticErrorZ CResult_NoneSemanticErrorZ_err(enum LDKSemanticError e); /** - * Frees any resources used by the CResult_ProbabilisticScoringParametersDecodeErrorZ. + * Checks if the given object is currently in the success state */ -void CResult_ProbabilisticScoringParametersDecodeErrorZ_free(struct LDKCResult_ProbabilisticScoringParametersDecodeErrorZ _res); +bool CResult_NoneSemanticErrorZ_is_ok(const struct LDKCResult_NoneSemanticErrorZ *NONNULL_PTR o); /** - * Creates a new CResult_ProbabilisticScoringParametersDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Frees any resources used by the CResult_NoneSemanticErrorZ. */ -struct LDKCResult_ProbabilisticScoringParametersDecodeErrorZ CResult_ProbabilisticScoringParametersDecodeErrorZ_clone(const struct LDKCResult_ProbabilisticScoringParametersDecodeErrorZ *NONNULL_PTR orig); +void CResult_NoneSemanticErrorZ_free(struct LDKCResult_NoneSemanticErrorZ _res); /** - * Creates a new tuple which has the same data as `orig` + * Creates a new CResult_NoneSemanticErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ C2Tuple_ProbabilisticScoringParametersNetworkGraphZ_clone(const struct LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ *NONNULL_PTR orig); - -/** - * Creates a new C2Tuple_ProbabilisticScoringParametersNetworkGraphZ from the contained elements. - */ -struct LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ C2Tuple_ProbabilisticScoringParametersNetworkGraphZ_new(struct LDKProbabilisticScoringParameters a, const struct LDKNetworkGraph *NONNULL_PTR b); - -/** - * Frees any resources used by the C2Tuple_ProbabilisticScoringParametersNetworkGraphZ. - */ -void C2Tuple_ProbabilisticScoringParametersNetworkGraphZ_free(struct LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ _res); +struct LDKCResult_NoneSemanticErrorZ CResult_NoneSemanticErrorZ_clone(const struct LDKCResult_NoneSemanticErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_ProbabilisticScorerDecodeErrorZ in the success state. + * Creates a new CResult_InvoiceSemanticErrorZ in the success state. */ -struct LDKCResult_ProbabilisticScorerDecodeErrorZ CResult_ProbabilisticScorerDecodeErrorZ_ok(struct LDKProbabilisticScorer o); +struct LDKCResult_InvoiceSemanticErrorZ CResult_InvoiceSemanticErrorZ_ok(struct LDKInvoice o); /** - * Creates a new CResult_ProbabilisticScorerDecodeErrorZ in the error state. + * Creates a new CResult_InvoiceSemanticErrorZ in the error state. */ -struct LDKCResult_ProbabilisticScorerDecodeErrorZ CResult_ProbabilisticScorerDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_InvoiceSemanticErrorZ CResult_InvoiceSemanticErrorZ_err(enum LDKSemanticError e); /** * Checks if the given object is currently in the success state */ -bool CResult_ProbabilisticScorerDecodeErrorZ_is_ok(const struct LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR o); +bool CResult_InvoiceSemanticErrorZ_is_ok(const struct LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_ProbabilisticScorerDecodeErrorZ. + * Frees any resources used by the CResult_InvoiceSemanticErrorZ. */ -void CResult_ProbabilisticScorerDecodeErrorZ_free(struct LDKCResult_ProbabilisticScorerDecodeErrorZ _res); +void CResult_InvoiceSemanticErrorZ_free(struct LDKCResult_InvoiceSemanticErrorZ _res); /** - * Creates a new CResult_InitFeaturesDecodeErrorZ in the success state. + * Creates a new CResult_InvoiceSemanticErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_InitFeaturesDecodeErrorZ CResult_InitFeaturesDecodeErrorZ_ok(struct LDKInitFeatures o); +struct LDKCResult_InvoiceSemanticErrorZ CResult_InvoiceSemanticErrorZ_clone(const struct LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_InitFeaturesDecodeErrorZ in the error state. + * Creates a new CResult_DescriptionCreationErrorZ in the success state. */ -struct LDKCResult_InitFeaturesDecodeErrorZ CResult_InitFeaturesDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_DescriptionCreationErrorZ CResult_DescriptionCreationErrorZ_ok(struct LDKDescription o); /** - * Checks if the given object is currently in the success state + * Creates a new CResult_DescriptionCreationErrorZ in the error state. */ -bool CResult_InitFeaturesDecodeErrorZ_is_ok(const struct LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR o); +struct LDKCResult_DescriptionCreationErrorZ CResult_DescriptionCreationErrorZ_err(enum LDKCreationError e); /** - * Frees any resources used by the CResult_InitFeaturesDecodeErrorZ. + * Checks if the given object is currently in the success state */ -void CResult_InitFeaturesDecodeErrorZ_free(struct LDKCResult_InitFeaturesDecodeErrorZ _res); +bool CResult_DescriptionCreationErrorZ_is_ok(const struct LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR o); /** - * Creates a new CResult_ChannelFeaturesDecodeErrorZ in the success state. + * Frees any resources used by the CResult_DescriptionCreationErrorZ. */ -struct LDKCResult_ChannelFeaturesDecodeErrorZ CResult_ChannelFeaturesDecodeErrorZ_ok(struct LDKChannelFeatures o); +void CResult_DescriptionCreationErrorZ_free(struct LDKCResult_DescriptionCreationErrorZ _res); /** - * Creates a new CResult_ChannelFeaturesDecodeErrorZ in the error state. + * Creates a new CResult_DescriptionCreationErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_ChannelFeaturesDecodeErrorZ CResult_ChannelFeaturesDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_DescriptionCreationErrorZ CResult_DescriptionCreationErrorZ_clone(const struct LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR orig); /** - * Checks if the given object is currently in the success state + * Creates a new CResult_PrivateRouteCreationErrorZ in the success state. */ -bool CResult_ChannelFeaturesDecodeErrorZ_is_ok(const struct LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR o); +struct LDKCResult_PrivateRouteCreationErrorZ CResult_PrivateRouteCreationErrorZ_ok(struct LDKPrivateRoute o); /** - * Frees any resources used by the CResult_ChannelFeaturesDecodeErrorZ. + * Creates a new CResult_PrivateRouteCreationErrorZ in the error state. */ -void CResult_ChannelFeaturesDecodeErrorZ_free(struct LDKCResult_ChannelFeaturesDecodeErrorZ _res); +struct LDKCResult_PrivateRouteCreationErrorZ CResult_PrivateRouteCreationErrorZ_err(enum LDKCreationError e); /** - * Creates a new CResult_NodeFeaturesDecodeErrorZ in the success state. + * Checks if the given object is currently in the success state */ -struct LDKCResult_NodeFeaturesDecodeErrorZ CResult_NodeFeaturesDecodeErrorZ_ok(struct LDKNodeFeatures o); +bool CResult_PrivateRouteCreationErrorZ_is_ok(const struct LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR o); /** - * Creates a new CResult_NodeFeaturesDecodeErrorZ in the error state. + * Frees any resources used by the CResult_PrivateRouteCreationErrorZ. */ -struct LDKCResult_NodeFeaturesDecodeErrorZ CResult_NodeFeaturesDecodeErrorZ_err(struct LDKDecodeError e); +void CResult_PrivateRouteCreationErrorZ_free(struct LDKCResult_PrivateRouteCreationErrorZ _res); /** - * Checks if the given object is currently in the success state + * Creates a new CResult_PrivateRouteCreationErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -bool CResult_NodeFeaturesDecodeErrorZ_is_ok(const struct LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR o); +struct LDKCResult_PrivateRouteCreationErrorZ CResult_PrivateRouteCreationErrorZ_clone(const struct LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR orig); /** - * Frees any resources used by the CResult_NodeFeaturesDecodeErrorZ. + * Creates a new CResult_StringErrorZ in the success state. */ -void CResult_NodeFeaturesDecodeErrorZ_free(struct LDKCResult_NodeFeaturesDecodeErrorZ _res); +struct LDKCResult_StringErrorZ CResult_StringErrorZ_ok(struct LDKStr o); /** - * Creates a new CResult_InvoiceFeaturesDecodeErrorZ in the success state. + * Creates a new CResult_StringErrorZ in the error state. */ -struct LDKCResult_InvoiceFeaturesDecodeErrorZ CResult_InvoiceFeaturesDecodeErrorZ_ok(struct LDKInvoiceFeatures o); +struct LDKCResult_StringErrorZ CResult_StringErrorZ_err(enum LDKSecp256k1Error e); /** - * Creates a new CResult_InvoiceFeaturesDecodeErrorZ in the error state. + * Checks if the given object is currently in the success state */ -struct LDKCResult_InvoiceFeaturesDecodeErrorZ CResult_InvoiceFeaturesDecodeErrorZ_err(struct LDKDecodeError e); +bool CResult_StringErrorZ_is_ok(const struct LDKCResult_StringErrorZ *NONNULL_PTR o); /** - * Checks if the given object is currently in the success state + * Frees any resources used by the CResult_StringErrorZ. */ -bool CResult_InvoiceFeaturesDecodeErrorZ_is_ok(const struct LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR o); +void CResult_StringErrorZ_free(struct LDKCResult_StringErrorZ _res); /** - * Frees any resources used by the CResult_InvoiceFeaturesDecodeErrorZ. + * Creates a new CResult_StringErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -void CResult_InvoiceFeaturesDecodeErrorZ_free(struct LDKCResult_InvoiceFeaturesDecodeErrorZ _res); +struct LDKCResult_StringErrorZ CResult_StringErrorZ_clone(const struct LDKCResult_StringErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_ChannelTypeFeaturesDecodeErrorZ in the success state. + * Creates a new CResult_ChannelMonitorUpdateDecodeErrorZ in the success state. */ -struct LDKCResult_ChannelTypeFeaturesDecodeErrorZ CResult_ChannelTypeFeaturesDecodeErrorZ_ok(struct LDKChannelTypeFeatures o); +struct LDKCResult_ChannelMonitorUpdateDecodeErrorZ CResult_ChannelMonitorUpdateDecodeErrorZ_ok(struct LDKChannelMonitorUpdate o); /** - * Creates a new CResult_ChannelTypeFeaturesDecodeErrorZ in the error state. + * Creates a new CResult_ChannelMonitorUpdateDecodeErrorZ in the error state. */ -struct LDKCResult_ChannelTypeFeaturesDecodeErrorZ CResult_ChannelTypeFeaturesDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_ChannelMonitorUpdateDecodeErrorZ CResult_ChannelMonitorUpdateDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(const struct LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR o); +bool CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(const struct LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_ChannelTypeFeaturesDecodeErrorZ. + * Frees any resources used by the CResult_ChannelMonitorUpdateDecodeErrorZ. */ -void CResult_ChannelTypeFeaturesDecodeErrorZ_free(struct LDKCResult_ChannelTypeFeaturesDecodeErrorZ _res); +void CResult_ChannelMonitorUpdateDecodeErrorZ_free(struct LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res); /** - * Creates a new CResult_DelayedPaymentOutputDescriptorDecodeErrorZ in the success state. + * Creates a new CResult_ChannelMonitorUpdateDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(struct LDKDelayedPaymentOutputDescriptor o); +struct LDKCResult_ChannelMonitorUpdateDecodeErrorZ CResult_ChannelMonitorUpdateDecodeErrorZ_clone(const struct LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_DelayedPaymentOutputDescriptorDecodeErrorZ in the error state. + * Constructs a new COption_MonitorEventZ containing a crate::lightning::chain::channelmonitor::MonitorEvent */ -struct LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCOption_MonitorEventZ COption_MonitorEventZ_some(struct LDKMonitorEvent o); /** - * Checks if the given object is currently in the success state + * Constructs a new COption_MonitorEventZ containing nothing */ -bool CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(const struct LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR o); +struct LDKCOption_MonitorEventZ COption_MonitorEventZ_none(void); /** - * Frees any resources used by the CResult_DelayedPaymentOutputDescriptorDecodeErrorZ. + * Frees any resources associated with the crate::lightning::chain::channelmonitor::MonitorEvent, if we are in the Some state */ -void CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(struct LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res); +void COption_MonitorEventZ_free(struct LDKCOption_MonitorEventZ _res); /** - * Creates a new CResult_DelayedPaymentOutputDescriptorDecodeErrorZ 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_DelayedPaymentOutputDescriptorDecodeErrorZ CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(const struct LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR orig); +struct LDKCOption_MonitorEventZ COption_MonitorEventZ_clone(const struct LDKCOption_MonitorEventZ *NONNULL_PTR orig); /** - * Creates a new CResult_StaticPaymentOutputDescriptorDecodeErrorZ in the success state. + * Creates a new CResult_COption_MonitorEventZDecodeErrorZ in the success state. */ -struct LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(struct LDKStaticPaymentOutputDescriptor o); +struct LDKCResult_COption_MonitorEventZDecodeErrorZ CResult_COption_MonitorEventZDecodeErrorZ_ok(struct LDKCOption_MonitorEventZ o); /** - * Creates a new CResult_StaticPaymentOutputDescriptorDecodeErrorZ in the error state. + * Creates a new CResult_COption_MonitorEventZDecodeErrorZ in the error state. */ -struct LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_COption_MonitorEventZDecodeErrorZ CResult_COption_MonitorEventZDecodeErrorZ_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); +bool CResult_COption_MonitorEventZDecodeErrorZ_is_ok(const struct LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_StaticPaymentOutputDescriptorDecodeErrorZ. + * Frees any resources used by the CResult_COption_MonitorEventZDecodeErrorZ. */ -void CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(struct LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res); +void CResult_COption_MonitorEventZDecodeErrorZ_free(struct LDKCResult_COption_MonitorEventZDecodeErrorZ _res); /** - * Creates a new CResult_StaticPaymentOutputDescriptorDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_COption_MonitorEventZDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(const struct LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_COption_MonitorEventZDecodeErrorZ CResult_COption_MonitorEventZDecodeErrorZ_clone(const struct LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_SpendableOutputDescriptorDecodeErrorZ in the success state. + * Creates a new CResult_HTLCUpdateDecodeErrorZ in the success state. */ -struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ CResult_SpendableOutputDescriptorDecodeErrorZ_ok(struct LDKSpendableOutputDescriptor o); +struct LDKCResult_HTLCUpdateDecodeErrorZ CResult_HTLCUpdateDecodeErrorZ_ok(struct LDKHTLCUpdate o); /** - * Creates a new CResult_SpendableOutputDescriptorDecodeErrorZ in the error state. + * Creates a new CResult_HTLCUpdateDecodeErrorZ in the error state. */ -struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ CResult_SpendableOutputDescriptorDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_HTLCUpdateDecodeErrorZ CResult_HTLCUpdateDecodeErrorZ_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); +bool CResult_HTLCUpdateDecodeErrorZ_is_ok(const struct LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_SpendableOutputDescriptorDecodeErrorZ. + * Frees any resources used by the CResult_HTLCUpdateDecodeErrorZ. */ -void CResult_SpendableOutputDescriptorDecodeErrorZ_free(struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res); +void CResult_HTLCUpdateDecodeErrorZ_free(struct LDKCResult_HTLCUpdateDecodeErrorZ _res); /** - * Creates a new CResult_SpendableOutputDescriptorDecodeErrorZ 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_SpendableOutputDescriptorDecodeErrorZ CResult_SpendableOutputDescriptorDecodeErrorZ_clone(const struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR orig); - -/** - * Frees the buffer pointed to by `data` if `datalen` is non-0. - */ -void CVec_PaymentPreimageZ_free(struct LDKCVec_PaymentPreimageZ _res); +struct LDKCResult_HTLCUpdateDecodeErrorZ CResult_HTLCUpdateDecodeErrorZ_clone(const struct LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR orig); /** * Creates a new tuple which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKC2Tuple_SignatureCVec_SignatureZZ C2Tuple_SignatureCVec_SignatureZZ_clone(const struct LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR orig); +struct LDKC2Tuple_OutPointScriptZ C2Tuple_OutPointScriptZ_clone(const struct LDKC2Tuple_OutPointScriptZ *NONNULL_PTR orig); /** - * Creates a new C2Tuple_SignatureCVec_SignatureZZ from the contained elements. + * Creates a new C2Tuple_OutPointScriptZ from the contained elements. */ -struct LDKC2Tuple_SignatureCVec_SignatureZZ C2Tuple_SignatureCVec_SignatureZZ_new(struct LDKSignature a, struct LDKCVec_SignatureZ b); +struct LDKC2Tuple_OutPointScriptZ C2Tuple_OutPointScriptZ_new(struct LDKOutPoint a, struct LDKCVec_u8Z b); /** - * Frees any resources used by the C2Tuple_SignatureCVec_SignatureZZ. + * Frees any resources used by the C2Tuple_OutPointScriptZ. */ -void C2Tuple_SignatureCVec_SignatureZZ_free(struct LDKC2Tuple_SignatureCVec_SignatureZZ _res); +void C2Tuple_OutPointScriptZ_free(struct LDKC2Tuple_OutPointScriptZ _res); /** - * Creates a new CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ in the success state. + * Creates a new tuple which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(struct LDKC2Tuple_SignatureCVec_SignatureZZ o); +struct LDKC2Tuple_u32ScriptZ C2Tuple_u32ScriptZ_clone(const struct LDKC2Tuple_u32ScriptZ *NONNULL_PTR orig); /** - * Creates a new CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ in the error state. + * Creates a new C2Tuple_u32ScriptZ from the contained elements. */ -struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err(void); +struct LDKC2Tuple_u32ScriptZ C2Tuple_u32ScriptZ_new(uint32_t a, struct LDKCVec_u8Z b); /** - * Checks if the given object is currently in the success state + * Frees any resources used by the C2Tuple_u32ScriptZ. */ -bool CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok(const struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR o); +void C2Tuple_u32ScriptZ_free(struct LDKC2Tuple_u32ScriptZ _res); /** - * Frees any resources used by the CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ. + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -void CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res); +void CVec_C2Tuple_u32ScriptZZ_free(struct LDKCVec_C2Tuple_u32ScriptZZ _res); /** - * Creates a new CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ which has the same data as `orig` + * Creates a new tuple which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(const struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR orig); +struct LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(const struct LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR orig); /** - * Creates a new CResult_SignatureNoneZ in the success state. + * Creates a new C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ from the contained elements. */ -struct LDKCResult_SignatureNoneZ CResult_SignatureNoneZ_ok(struct LDKSignature o); +struct LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(struct LDKThirtyTwoBytes a, struct LDKCVec_C2Tuple_u32ScriptZZ b); /** - * Creates a new CResult_SignatureNoneZ in the error state. + * Frees any resources used by the C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ. */ -struct LDKCResult_SignatureNoneZ CResult_SignatureNoneZ_err(void); +void C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(struct LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res); /** - * Checks if the given object is currently in the success state + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -bool CResult_SignatureNoneZ_is_ok(const struct LDKCResult_SignatureNoneZ *NONNULL_PTR o); +void CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(struct LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res); /** - * Frees any resources used by the CResult_SignatureNoneZ. + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -void CResult_SignatureNoneZ_free(struct LDKCResult_SignatureNoneZ _res); +void CVec_EventZ_free(struct LDKCVec_EventZ _res); /** - * Creates a new CResult_SignatureNoneZ 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_SignatureNoneZ CResult_SignatureNoneZ_clone(const struct LDKCResult_SignatureNoneZ *NONNULL_PTR orig); +void CVec_TransactionZ_free(struct LDKCVec_TransactionZ _res); /** * 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); +struct LDKC2Tuple_u32TxOutZ C2Tuple_u32TxOutZ_clone(const struct LDKC2Tuple_u32TxOutZ *NONNULL_PTR orig); /** - * Creates a new C2Tuple_SignatureSignatureZ from the contained elements. + * Creates a new C2Tuple_u32TxOutZ from the contained elements. */ -struct LDKC2Tuple_SignatureSignatureZ C2Tuple_SignatureSignatureZ_new(struct LDKSignature a, struct LDKSignature b); +struct LDKC2Tuple_u32TxOutZ C2Tuple_u32TxOutZ_new(uint32_t a, struct LDKTxOut b); /** - * Frees any resources used by the C2Tuple_SignatureSignatureZ. + * Frees any resources used by the C2Tuple_u32TxOutZ. */ -void C2Tuple_SignatureSignatureZ_free(struct LDKC2Tuple_SignatureSignatureZ _res); +void C2Tuple_u32TxOutZ_free(struct LDKC2Tuple_u32TxOutZ _res); /** - * Creates a new CResult_C2Tuple_SignatureSignatureZNoneZ in the success state. + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -struct LDKCResult_C2Tuple_SignatureSignatureZNoneZ CResult_C2Tuple_SignatureSignatureZNoneZ_ok(struct LDKC2Tuple_SignatureSignatureZ o); +void CVec_C2Tuple_u32TxOutZZ_free(struct LDKCVec_C2Tuple_u32TxOutZZ _res); /** - * Creates a new CResult_C2Tuple_SignatureSignatureZNoneZ in the error state. + * Creates a new tuple which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_C2Tuple_SignatureSignatureZNoneZ CResult_C2Tuple_SignatureSignatureZNoneZ_err(void); +struct LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(const struct LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR orig); /** - * Checks if the given object is currently in the success state + * Creates a new C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ from the contained elements. */ -bool CResult_C2Tuple_SignatureSignatureZNoneZ_is_ok(const struct LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR o); +struct LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(struct LDKThirtyTwoBytes a, struct LDKCVec_C2Tuple_u32TxOutZZ b); /** - * Frees any resources used by the CResult_C2Tuple_SignatureSignatureZNoneZ. + * Frees any resources used by the C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ. */ -void CResult_C2Tuple_SignatureSignatureZNoneZ_free(struct LDKCResult_C2Tuple_SignatureSignatureZNoneZ _res); +void C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(struct LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res); /** - * Creates a new CResult_C2Tuple_SignatureSignatureZNoneZ 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_C2Tuple_SignatureSignatureZNoneZ CResult_C2Tuple_SignatureSignatureZNoneZ_clone(const struct LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR orig); +void CVec_TransactionOutputsZ_free(struct LDKCVec_TransactionOutputsZ _res); /** - * Creates a new CResult_SecretKeyNoneZ in the success state. + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -struct LDKCResult_SecretKeyNoneZ CResult_SecretKeyNoneZ_ok(struct LDKSecretKey o); +void CVec_BalanceZ_free(struct LDKCVec_BalanceZ _res); /** - * Creates a new CResult_SecretKeyNoneZ in the error state. + * Creates a new CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ in the success state. */ -struct LDKCResult_SecretKeyNoneZ CResult_SecretKeyNoneZ_err(void); +struct LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(struct LDKC2Tuple_BlockHashChannelMonitorZ o); /** - * Checks if the given object is currently in the success state + * Creates a new CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ in the error state. */ -bool CResult_SecretKeyNoneZ_is_ok(const struct LDKCResult_SecretKeyNoneZ *NONNULL_PTR o); +struct LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees any resources used by the CResult_SecretKeyNoneZ. + * Checks if the given object is currently in the success state */ -void CResult_SecretKeyNoneZ_free(struct LDKCResult_SecretKeyNoneZ _res); +bool CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok(const struct LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR o); /** - * Creates a new CResult_SecretKeyNoneZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Frees any resources used by the CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ. */ -struct LDKCResult_SecretKeyNoneZ CResult_SecretKeyNoneZ_clone(const struct LDKCResult_SecretKeyNoneZ *NONNULL_PTR orig); +void CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(struct LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res); /** - * Creates a new CResult_SignDecodeErrorZ in the success state. + * Creates a new C2Tuple_PublicKeyTypeZ from the contained elements. */ -struct LDKCResult_SignDecodeErrorZ CResult_SignDecodeErrorZ_ok(struct LDKSign o); +struct LDKC2Tuple_PublicKeyTypeZ C2Tuple_PublicKeyTypeZ_new(struct LDKPublicKey a, struct LDKType b); /** - * Creates a new CResult_SignDecodeErrorZ in the error state. + * Frees any resources used by the C2Tuple_PublicKeyTypeZ. */ -struct LDKCResult_SignDecodeErrorZ CResult_SignDecodeErrorZ_err(struct LDKDecodeError e); +void C2Tuple_PublicKeyTypeZ_free(struct LDKC2Tuple_PublicKeyTypeZ _res); /** - * Checks if the given object is currently in the success state + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -bool CResult_SignDecodeErrorZ_is_ok(const struct LDKCResult_SignDecodeErrorZ *NONNULL_PTR o); +void CVec_C2Tuple_PublicKeyTypeZZ_free(struct LDKCVec_C2Tuple_PublicKeyTypeZZ _res); /** - * Frees any resources used by the CResult_SignDecodeErrorZ. + * Constructs a new COption_CustomOnionMessageContentsZ containing a crate::lightning::onion_message::packet::CustomOnionMessageContents */ -void CResult_SignDecodeErrorZ_free(struct LDKCResult_SignDecodeErrorZ _res); +struct LDKCOption_CustomOnionMessageContentsZ COption_CustomOnionMessageContentsZ_some(struct LDKCustomOnionMessageContents o); /** - * Creates a new CResult_SignDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Constructs a new COption_CustomOnionMessageContentsZ containing nothing */ -struct LDKCResult_SignDecodeErrorZ CResult_SignDecodeErrorZ_clone(const struct LDKCResult_SignDecodeErrorZ *NONNULL_PTR orig); +struct LDKCOption_CustomOnionMessageContentsZ COption_CustomOnionMessageContentsZ_none(void); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Frees any resources associated with the crate::lightning::onion_message::packet::CustomOnionMessageContents, if we are in the Some state */ -void CVec_u5Z_free(struct LDKCVec_u5Z _res); +void COption_CustomOnionMessageContentsZ_free(struct LDKCOption_CustomOnionMessageContentsZ _res); /** - * Creates a new CResult_RecoverableSignatureNoneZ in the success state. + * Creates a new CResult_COption_CustomOnionMessageContentsZDecodeErrorZ in the success state. */ -struct LDKCResult_RecoverableSignatureNoneZ CResult_RecoverableSignatureNoneZ_ok(struct LDKRecoverableSignature o); +struct LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_ok(struct LDKCOption_CustomOnionMessageContentsZ o); /** - * Creates a new CResult_RecoverableSignatureNoneZ in the error state. + * Creates a new CResult_COption_CustomOnionMessageContentsZDecodeErrorZ in the error state. */ -struct LDKCResult_RecoverableSignatureNoneZ CResult_RecoverableSignatureNoneZ_err(void); +struct LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_RecoverableSignatureNoneZ_is_ok(const struct LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR o); +bool CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_is_ok(const struct LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_RecoverableSignatureNoneZ. + * Frees any resources used by the CResult_COption_CustomOnionMessageContentsZDecodeErrorZ. */ -void CResult_RecoverableSignatureNoneZ_free(struct LDKCResult_RecoverableSignatureNoneZ _res); +void CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_free(struct LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ _res); /** - * Creates a new CResult_RecoverableSignatureNoneZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Constructs a new COption_NetAddressZ containing a crate::lightning::ln::msgs::NetAddress */ -struct LDKCResult_RecoverableSignatureNoneZ CResult_RecoverableSignatureNoneZ_clone(const struct LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR orig); +struct LDKCOption_NetAddressZ COption_NetAddressZ_some(struct LDKNetAddress o); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Constructs a new COption_NetAddressZ containing nothing */ -void CVec_u8Z_free(struct LDKCVec_u8Z _res); +struct LDKCOption_NetAddressZ COption_NetAddressZ_none(void); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Frees any resources associated with the crate::lightning::ln::msgs::NetAddress, if we are in the Some state */ -void CVec_CVec_u8ZZ_free(struct LDKCVec_CVec_u8ZZ _res); +void COption_NetAddressZ_free(struct LDKCOption_NetAddressZ _res); /** - * Creates a new CResult_CVec_CVec_u8ZZNoneZ in the success state. + * Creates a new COption_NetAddressZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_CVec_CVec_u8ZZNoneZ CResult_CVec_CVec_u8ZZNoneZ_ok(struct LDKCVec_CVec_u8ZZ o); +struct LDKCOption_NetAddressZ COption_NetAddressZ_clone(const struct LDKCOption_NetAddressZ *NONNULL_PTR orig); /** - * Creates a new CResult_CVec_CVec_u8ZZNoneZ in the error state. + * Creates a new CResult_CVec_u8ZPeerHandleErrorZ in the success state. */ -struct LDKCResult_CVec_CVec_u8ZZNoneZ CResult_CVec_CVec_u8ZZNoneZ_err(void); +struct LDKCResult_CVec_u8ZPeerHandleErrorZ CResult_CVec_u8ZPeerHandleErrorZ_ok(struct LDKCVec_u8Z o); + +/** + * Creates a new CResult_CVec_u8ZPeerHandleErrorZ in the error state. + */ +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_CVec_u8ZZNoneZ_is_ok(const struct LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR o); +bool CResult_CVec_u8ZPeerHandleErrorZ_is_ok(const struct LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_CVec_CVec_u8ZZNoneZ. + * Frees any resources used by the CResult_CVec_u8ZPeerHandleErrorZ. */ -void CResult_CVec_CVec_u8ZZNoneZ_free(struct LDKCResult_CVec_CVec_u8ZZNoneZ _res); +void CResult_CVec_u8ZPeerHandleErrorZ_free(struct LDKCResult_CVec_u8ZPeerHandleErrorZ _res); /** - * Creates a new CResult_CVec_CVec_u8ZZNoneZ which has the same data as `orig` + * Creates a new CResult_CVec_u8ZPeerHandleErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_CVec_CVec_u8ZZNoneZ CResult_CVec_CVec_u8ZZNoneZ_clone(const struct LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR orig); +struct LDKCResult_CVec_u8ZPeerHandleErrorZ CResult_CVec_u8ZPeerHandleErrorZ_clone(const struct LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_InMemorySignerDecodeErrorZ in the success state. + * Creates a new CResult_NonePeerHandleErrorZ in the success state. */ -struct LDKCResult_InMemorySignerDecodeErrorZ CResult_InMemorySignerDecodeErrorZ_ok(struct LDKInMemorySigner o); +struct LDKCResult_NonePeerHandleErrorZ CResult_NonePeerHandleErrorZ_ok(void); /** - * Creates a new CResult_InMemorySignerDecodeErrorZ in the error state. + * Creates a new CResult_NonePeerHandleErrorZ in the error state. */ -struct LDKCResult_InMemorySignerDecodeErrorZ CResult_InMemorySignerDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_NonePeerHandleErrorZ CResult_NonePeerHandleErrorZ_err(struct LDKPeerHandleError e); /** * Checks if the given object is currently in the success state */ -bool CResult_InMemorySignerDecodeErrorZ_is_ok(const struct LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR o); +bool CResult_NonePeerHandleErrorZ_is_ok(const struct LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_InMemorySignerDecodeErrorZ. + * Frees any resources used by the CResult_NonePeerHandleErrorZ. */ -void CResult_InMemorySignerDecodeErrorZ_free(struct LDKCResult_InMemorySignerDecodeErrorZ _res); +void CResult_NonePeerHandleErrorZ_free(struct LDKCResult_NonePeerHandleErrorZ _res); /** - * Creates a new CResult_InMemorySignerDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_NonePeerHandleErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_InMemorySignerDecodeErrorZ CResult_InMemorySignerDecodeErrorZ_clone(const struct LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR orig); - -/** - * Frees the buffer pointed to by `data` if `datalen` is non-0. - */ -void CVec_TxOutZ_free(struct LDKCVec_TxOutZ _res); +struct LDKCResult_NonePeerHandleErrorZ CResult_NonePeerHandleErrorZ_clone(const struct LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_TransactionNoneZ in the success state. + * Creates a new CResult_boolPeerHandleErrorZ in the success state. */ -struct LDKCResult_TransactionNoneZ CResult_TransactionNoneZ_ok(struct LDKTransaction o); +struct LDKCResult_boolPeerHandleErrorZ CResult_boolPeerHandleErrorZ_ok(bool o); /** - * Creates a new CResult_TransactionNoneZ in the error state. + * Creates a new CResult_boolPeerHandleErrorZ in the error state. */ -struct LDKCResult_TransactionNoneZ CResult_TransactionNoneZ_err(void); +struct LDKCResult_boolPeerHandleErrorZ CResult_boolPeerHandleErrorZ_err(struct LDKPeerHandleError e); /** * Checks if the given object is currently in the success state */ -bool CResult_TransactionNoneZ_is_ok(const struct LDKCResult_TransactionNoneZ *NONNULL_PTR o); +bool CResult_boolPeerHandleErrorZ_is_ok(const struct LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_TransactionNoneZ. + * Frees any resources used by the CResult_boolPeerHandleErrorZ. */ -void CResult_TransactionNoneZ_free(struct LDKCResult_TransactionNoneZ _res); +void CResult_boolPeerHandleErrorZ_free(struct LDKCResult_boolPeerHandleErrorZ _res); /** - * Creates a new CResult_TransactionNoneZ which has the same data as `orig` + * Creates a new CResult_boolPeerHandleErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_TransactionNoneZ CResult_TransactionNoneZ_clone(const struct LDKCResult_TransactionNoneZ *NONNULL_PTR orig); - -/** - * Creates a new C2Tuple_BlockHashChannelMonitorZ from the contained elements. - */ -struct LDKC2Tuple_BlockHashChannelMonitorZ C2Tuple_BlockHashChannelMonitorZ_new(struct LDKThirtyTwoBytes a, struct LDKChannelMonitor b); +struct LDKCResult_boolPeerHandleErrorZ CResult_boolPeerHandleErrorZ_clone(const struct LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR orig); /** - * Frees any resources used by the C2Tuple_BlockHashChannelMonitorZ. + * Creates a new CResult_NoneSendErrorZ in the success state. */ -void C2Tuple_BlockHashChannelMonitorZ_free(struct LDKC2Tuple_BlockHashChannelMonitorZ _res); +struct LDKCResult_NoneSendErrorZ CResult_NoneSendErrorZ_ok(void); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Creates a new CResult_NoneSendErrorZ in the error state. */ -void CVec_C2Tuple_BlockHashChannelMonitorZZ_free(struct LDKCVec_C2Tuple_BlockHashChannelMonitorZZ _res); +struct LDKCResult_NoneSendErrorZ CResult_NoneSendErrorZ_err(struct LDKSendError e); /** - * Creates a new CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ in the success state. + * Checks if the given object is currently in the success state */ -struct LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(struct LDKCVec_C2Tuple_BlockHashChannelMonitorZZ o); +bool CResult_NoneSendErrorZ_is_ok(const struct LDKCResult_NoneSendErrorZ *NONNULL_PTR o); /** - * Creates a new CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ in the error state. + * Frees any resources used by the CResult_NoneSendErrorZ. */ -struct LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(enum LDKIOError e); +void CResult_NoneSendErrorZ_free(struct LDKCResult_NoneSendErrorZ _res); /** - * Checks if the given object is currently in the success state + * Creates a new CResult_u32GraphSyncErrorZ in the success state. */ -bool CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_is_ok(const struct LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR o); +struct LDKCResult_u32GraphSyncErrorZ CResult_u32GraphSyncErrorZ_ok(uint32_t o); /** - * Frees any resources used by the CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ. + * Creates a new CResult_u32GraphSyncErrorZ in the error state. */ -void CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(struct LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ _res); +struct LDKCResult_u32GraphSyncErrorZ CResult_u32GraphSyncErrorZ_err(struct LDKGraphSyncError e); /** - * Constructs a new COption_u16Z containing a u16 + * Checks if the given object is currently in the success state */ -struct LDKCOption_u16Z COption_u16Z_some(uint16_t o); +bool CResult_u32GraphSyncErrorZ_is_ok(const struct LDKCResult_u32GraphSyncErrorZ *NONNULL_PTR o); /** - * Constructs a new COption_u16Z containing nothing + * Frees any resources used by the CResult_u32GraphSyncErrorZ. */ -struct LDKCOption_u16Z COption_u16Z_none(void); +void CResult_u32GraphSyncErrorZ_free(struct LDKCResult_u32GraphSyncErrorZ _res); /** - * Frees any resources associated with the u16, if we are in the Some state + * Creates a new CResult_NetAddressDecodeErrorZ in the success state. */ -void COption_u16Z_free(struct LDKCOption_u16Z _res); +struct LDKCResult_NetAddressDecodeErrorZ CResult_NetAddressDecodeErrorZ_ok(struct LDKNetAddress o); /** - * Creates a new COption_u16Z which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Creates a new CResult_NetAddressDecodeErrorZ in the error state. */ -struct LDKCOption_u16Z COption_u16Z_clone(const struct LDKCOption_u16Z *NONNULL_PTR orig); +struct LDKCResult_NetAddressDecodeErrorZ CResult_NetAddressDecodeErrorZ_err(struct LDKDecodeError e); /** - * Creates a new CResult_NoneAPIErrorZ in the success state. + * Checks if the given object is currently in the success state */ -struct LDKCResult_NoneAPIErrorZ CResult_NoneAPIErrorZ_ok(void); +bool CResult_NetAddressDecodeErrorZ_is_ok(const struct LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR o); /** - * Creates a new CResult_NoneAPIErrorZ in the error state. + * Frees any resources used by the CResult_NetAddressDecodeErrorZ. */ -struct LDKCResult_NoneAPIErrorZ CResult_NoneAPIErrorZ_err(struct LDKAPIError e); +void CResult_NetAddressDecodeErrorZ_free(struct LDKCResult_NetAddressDecodeErrorZ _res); /** - * Checks if the given object is currently in the success state + * Creates a new CResult_NetAddressDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -bool CResult_NoneAPIErrorZ_is_ok(const struct LDKCResult_NoneAPIErrorZ *NONNULL_PTR o); +struct LDKCResult_NetAddressDecodeErrorZ CResult_NetAddressDecodeErrorZ_clone(const struct LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR orig); /** - * Frees any resources used by the CResult_NoneAPIErrorZ. + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -void CResult_NoneAPIErrorZ_free(struct LDKCResult_NoneAPIErrorZ _res); +void CVec_UpdateAddHTLCZ_free(struct LDKCVec_UpdateAddHTLCZ _res); /** - * Creates a new CResult_NoneAPIErrorZ 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_NoneAPIErrorZ CResult_NoneAPIErrorZ_clone(const struct LDKCResult_NoneAPIErrorZ *NONNULL_PTR orig); +void CVec_UpdateFulfillHTLCZ_free(struct LDKCVec_UpdateFulfillHTLCZ _res); /** * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -void CVec_CResult_NoneAPIErrorZZ_free(struct LDKCVec_CResult_NoneAPIErrorZZ _res); +void CVec_UpdateFailHTLCZ_free(struct LDKCVec_UpdateFailHTLCZ _res); /** * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -void CVec_APIErrorZ_free(struct LDKCVec_APIErrorZ _res); +void CVec_UpdateFailMalformedHTLCZ_free(struct LDKCVec_UpdateFailMalformedHTLCZ _res); /** - * Creates a new CResult__u832APIErrorZ in the success state. + * Creates a new CResult_AcceptChannelDecodeErrorZ in the success state. */ -struct LDKCResult__u832APIErrorZ CResult__u832APIErrorZ_ok(struct LDKThirtyTwoBytes o); +struct LDKCResult_AcceptChannelDecodeErrorZ CResult_AcceptChannelDecodeErrorZ_ok(struct LDKAcceptChannel o); /** - * Creates a new CResult__u832APIErrorZ in the error state. + * Creates a new CResult_AcceptChannelDecodeErrorZ in the error state. */ -struct LDKCResult__u832APIErrorZ CResult__u832APIErrorZ_err(struct LDKAPIError e); +struct LDKCResult_AcceptChannelDecodeErrorZ CResult_AcceptChannelDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult__u832APIErrorZ_is_ok(const struct LDKCResult__u832APIErrorZ *NONNULL_PTR o); +bool CResult_AcceptChannelDecodeErrorZ_is_ok(const struct LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult__u832APIErrorZ. + * Frees any resources used by the CResult_AcceptChannelDecodeErrorZ. */ -void CResult__u832APIErrorZ_free(struct LDKCResult__u832APIErrorZ _res); +void CResult_AcceptChannelDecodeErrorZ_free(struct LDKCResult_AcceptChannelDecodeErrorZ _res); /** - * Creates a new CResult__u832APIErrorZ which has the same data as `orig` + * Creates a new CResult_AcceptChannelDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult__u832APIErrorZ CResult__u832APIErrorZ_clone(const struct LDKCResult__u832APIErrorZ *NONNULL_PTR orig); +struct LDKCResult_AcceptChannelDecodeErrorZ CResult_AcceptChannelDecodeErrorZ_clone(const struct LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_PaymentIdPaymentSendFailureZ in the success state. + * Creates a new CResult_AnnouncementSignaturesDecodeErrorZ in the success state. */ -struct LDKCResult_PaymentIdPaymentSendFailureZ CResult_PaymentIdPaymentSendFailureZ_ok(struct LDKThirtyTwoBytes o); +struct LDKCResult_AnnouncementSignaturesDecodeErrorZ CResult_AnnouncementSignaturesDecodeErrorZ_ok(struct LDKAnnouncementSignatures o); /** - * Creates a new CResult_PaymentIdPaymentSendFailureZ in the error state. + * Creates a new CResult_AnnouncementSignaturesDecodeErrorZ in the error state. */ -struct LDKCResult_PaymentIdPaymentSendFailureZ CResult_PaymentIdPaymentSendFailureZ_err(struct LDKPaymentSendFailure e); +struct LDKCResult_AnnouncementSignaturesDecodeErrorZ CResult_AnnouncementSignaturesDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_PaymentIdPaymentSendFailureZ_is_ok(const struct LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR o); +bool CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(const struct LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_PaymentIdPaymentSendFailureZ. + * Frees any resources used by the CResult_AnnouncementSignaturesDecodeErrorZ. */ -void CResult_PaymentIdPaymentSendFailureZ_free(struct LDKCResult_PaymentIdPaymentSendFailureZ _res); +void CResult_AnnouncementSignaturesDecodeErrorZ_free(struct LDKCResult_AnnouncementSignaturesDecodeErrorZ _res); /** - * Creates a new CResult_PaymentIdPaymentSendFailureZ which has the same data as `orig` + * Creates a new CResult_AnnouncementSignaturesDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_PaymentIdPaymentSendFailureZ CResult_PaymentIdPaymentSendFailureZ_clone(const struct LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR orig); +struct LDKCResult_AnnouncementSignaturesDecodeErrorZ CResult_AnnouncementSignaturesDecodeErrorZ_clone(const struct LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_NonePaymentSendFailureZ in the success state. + * Creates a new CResult_ChannelReestablishDecodeErrorZ in the success state. */ -struct LDKCResult_NonePaymentSendFailureZ CResult_NonePaymentSendFailureZ_ok(void); +struct LDKCResult_ChannelReestablishDecodeErrorZ CResult_ChannelReestablishDecodeErrorZ_ok(struct LDKChannelReestablish o); /** - * Creates a new CResult_NonePaymentSendFailureZ in the error state. + * Creates a new CResult_ChannelReestablishDecodeErrorZ in the error state. */ -struct LDKCResult_NonePaymentSendFailureZ CResult_NonePaymentSendFailureZ_err(struct LDKPaymentSendFailure e); +struct LDKCResult_ChannelReestablishDecodeErrorZ CResult_ChannelReestablishDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_NonePaymentSendFailureZ_is_ok(const struct LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR o); +bool CResult_ChannelReestablishDecodeErrorZ_is_ok(const struct LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_NonePaymentSendFailureZ. + * Frees any resources used by the CResult_ChannelReestablishDecodeErrorZ. */ -void CResult_NonePaymentSendFailureZ_free(struct LDKCResult_NonePaymentSendFailureZ _res); +void CResult_ChannelReestablishDecodeErrorZ_free(struct LDKCResult_ChannelReestablishDecodeErrorZ _res); /** - * Creates a new CResult_NonePaymentSendFailureZ which has the same data as `orig` + * Creates a new CResult_ChannelReestablishDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_NonePaymentSendFailureZ CResult_NonePaymentSendFailureZ_clone(const struct LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR orig); +struct LDKCResult_ChannelReestablishDecodeErrorZ CResult_ChannelReestablishDecodeErrorZ_clone(const struct LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new tuple which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Creates a new CResult_ClosingSignedDecodeErrorZ in the success state. */ -struct LDKC2Tuple_PaymentHashPaymentIdZ C2Tuple_PaymentHashPaymentIdZ_clone(const struct LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR orig); +struct LDKCResult_ClosingSignedDecodeErrorZ CResult_ClosingSignedDecodeErrorZ_ok(struct LDKClosingSigned o); /** - * Creates a new C2Tuple_PaymentHashPaymentIdZ from the contained elements. + * Creates a new CResult_ClosingSignedDecodeErrorZ in the error state. */ -struct LDKC2Tuple_PaymentHashPaymentIdZ C2Tuple_PaymentHashPaymentIdZ_new(struct LDKThirtyTwoBytes a, struct LDKThirtyTwoBytes b); +struct LDKCResult_ClosingSignedDecodeErrorZ CResult_ClosingSignedDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees any resources used by the C2Tuple_PaymentHashPaymentIdZ. + * Checks if the given object is currently in the success state */ -void C2Tuple_PaymentHashPaymentIdZ_free(struct LDKC2Tuple_PaymentHashPaymentIdZ _res); +bool CResult_ClosingSignedDecodeErrorZ_is_ok(const struct LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR o); /** - * Creates a new CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ in the success state. + * Frees any resources used by the CResult_ClosingSignedDecodeErrorZ. */ -struct LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(struct LDKC2Tuple_PaymentHashPaymentIdZ o); +void CResult_ClosingSignedDecodeErrorZ_free(struct LDKCResult_ClosingSignedDecodeErrorZ _res); /** - * Creates a new CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ in the error state. + * Creates a new CResult_ClosingSignedDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(struct LDKPaymentSendFailure e); +struct LDKCResult_ClosingSignedDecodeErrorZ CResult_ClosingSignedDecodeErrorZ_clone(const struct LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR orig); /** - * Checks if the given object is currently in the success state + * Creates a new CResult_ClosingSignedFeeRangeDecodeErrorZ in the success state. */ -bool CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok(const struct LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR o); +struct LDKCResult_ClosingSignedFeeRangeDecodeErrorZ CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(struct LDKClosingSignedFeeRange o); /** - * Frees any resources used by the CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ. + * Creates a new CResult_ClosingSignedFeeRangeDecodeErrorZ in the error state. */ -void CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(struct LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ _res); +struct LDKCResult_ClosingSignedFeeRangeDecodeErrorZ CResult_ClosingSignedFeeRangeDecodeErrorZ_err(struct LDKDecodeError e); /** - * Creates a new CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Checks if the given object is currently in the success state */ -struct LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(const struct LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR orig); +bool CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(const struct LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR o); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Frees any resources used by the CResult_ClosingSignedFeeRangeDecodeErrorZ. */ -void CVec_NetAddressZ_free(struct LDKCVec_NetAddressZ _res); +void CResult_ClosingSignedFeeRangeDecodeErrorZ_free(struct LDKCResult_ClosingSignedFeeRangeDecodeErrorZ _res); /** - * Creates a new tuple which has the same data as `orig` + * Creates a new CResult_ClosingSignedFeeRangeDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKC2Tuple_PaymentHashPaymentSecretZ C2Tuple_PaymentHashPaymentSecretZ_clone(const struct LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR orig); - -/** - * Creates a new C2Tuple_PaymentHashPaymentSecretZ from the contained elements. - */ -struct LDKC2Tuple_PaymentHashPaymentSecretZ C2Tuple_PaymentHashPaymentSecretZ_new(struct LDKThirtyTwoBytes a, struct LDKThirtyTwoBytes b); - -/** - * Frees any resources used by the C2Tuple_PaymentHashPaymentSecretZ. - */ -void C2Tuple_PaymentHashPaymentSecretZ_free(struct LDKC2Tuple_PaymentHashPaymentSecretZ _res); +struct LDKCResult_ClosingSignedFeeRangeDecodeErrorZ CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(const struct LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ in the success state. + * Creates a new CResult_CommitmentSignedDecodeErrorZ in the success state. */ -struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok(struct LDKC2Tuple_PaymentHashPaymentSecretZ o); +struct LDKCResult_CommitmentSignedDecodeErrorZ CResult_CommitmentSignedDecodeErrorZ_ok(struct LDKCommitmentSigned o); /** - * Creates a new CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ in the error state. + * Creates a new CResult_CommitmentSignedDecodeErrorZ in the error state. */ -struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err(void); +struct LDKCResult_CommitmentSignedDecodeErrorZ CResult_CommitmentSignedDecodeErrorZ_err(struct LDKDecodeError e); /** * 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); +bool CResult_CommitmentSignedDecodeErrorZ_is_ok(const struct LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ. + * Frees any resources used by the CResult_CommitmentSignedDecodeErrorZ. */ -void CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free(struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ _res); +void CResult_CommitmentSignedDecodeErrorZ_free(struct LDKCResult_CommitmentSignedDecodeErrorZ _res); /** - * Creates a new CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ which has the same data as `orig` + * Creates a new CResult_CommitmentSignedDecodeErrorZ 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); +struct LDKCResult_CommitmentSignedDecodeErrorZ CResult_CommitmentSignedDecodeErrorZ_clone(const struct LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ in the success state. + * Creates a new CResult_FundingCreatedDecodeErrorZ in the success state. */ -struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok(struct LDKC2Tuple_PaymentHashPaymentSecretZ o); +struct LDKCResult_FundingCreatedDecodeErrorZ CResult_FundingCreatedDecodeErrorZ_ok(struct LDKFundingCreated o); /** - * Creates a new CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ in the error state. + * Creates a new CResult_FundingCreatedDecodeErrorZ in the error state. */ -struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err(struct LDKAPIError e); +struct LDKCResult_FundingCreatedDecodeErrorZ CResult_FundingCreatedDecodeErrorZ_err(struct LDKDecodeError 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); +bool CResult_FundingCreatedDecodeErrorZ_is_ok(const struct LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ. + * Frees any resources used by the CResult_FundingCreatedDecodeErrorZ. */ -void CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free(struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ _res); +void CResult_FundingCreatedDecodeErrorZ_free(struct LDKCResult_FundingCreatedDecodeErrorZ _res); /** - * Creates a new CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ which has the same data as `orig` + * Creates a new CResult_FundingCreatedDecodeErrorZ 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); +struct LDKCResult_FundingCreatedDecodeErrorZ CResult_FundingCreatedDecodeErrorZ_clone(const struct LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_PaymentSecretNoneZ in the success state. + * Creates a new CResult_FundingSignedDecodeErrorZ in the success state. */ -struct LDKCResult_PaymentSecretNoneZ CResult_PaymentSecretNoneZ_ok(struct LDKThirtyTwoBytes o); +struct LDKCResult_FundingSignedDecodeErrorZ CResult_FundingSignedDecodeErrorZ_ok(struct LDKFundingSigned o); /** - * Creates a new CResult_PaymentSecretNoneZ in the error state. + * Creates a new CResult_FundingSignedDecodeErrorZ in the error state. */ -struct LDKCResult_PaymentSecretNoneZ CResult_PaymentSecretNoneZ_err(void); +struct LDKCResult_FundingSignedDecodeErrorZ CResult_FundingSignedDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_PaymentSecretNoneZ_is_ok(const struct LDKCResult_PaymentSecretNoneZ *NONNULL_PTR o); +bool CResult_FundingSignedDecodeErrorZ_is_ok(const struct LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_PaymentSecretNoneZ. + * Frees any resources used by the CResult_FundingSignedDecodeErrorZ. */ -void CResult_PaymentSecretNoneZ_free(struct LDKCResult_PaymentSecretNoneZ _res); +void CResult_FundingSignedDecodeErrorZ_free(struct LDKCResult_FundingSignedDecodeErrorZ _res); /** - * Creates a new CResult_PaymentSecretNoneZ which has the same data as `orig` + * Creates a new CResult_FundingSignedDecodeErrorZ 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); +struct LDKCResult_FundingSignedDecodeErrorZ CResult_FundingSignedDecodeErrorZ_clone(const struct LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_PaymentSecretAPIErrorZ in the success state. + * Creates a new CResult_ChannelReadyDecodeErrorZ in the success state. */ -struct LDKCResult_PaymentSecretAPIErrorZ CResult_PaymentSecretAPIErrorZ_ok(struct LDKThirtyTwoBytes o); +struct LDKCResult_ChannelReadyDecodeErrorZ CResult_ChannelReadyDecodeErrorZ_ok(struct LDKChannelReady o); /** - * Creates a new CResult_PaymentSecretAPIErrorZ in the error state. + * Creates a new CResult_ChannelReadyDecodeErrorZ in the error state. */ -struct LDKCResult_PaymentSecretAPIErrorZ CResult_PaymentSecretAPIErrorZ_err(struct LDKAPIError e); +struct LDKCResult_ChannelReadyDecodeErrorZ CResult_ChannelReadyDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_PaymentSecretAPIErrorZ_is_ok(const struct LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR o); +bool CResult_ChannelReadyDecodeErrorZ_is_ok(const struct LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_PaymentSecretAPIErrorZ. + * Frees any resources used by the CResult_ChannelReadyDecodeErrorZ. */ -void CResult_PaymentSecretAPIErrorZ_free(struct LDKCResult_PaymentSecretAPIErrorZ _res); +void CResult_ChannelReadyDecodeErrorZ_free(struct LDKCResult_ChannelReadyDecodeErrorZ _res); /** - * Creates a new CResult_PaymentSecretAPIErrorZ which has the same data as `orig` + * Creates a new CResult_ChannelReadyDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_PaymentSecretAPIErrorZ CResult_PaymentSecretAPIErrorZ_clone(const struct LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR orig); +struct LDKCResult_ChannelReadyDecodeErrorZ CResult_ChannelReadyDecodeErrorZ_clone(const struct LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_PaymentPreimageAPIErrorZ in the success state. + * Creates a new CResult_InitDecodeErrorZ in the success state. */ -struct LDKCResult_PaymentPreimageAPIErrorZ CResult_PaymentPreimageAPIErrorZ_ok(struct LDKThirtyTwoBytes o); +struct LDKCResult_InitDecodeErrorZ CResult_InitDecodeErrorZ_ok(struct LDKInit o); /** - * Creates a new CResult_PaymentPreimageAPIErrorZ in the error state. + * Creates a new CResult_InitDecodeErrorZ in the error state. */ -struct LDKCResult_PaymentPreimageAPIErrorZ CResult_PaymentPreimageAPIErrorZ_err(struct LDKAPIError e); +struct LDKCResult_InitDecodeErrorZ CResult_InitDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_PaymentPreimageAPIErrorZ_is_ok(const struct LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR o); +bool CResult_InitDecodeErrorZ_is_ok(const struct LDKCResult_InitDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_PaymentPreimageAPIErrorZ. + * Frees any resources used by the CResult_InitDecodeErrorZ. */ -void CResult_PaymentPreimageAPIErrorZ_free(struct LDKCResult_PaymentPreimageAPIErrorZ _res); +void CResult_InitDecodeErrorZ_free(struct LDKCResult_InitDecodeErrorZ _res); /** - * Creates a new CResult_PaymentPreimageAPIErrorZ which has the same data as `orig` + * Creates a new CResult_InitDecodeErrorZ 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); +struct LDKCResult_InitDecodeErrorZ CResult_InitDecodeErrorZ_clone(const struct LDKCResult_InitDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_CounterpartyForwardingInfoDecodeErrorZ in the success state. + * Creates a new CResult_OpenChannelDecodeErrorZ in the success state. */ -struct LDKCResult_CounterpartyForwardingInfoDecodeErrorZ CResult_CounterpartyForwardingInfoDecodeErrorZ_ok(struct LDKCounterpartyForwardingInfo o); +struct LDKCResult_OpenChannelDecodeErrorZ CResult_OpenChannelDecodeErrorZ_ok(struct LDKOpenChannel o); /** - * Creates a new CResult_CounterpartyForwardingInfoDecodeErrorZ in the error state. + * Creates a new CResult_OpenChannelDecodeErrorZ in the error state. */ -struct LDKCResult_CounterpartyForwardingInfoDecodeErrorZ CResult_CounterpartyForwardingInfoDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_OpenChannelDecodeErrorZ CResult_OpenChannelDecodeErrorZ_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); +bool CResult_OpenChannelDecodeErrorZ_is_ok(const struct LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_CounterpartyForwardingInfoDecodeErrorZ. + * Frees any resources used by the CResult_OpenChannelDecodeErrorZ. */ -void CResult_CounterpartyForwardingInfoDecodeErrorZ_free(struct LDKCResult_CounterpartyForwardingInfoDecodeErrorZ _res); +void CResult_OpenChannelDecodeErrorZ_free(struct LDKCResult_OpenChannelDecodeErrorZ _res); /** - * Creates a new CResult_CounterpartyForwardingInfoDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_OpenChannelDecodeErrorZ 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); +struct LDKCResult_OpenChannelDecodeErrorZ CResult_OpenChannelDecodeErrorZ_clone(const struct LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_ChannelCounterpartyDecodeErrorZ in the success state. + * Creates a new CResult_RevokeAndACKDecodeErrorZ in the success state. */ -struct LDKCResult_ChannelCounterpartyDecodeErrorZ CResult_ChannelCounterpartyDecodeErrorZ_ok(struct LDKChannelCounterparty o); +struct LDKCResult_RevokeAndACKDecodeErrorZ CResult_RevokeAndACKDecodeErrorZ_ok(struct LDKRevokeAndACK o); /** - * Creates a new CResult_ChannelCounterpartyDecodeErrorZ in the error state. + * Creates a new CResult_RevokeAndACKDecodeErrorZ in the error state. */ -struct LDKCResult_ChannelCounterpartyDecodeErrorZ CResult_ChannelCounterpartyDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_RevokeAndACKDecodeErrorZ CResult_RevokeAndACKDecodeErrorZ_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); +bool CResult_RevokeAndACKDecodeErrorZ_is_ok(const struct LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_ChannelCounterpartyDecodeErrorZ. + * Frees any resources used by the CResult_RevokeAndACKDecodeErrorZ. */ -void CResult_ChannelCounterpartyDecodeErrorZ_free(struct LDKCResult_ChannelCounterpartyDecodeErrorZ _res); +void CResult_RevokeAndACKDecodeErrorZ_free(struct LDKCResult_RevokeAndACKDecodeErrorZ _res); /** - * Creates a new CResult_ChannelCounterpartyDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_RevokeAndACKDecodeErrorZ 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); +struct LDKCResult_RevokeAndACKDecodeErrorZ CResult_RevokeAndACKDecodeErrorZ_clone(const struct LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_ChannelDetailsDecodeErrorZ in the success state. + * Creates a new CResult_ShutdownDecodeErrorZ in the success state. */ -struct LDKCResult_ChannelDetailsDecodeErrorZ CResult_ChannelDetailsDecodeErrorZ_ok(struct LDKChannelDetails o); +struct LDKCResult_ShutdownDecodeErrorZ CResult_ShutdownDecodeErrorZ_ok(struct LDKShutdown o); /** - * Creates a new CResult_ChannelDetailsDecodeErrorZ in the error state. + * Creates a new CResult_ShutdownDecodeErrorZ in the error state. */ -struct LDKCResult_ChannelDetailsDecodeErrorZ CResult_ChannelDetailsDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_ShutdownDecodeErrorZ CResult_ShutdownDecodeErrorZ_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); +bool CResult_ShutdownDecodeErrorZ_is_ok(const struct LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_ChannelDetailsDecodeErrorZ. + * Frees any resources used by the CResult_ShutdownDecodeErrorZ. */ -void CResult_ChannelDetailsDecodeErrorZ_free(struct LDKCResult_ChannelDetailsDecodeErrorZ _res); +void CResult_ShutdownDecodeErrorZ_free(struct LDKCResult_ShutdownDecodeErrorZ _res); /** - * Creates a new CResult_ChannelDetailsDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_ShutdownDecodeErrorZ 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); +struct LDKCResult_ShutdownDecodeErrorZ CResult_ShutdownDecodeErrorZ_clone(const struct LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_PhantomRouteHintsDecodeErrorZ in the success state. + * Creates a new CResult_UpdateFailHTLCDecodeErrorZ in the success state. */ -struct LDKCResult_PhantomRouteHintsDecodeErrorZ CResult_PhantomRouteHintsDecodeErrorZ_ok(struct LDKPhantomRouteHints o); +struct LDKCResult_UpdateFailHTLCDecodeErrorZ CResult_UpdateFailHTLCDecodeErrorZ_ok(struct LDKUpdateFailHTLC o); /** - * Creates a new CResult_PhantomRouteHintsDecodeErrorZ in the error state. + * Creates a new CResult_UpdateFailHTLCDecodeErrorZ in the error state. */ -struct LDKCResult_PhantomRouteHintsDecodeErrorZ CResult_PhantomRouteHintsDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_UpdateFailHTLCDecodeErrorZ CResult_UpdateFailHTLCDecodeErrorZ_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); +bool CResult_UpdateFailHTLCDecodeErrorZ_is_ok(const struct LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR o); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Frees any resources used by the CResult_UpdateFailHTLCDecodeErrorZ. */ -void CVec_ChannelMonitorZ_free(struct LDKCVec_ChannelMonitorZ _res); +void CResult_UpdateFailHTLCDecodeErrorZ_free(struct LDKCResult_UpdateFailHTLCDecodeErrorZ _res); /** - * Creates a new C2Tuple_BlockHashChannelManagerZ from the contained elements. + * Creates a new CResult_UpdateFailHTLCDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKC2Tuple_BlockHashChannelManagerZ C2Tuple_BlockHashChannelManagerZ_new(struct LDKThirtyTwoBytes a, struct LDKChannelManager b); +struct LDKCResult_UpdateFailHTLCDecodeErrorZ CResult_UpdateFailHTLCDecodeErrorZ_clone(const struct LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR orig); /** - * Frees any resources used by the C2Tuple_BlockHashChannelManagerZ. + * Creates a new CResult_UpdateFailMalformedHTLCDecodeErrorZ in the success state. */ -void C2Tuple_BlockHashChannelManagerZ_free(struct LDKC2Tuple_BlockHashChannelManagerZ _res); +struct LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(struct LDKUpdateFailMalformedHTLC o); /** - * Creates a new CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ in the success state. + * Creates a new CResult_UpdateFailMalformedHTLCDecodeErrorZ in the error state. */ -struct LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(struct LDKC2Tuple_BlockHashChannelManagerZ o); +struct LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(struct LDKDecodeError e); /** - * Creates a new CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ in the error state. + * Checks if the given object is currently in the success state */ -struct LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(struct LDKDecodeError e); +bool CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(const struct LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR o); /** - * Checks if the given object is currently in the success state + * Frees any resources used by the CResult_UpdateFailMalformedHTLCDecodeErrorZ. */ -bool CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok(const struct LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR o); +void CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(struct LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res); /** - * Frees any resources used by the CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ. + * Creates a new CResult_UpdateFailMalformedHTLCDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -void CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(struct LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res); +struct LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(const struct LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_ChannelConfigDecodeErrorZ in the success state. + * Creates a new CResult_UpdateFeeDecodeErrorZ in the success state. */ -struct LDKCResult_ChannelConfigDecodeErrorZ CResult_ChannelConfigDecodeErrorZ_ok(struct LDKChannelConfig o); +struct LDKCResult_UpdateFeeDecodeErrorZ CResult_UpdateFeeDecodeErrorZ_ok(struct LDKUpdateFee o); /** - * Creates a new CResult_ChannelConfigDecodeErrorZ in the error state. + * Creates a new CResult_UpdateFeeDecodeErrorZ in the error state. */ -struct LDKCResult_ChannelConfigDecodeErrorZ CResult_ChannelConfigDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_UpdateFeeDecodeErrorZ CResult_UpdateFeeDecodeErrorZ_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); +bool CResult_UpdateFeeDecodeErrorZ_is_ok(const struct LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_ChannelConfigDecodeErrorZ. + * Frees any resources used by the CResult_UpdateFeeDecodeErrorZ. */ -void CResult_ChannelConfigDecodeErrorZ_free(struct LDKCResult_ChannelConfigDecodeErrorZ _res); +void CResult_UpdateFeeDecodeErrorZ_free(struct LDKCResult_UpdateFeeDecodeErrorZ _res); /** - * Creates a new CResult_ChannelConfigDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_UpdateFeeDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_ChannelConfigDecodeErrorZ CResult_ChannelConfigDecodeErrorZ_clone(const struct LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_UpdateFeeDecodeErrorZ CResult_UpdateFeeDecodeErrorZ_clone(const struct LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_OutPointDecodeErrorZ in the success state. + * Creates a new CResult_UpdateFulfillHTLCDecodeErrorZ in the success state. */ -struct LDKCResult_OutPointDecodeErrorZ CResult_OutPointDecodeErrorZ_ok(struct LDKOutPoint o); +struct LDKCResult_UpdateFulfillHTLCDecodeErrorZ CResult_UpdateFulfillHTLCDecodeErrorZ_ok(struct LDKUpdateFulfillHTLC o); /** - * Creates a new CResult_OutPointDecodeErrorZ in the error state. + * Creates a new CResult_UpdateFulfillHTLCDecodeErrorZ in the error state. */ -struct LDKCResult_OutPointDecodeErrorZ CResult_OutPointDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_UpdateFulfillHTLCDecodeErrorZ CResult_UpdateFulfillHTLCDecodeErrorZ_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); +bool CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(const struct LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_OutPointDecodeErrorZ. + * Frees any resources used by the CResult_UpdateFulfillHTLCDecodeErrorZ. */ -void CResult_OutPointDecodeErrorZ_free(struct LDKCResult_OutPointDecodeErrorZ _res); +void CResult_UpdateFulfillHTLCDecodeErrorZ_free(struct LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res); /** - * Creates a new CResult_OutPointDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_UpdateFulfillHTLCDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_OutPointDecodeErrorZ CResult_OutPointDecodeErrorZ_clone(const struct LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_UpdateFulfillHTLCDecodeErrorZ CResult_UpdateFulfillHTLCDecodeErrorZ_clone(const struct LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR orig); /** - * Constructs a new COption_TypeZ containing a crate::lightning::ln::wire::Type + * Creates a new CResult_UpdateAddHTLCDecodeErrorZ in the success state. */ -struct LDKCOption_TypeZ COption_TypeZ_some(struct LDKType o); +struct LDKCResult_UpdateAddHTLCDecodeErrorZ CResult_UpdateAddHTLCDecodeErrorZ_ok(struct LDKUpdateAddHTLC o); /** - * Constructs a new COption_TypeZ containing nothing + * Creates a new CResult_UpdateAddHTLCDecodeErrorZ in the error state. */ -struct LDKCOption_TypeZ COption_TypeZ_none(void); +struct LDKCResult_UpdateAddHTLCDecodeErrorZ CResult_UpdateAddHTLCDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees any resources associated with the crate::lightning::ln::wire::Type, if we are in the Some state + * Checks if the given object is currently in the success state */ -void COption_TypeZ_free(struct LDKCOption_TypeZ _res); +bool CResult_UpdateAddHTLCDecodeErrorZ_is_ok(const struct LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR o); /** - * Creates a new CResult_COption_TypeZDecodeErrorZ in the success state. + * Frees any resources used by the CResult_UpdateAddHTLCDecodeErrorZ. */ -struct LDKCResult_COption_TypeZDecodeErrorZ CResult_COption_TypeZDecodeErrorZ_ok(struct LDKCOption_TypeZ o); +void CResult_UpdateAddHTLCDecodeErrorZ_free(struct LDKCResult_UpdateAddHTLCDecodeErrorZ _res); /** - * Creates a new CResult_COption_TypeZDecodeErrorZ in the error state. + * Creates a new CResult_UpdateAddHTLCDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_COption_TypeZDecodeErrorZ CResult_COption_TypeZDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_UpdateAddHTLCDecodeErrorZ CResult_UpdateAddHTLCDecodeErrorZ_clone(const struct LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_OnionMessageDecodeErrorZ in the success state. + */ +struct LDKCResult_OnionMessageDecodeErrorZ CResult_OnionMessageDecodeErrorZ_ok(struct LDKOnionMessage o); + +/** + * Creates a new CResult_OnionMessageDecodeErrorZ in the error state. + */ +struct LDKCResult_OnionMessageDecodeErrorZ CResult_OnionMessageDecodeErrorZ_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); +bool CResult_OnionMessageDecodeErrorZ_is_ok(const struct LDKCResult_OnionMessageDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_COption_TypeZDecodeErrorZ. + * Frees any resources used by the CResult_OnionMessageDecodeErrorZ. */ -void CResult_COption_TypeZDecodeErrorZ_free(struct LDKCResult_COption_TypeZDecodeErrorZ _res); +void CResult_OnionMessageDecodeErrorZ_free(struct LDKCResult_OnionMessageDecodeErrorZ _res); /** - * Creates a new CResult_PaymentIdPaymentErrorZ in the success state. + * Creates a new CResult_OnionMessageDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_PaymentIdPaymentErrorZ CResult_PaymentIdPaymentErrorZ_ok(struct LDKThirtyTwoBytes o); +struct LDKCResult_OnionMessageDecodeErrorZ CResult_OnionMessageDecodeErrorZ_clone(const struct LDKCResult_OnionMessageDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_PaymentIdPaymentErrorZ in the error state. + * Creates a new CResult_PingDecodeErrorZ in the success state. */ -struct LDKCResult_PaymentIdPaymentErrorZ CResult_PaymentIdPaymentErrorZ_err(struct LDKPaymentError e); +struct LDKCResult_PingDecodeErrorZ CResult_PingDecodeErrorZ_ok(struct LDKPing o); + +/** + * Creates a new CResult_PingDecodeErrorZ in the error state. + */ +struct LDKCResult_PingDecodeErrorZ CResult_PingDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_PaymentIdPaymentErrorZ_is_ok(const struct LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR o); +bool CResult_PingDecodeErrorZ_is_ok(const struct LDKCResult_PingDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_PaymentIdPaymentErrorZ. + * Frees any resources used by the CResult_PingDecodeErrorZ. */ -void CResult_PaymentIdPaymentErrorZ_free(struct LDKCResult_PaymentIdPaymentErrorZ _res); +void CResult_PingDecodeErrorZ_free(struct LDKCResult_PingDecodeErrorZ _res); /** - * Creates a new CResult_PaymentIdPaymentErrorZ which has the same data as `orig` + * Creates a new CResult_PingDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_PaymentIdPaymentErrorZ CResult_PaymentIdPaymentErrorZ_clone(const struct LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR orig); +struct LDKCResult_PingDecodeErrorZ CResult_PingDecodeErrorZ_clone(const struct LDKCResult_PingDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_SiPrefixNoneZ in the success state. + * Creates a new CResult_PongDecodeErrorZ in the success state. */ -struct LDKCResult_SiPrefixNoneZ CResult_SiPrefixNoneZ_ok(enum LDKSiPrefix o); +struct LDKCResult_PongDecodeErrorZ CResult_PongDecodeErrorZ_ok(struct LDKPong o); /** - * Creates a new CResult_SiPrefixNoneZ in the error state. + * Creates a new CResult_PongDecodeErrorZ in the error state. */ -struct LDKCResult_SiPrefixNoneZ CResult_SiPrefixNoneZ_err(void); +struct LDKCResult_PongDecodeErrorZ CResult_PongDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_SiPrefixNoneZ_is_ok(const struct LDKCResult_SiPrefixNoneZ *NONNULL_PTR o); +bool CResult_PongDecodeErrorZ_is_ok(const struct LDKCResult_PongDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_SiPrefixNoneZ. + * Frees any resources used by the CResult_PongDecodeErrorZ. */ -void CResult_SiPrefixNoneZ_free(struct LDKCResult_SiPrefixNoneZ _res); +void CResult_PongDecodeErrorZ_free(struct LDKCResult_PongDecodeErrorZ _res); /** - * Creates a new CResult_SiPrefixNoneZ which has the same data as `orig` + * Creates a new CResult_PongDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_SiPrefixNoneZ CResult_SiPrefixNoneZ_clone(const struct LDKCResult_SiPrefixNoneZ *NONNULL_PTR orig); +struct LDKCResult_PongDecodeErrorZ CResult_PongDecodeErrorZ_clone(const struct LDKCResult_PongDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_InvoiceNoneZ in the success state. + * Creates a new CResult_UnsignedChannelAnnouncementDecodeErrorZ in the success state. */ -struct LDKCResult_InvoiceNoneZ CResult_InvoiceNoneZ_ok(struct LDKInvoice o); +struct LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(struct LDKUnsignedChannelAnnouncement o); /** - * Creates a new CResult_InvoiceNoneZ in the error state. + * Creates a new CResult_UnsignedChannelAnnouncementDecodeErrorZ in the error state. */ -struct LDKCResult_InvoiceNoneZ CResult_InvoiceNoneZ_err(void); +struct LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_InvoiceNoneZ_is_ok(const struct LDKCResult_InvoiceNoneZ *NONNULL_PTR o); +bool CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(const struct LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_InvoiceNoneZ. + * Frees any resources used by the CResult_UnsignedChannelAnnouncementDecodeErrorZ. */ -void CResult_InvoiceNoneZ_free(struct LDKCResult_InvoiceNoneZ _res); +void CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(struct LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res); /** - * Creates a new CResult_InvoiceNoneZ which has the same data as `orig` + * Creates a new CResult_UnsignedChannelAnnouncementDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_InvoiceNoneZ CResult_InvoiceNoneZ_clone(const struct LDKCResult_InvoiceNoneZ *NONNULL_PTR orig); +struct LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(const struct LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_SignedRawInvoiceNoneZ in the success state. + * Creates a new CResult_ChannelAnnouncementDecodeErrorZ in the success state. */ -struct LDKCResult_SignedRawInvoiceNoneZ CResult_SignedRawInvoiceNoneZ_ok(struct LDKSignedRawInvoice o); +struct LDKCResult_ChannelAnnouncementDecodeErrorZ CResult_ChannelAnnouncementDecodeErrorZ_ok(struct LDKChannelAnnouncement o); /** - * Creates a new CResult_SignedRawInvoiceNoneZ in the error state. + * Creates a new CResult_ChannelAnnouncementDecodeErrorZ in the error state. */ -struct LDKCResult_SignedRawInvoiceNoneZ CResult_SignedRawInvoiceNoneZ_err(void); +struct LDKCResult_ChannelAnnouncementDecodeErrorZ CResult_ChannelAnnouncementDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_SignedRawInvoiceNoneZ_is_ok(const struct LDKCResult_SignedRawInvoiceNoneZ *NONNULL_PTR o); +bool CResult_ChannelAnnouncementDecodeErrorZ_is_ok(const struct LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_SignedRawInvoiceNoneZ. + * Frees any resources used by the CResult_ChannelAnnouncementDecodeErrorZ. */ -void CResult_SignedRawInvoiceNoneZ_free(struct LDKCResult_SignedRawInvoiceNoneZ _res); +void CResult_ChannelAnnouncementDecodeErrorZ_free(struct LDKCResult_ChannelAnnouncementDecodeErrorZ _res); /** - * Creates a new CResult_SignedRawInvoiceNoneZ which has the same data as `orig` + * Creates a new CResult_ChannelAnnouncementDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_SignedRawInvoiceNoneZ CResult_SignedRawInvoiceNoneZ_clone(const struct LDKCResult_SignedRawInvoiceNoneZ *NONNULL_PTR orig); +struct LDKCResult_ChannelAnnouncementDecodeErrorZ CResult_ChannelAnnouncementDecodeErrorZ_clone(const struct LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new tuple which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Creates a new CResult_UnsignedChannelUpdateDecodeErrorZ in the success state. */ -struct LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(const struct LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR orig); +struct LDKCResult_UnsignedChannelUpdateDecodeErrorZ CResult_UnsignedChannelUpdateDecodeErrorZ_ok(struct LDKUnsignedChannelUpdate o); + +/** + * Creates a new CResult_UnsignedChannelUpdateDecodeErrorZ in the error state. + */ +struct LDKCResult_UnsignedChannelUpdateDecodeErrorZ CResult_UnsignedChannelUpdateDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(const struct LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR o); /** - * Creates a new C3Tuple_RawInvoice_u832InvoiceSignatureZ from the contained elements. + * Frees any resources used by the CResult_UnsignedChannelUpdateDecodeErrorZ. */ -struct LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(struct LDKRawInvoice a, struct LDKThirtyTwoBytes b, struct LDKInvoiceSignature c); +void CResult_UnsignedChannelUpdateDecodeErrorZ_free(struct LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res); /** - * Frees any resources used by the C3Tuple_RawInvoice_u832InvoiceSignatureZ. + * Creates a new CResult_UnsignedChannelUpdateDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -void C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(struct LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res); +struct LDKCResult_UnsignedChannelUpdateDecodeErrorZ CResult_UnsignedChannelUpdateDecodeErrorZ_clone(const struct LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_PayeePubKeyErrorZ in the success state. + * Creates a new CResult_ChannelUpdateDecodeErrorZ in the success state. */ -struct LDKCResult_PayeePubKeyErrorZ CResult_PayeePubKeyErrorZ_ok(struct LDKPayeePubKey o); +struct LDKCResult_ChannelUpdateDecodeErrorZ CResult_ChannelUpdateDecodeErrorZ_ok(struct LDKChannelUpdate o); /** - * Creates a new CResult_PayeePubKeyErrorZ in the error state. + * Creates a new CResult_ChannelUpdateDecodeErrorZ in the error state. */ -struct LDKCResult_PayeePubKeyErrorZ CResult_PayeePubKeyErrorZ_err(enum LDKSecp256k1Error e); +struct LDKCResult_ChannelUpdateDecodeErrorZ CResult_ChannelUpdateDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_PayeePubKeyErrorZ_is_ok(const struct LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR o); +bool CResult_ChannelUpdateDecodeErrorZ_is_ok(const struct LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_PayeePubKeyErrorZ. + * Frees any resources used by the CResult_ChannelUpdateDecodeErrorZ. */ -void CResult_PayeePubKeyErrorZ_free(struct LDKCResult_PayeePubKeyErrorZ _res); +void CResult_ChannelUpdateDecodeErrorZ_free(struct LDKCResult_ChannelUpdateDecodeErrorZ _res); /** - * Creates a new CResult_PayeePubKeyErrorZ which has the same data as `orig` + * Creates a new CResult_ChannelUpdateDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_PayeePubKeyErrorZ CResult_PayeePubKeyErrorZ_clone(const struct LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR orig); - -/** - * Frees the buffer pointed to by `data` if `datalen` is non-0. - */ -void CVec_PrivateRouteZ_free(struct LDKCVec_PrivateRouteZ _res); +struct LDKCResult_ChannelUpdateDecodeErrorZ CResult_ChannelUpdateDecodeErrorZ_clone(const struct LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_PositiveTimestampCreationErrorZ in the success state. + * Creates a new CResult_ErrorMessageDecodeErrorZ in the success state. */ -struct LDKCResult_PositiveTimestampCreationErrorZ CResult_PositiveTimestampCreationErrorZ_ok(struct LDKPositiveTimestamp o); +struct LDKCResult_ErrorMessageDecodeErrorZ CResult_ErrorMessageDecodeErrorZ_ok(struct LDKErrorMessage o); /** - * Creates a new CResult_PositiveTimestampCreationErrorZ in the error state. + * Creates a new CResult_ErrorMessageDecodeErrorZ in the error state. */ -struct LDKCResult_PositiveTimestampCreationErrorZ CResult_PositiveTimestampCreationErrorZ_err(enum LDKCreationError e); +struct LDKCResult_ErrorMessageDecodeErrorZ CResult_ErrorMessageDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_PositiveTimestampCreationErrorZ_is_ok(const struct LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR o); +bool CResult_ErrorMessageDecodeErrorZ_is_ok(const struct LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_PositiveTimestampCreationErrorZ. + * Frees any resources used by the CResult_ErrorMessageDecodeErrorZ. */ -void CResult_PositiveTimestampCreationErrorZ_free(struct LDKCResult_PositiveTimestampCreationErrorZ _res); +void CResult_ErrorMessageDecodeErrorZ_free(struct LDKCResult_ErrorMessageDecodeErrorZ _res); /** - * Creates a new CResult_PositiveTimestampCreationErrorZ which has the same data as `orig` + * Creates a new CResult_ErrorMessageDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_PositiveTimestampCreationErrorZ CResult_PositiveTimestampCreationErrorZ_clone(const struct LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR orig); +struct LDKCResult_ErrorMessageDecodeErrorZ CResult_ErrorMessageDecodeErrorZ_clone(const struct LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_NoneSemanticErrorZ in the success state. + * Creates a new CResult_WarningMessageDecodeErrorZ in the success state. */ -struct LDKCResult_NoneSemanticErrorZ CResult_NoneSemanticErrorZ_ok(void); +struct LDKCResult_WarningMessageDecodeErrorZ CResult_WarningMessageDecodeErrorZ_ok(struct LDKWarningMessage o); /** - * Creates a new CResult_NoneSemanticErrorZ in the error state. + * Creates a new CResult_WarningMessageDecodeErrorZ in the error state. */ -struct LDKCResult_NoneSemanticErrorZ CResult_NoneSemanticErrorZ_err(enum LDKSemanticError e); +struct LDKCResult_WarningMessageDecodeErrorZ CResult_WarningMessageDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_NoneSemanticErrorZ_is_ok(const struct LDKCResult_NoneSemanticErrorZ *NONNULL_PTR o); +bool CResult_WarningMessageDecodeErrorZ_is_ok(const struct LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_NoneSemanticErrorZ. + * Frees any resources used by the CResult_WarningMessageDecodeErrorZ. */ -void CResult_NoneSemanticErrorZ_free(struct LDKCResult_NoneSemanticErrorZ _res); +void CResult_WarningMessageDecodeErrorZ_free(struct LDKCResult_WarningMessageDecodeErrorZ _res); /** - * Creates a new CResult_NoneSemanticErrorZ which has the same data as `orig` + * Creates a new CResult_WarningMessageDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_NoneSemanticErrorZ CResult_NoneSemanticErrorZ_clone(const struct LDKCResult_NoneSemanticErrorZ *NONNULL_PTR orig); +struct LDKCResult_WarningMessageDecodeErrorZ CResult_WarningMessageDecodeErrorZ_clone(const struct LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_InvoiceSemanticErrorZ in the success state. + * Creates a new CResult_UnsignedNodeAnnouncementDecodeErrorZ in the success state. */ -struct LDKCResult_InvoiceSemanticErrorZ CResult_InvoiceSemanticErrorZ_ok(struct LDKInvoice o); +struct LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(struct LDKUnsignedNodeAnnouncement o); /** - * Creates a new CResult_InvoiceSemanticErrorZ in the error state. + * Creates a new CResult_UnsignedNodeAnnouncementDecodeErrorZ in the error state. */ -struct LDKCResult_InvoiceSemanticErrorZ CResult_InvoiceSemanticErrorZ_err(enum LDKSemanticError e); +struct LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_InvoiceSemanticErrorZ_is_ok(const struct LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR o); +bool CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(const struct LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_InvoiceSemanticErrorZ. + * Frees any resources used by the CResult_UnsignedNodeAnnouncementDecodeErrorZ. */ -void CResult_InvoiceSemanticErrorZ_free(struct LDKCResult_InvoiceSemanticErrorZ _res); +void CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(struct LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res); /** - * Creates a new CResult_InvoiceSemanticErrorZ which has the same data as `orig` + * Creates a new CResult_UnsignedNodeAnnouncementDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_InvoiceSemanticErrorZ CResult_InvoiceSemanticErrorZ_clone(const struct LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR orig); +struct LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(const struct LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_DescriptionCreationErrorZ in the success state. + * Creates a new CResult_NodeAnnouncementDecodeErrorZ in the success state. */ -struct LDKCResult_DescriptionCreationErrorZ CResult_DescriptionCreationErrorZ_ok(struct LDKDescription o); +struct LDKCResult_NodeAnnouncementDecodeErrorZ CResult_NodeAnnouncementDecodeErrorZ_ok(struct LDKNodeAnnouncement o); /** - * Creates a new CResult_DescriptionCreationErrorZ in the error state. + * Creates a new CResult_NodeAnnouncementDecodeErrorZ in the error state. */ -struct LDKCResult_DescriptionCreationErrorZ CResult_DescriptionCreationErrorZ_err(enum LDKCreationError e); +struct LDKCResult_NodeAnnouncementDecodeErrorZ CResult_NodeAnnouncementDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_DescriptionCreationErrorZ_is_ok(const struct LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR o); +bool CResult_NodeAnnouncementDecodeErrorZ_is_ok(const struct LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_DescriptionCreationErrorZ. + * Frees any resources used by the CResult_NodeAnnouncementDecodeErrorZ. */ -void CResult_DescriptionCreationErrorZ_free(struct LDKCResult_DescriptionCreationErrorZ _res); +void CResult_NodeAnnouncementDecodeErrorZ_free(struct LDKCResult_NodeAnnouncementDecodeErrorZ _res); /** - * Creates a new CResult_DescriptionCreationErrorZ which has the same data as `orig` + * Creates a new CResult_NodeAnnouncementDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_DescriptionCreationErrorZ CResult_DescriptionCreationErrorZ_clone(const struct LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR orig); +struct LDKCResult_NodeAnnouncementDecodeErrorZ CResult_NodeAnnouncementDecodeErrorZ_clone(const struct LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_PrivateRouteCreationErrorZ in the success state. + * Creates a new CResult_QueryShortChannelIdsDecodeErrorZ in the success state. */ -struct LDKCResult_PrivateRouteCreationErrorZ CResult_PrivateRouteCreationErrorZ_ok(struct LDKPrivateRoute o); +struct LDKCResult_QueryShortChannelIdsDecodeErrorZ CResult_QueryShortChannelIdsDecodeErrorZ_ok(struct LDKQueryShortChannelIds o); /** - * Creates a new CResult_PrivateRouteCreationErrorZ in the error state. + * Creates a new CResult_QueryShortChannelIdsDecodeErrorZ in the error state. */ -struct LDKCResult_PrivateRouteCreationErrorZ CResult_PrivateRouteCreationErrorZ_err(enum LDKCreationError e); +struct LDKCResult_QueryShortChannelIdsDecodeErrorZ CResult_QueryShortChannelIdsDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_PrivateRouteCreationErrorZ_is_ok(const struct LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR o); +bool CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(const struct LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_PrivateRouteCreationErrorZ. + * Frees any resources used by the CResult_QueryShortChannelIdsDecodeErrorZ. */ -void CResult_PrivateRouteCreationErrorZ_free(struct LDKCResult_PrivateRouteCreationErrorZ _res); +void CResult_QueryShortChannelIdsDecodeErrorZ_free(struct LDKCResult_QueryShortChannelIdsDecodeErrorZ _res); /** - * Creates a new CResult_PrivateRouteCreationErrorZ which has the same data as `orig` + * Creates a new CResult_QueryShortChannelIdsDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_PrivateRouteCreationErrorZ CResult_PrivateRouteCreationErrorZ_clone(const struct LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR orig); +struct LDKCResult_QueryShortChannelIdsDecodeErrorZ CResult_QueryShortChannelIdsDecodeErrorZ_clone(const struct LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_StringErrorZ in the success state. + * Creates a new CResult_ReplyShortChannelIdsEndDecodeErrorZ in the success state. */ -struct LDKCResult_StringErrorZ CResult_StringErrorZ_ok(struct LDKStr o); +struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(struct LDKReplyShortChannelIdsEnd o); /** - * Creates a new CResult_StringErrorZ in the error state. + * Creates a new CResult_ReplyShortChannelIdsEndDecodeErrorZ in the error state. */ -struct LDKCResult_StringErrorZ CResult_StringErrorZ_err(enum LDKSecp256k1Error e); +struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_StringErrorZ_is_ok(const struct LDKCResult_StringErrorZ *NONNULL_PTR o); +bool CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(const struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_StringErrorZ. + * Frees any resources used by the CResult_ReplyShortChannelIdsEndDecodeErrorZ. */ -void CResult_StringErrorZ_free(struct LDKCResult_StringErrorZ _res); +void CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res); /** - * Creates a new CResult_ChannelMonitorUpdateDecodeErrorZ in the success state. + * Creates a new CResult_ReplyShortChannelIdsEndDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_ChannelMonitorUpdateDecodeErrorZ CResult_ChannelMonitorUpdateDecodeErrorZ_ok(struct LDKChannelMonitorUpdate o); +struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(const struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_ChannelMonitorUpdateDecodeErrorZ in the error state. + * Creates a new CResult_QueryChannelRangeDecodeErrorZ in the success state. */ -struct LDKCResult_ChannelMonitorUpdateDecodeErrorZ CResult_ChannelMonitorUpdateDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_QueryChannelRangeDecodeErrorZ CResult_QueryChannelRangeDecodeErrorZ_ok(struct LDKQueryChannelRange o); + +/** + * Creates a new CResult_QueryChannelRangeDecodeErrorZ in the error state. + */ +struct LDKCResult_QueryChannelRangeDecodeErrorZ CResult_QueryChannelRangeDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(const struct LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR o); +bool CResult_QueryChannelRangeDecodeErrorZ_is_ok(const struct LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_ChannelMonitorUpdateDecodeErrorZ. + * Frees any resources used by the CResult_QueryChannelRangeDecodeErrorZ. */ -void CResult_ChannelMonitorUpdateDecodeErrorZ_free(struct LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res); +void CResult_QueryChannelRangeDecodeErrorZ_free(struct LDKCResult_QueryChannelRangeDecodeErrorZ _res); /** - * Creates a new CResult_ChannelMonitorUpdateDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_QueryChannelRangeDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_ChannelMonitorUpdateDecodeErrorZ CResult_ChannelMonitorUpdateDecodeErrorZ_clone(const struct LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_QueryChannelRangeDecodeErrorZ CResult_QueryChannelRangeDecodeErrorZ_clone(const struct LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR orig); /** - * Constructs a new COption_MonitorEventZ containing a crate::lightning::chain::channelmonitor::MonitorEvent + * Creates a new CResult_ReplyChannelRangeDecodeErrorZ in the success state. */ -struct LDKCOption_MonitorEventZ COption_MonitorEventZ_some(struct LDKMonitorEvent o); +struct LDKCResult_ReplyChannelRangeDecodeErrorZ CResult_ReplyChannelRangeDecodeErrorZ_ok(struct LDKReplyChannelRange o); /** - * Constructs a new COption_MonitorEventZ containing nothing + * Creates a new CResult_ReplyChannelRangeDecodeErrorZ in the error state. */ -struct LDKCOption_MonitorEventZ COption_MonitorEventZ_none(void); +struct LDKCResult_ReplyChannelRangeDecodeErrorZ CResult_ReplyChannelRangeDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees any resources associated with the crate::lightning::chain::channelmonitor::MonitorEvent, if we are in the Some state + * Checks if the given object is currently in the success state */ -void COption_MonitorEventZ_free(struct LDKCOption_MonitorEventZ _res); +bool CResult_ReplyChannelRangeDecodeErrorZ_is_ok(const struct LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR o); /** - * Creates a new COption_MonitorEventZ which has the same data as `orig` + * Frees any resources used by the CResult_ReplyChannelRangeDecodeErrorZ. + */ +void CResult_ReplyChannelRangeDecodeErrorZ_free(struct LDKCResult_ReplyChannelRangeDecodeErrorZ _res); + +/** + * Creates a new CResult_ReplyChannelRangeDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCOption_MonitorEventZ COption_MonitorEventZ_clone(const struct LDKCOption_MonitorEventZ *NONNULL_PTR orig); +struct LDKCResult_ReplyChannelRangeDecodeErrorZ CResult_ReplyChannelRangeDecodeErrorZ_clone(const struct LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_COption_MonitorEventZDecodeErrorZ in the success state. + * Creates a new CResult_GossipTimestampFilterDecodeErrorZ in the success state. */ -struct LDKCResult_COption_MonitorEventZDecodeErrorZ CResult_COption_MonitorEventZDecodeErrorZ_ok(struct LDKCOption_MonitorEventZ o); +struct LDKCResult_GossipTimestampFilterDecodeErrorZ CResult_GossipTimestampFilterDecodeErrorZ_ok(struct LDKGossipTimestampFilter o); /** - * Creates a new CResult_COption_MonitorEventZDecodeErrorZ in the error state. + * Creates a new CResult_GossipTimestampFilterDecodeErrorZ in the error state. */ -struct LDKCResult_COption_MonitorEventZDecodeErrorZ CResult_COption_MonitorEventZDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_GossipTimestampFilterDecodeErrorZ CResult_GossipTimestampFilterDecodeErrorZ_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); +bool CResult_GossipTimestampFilterDecodeErrorZ_is_ok(const struct LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_COption_MonitorEventZDecodeErrorZ. + * Frees any resources used by the CResult_GossipTimestampFilterDecodeErrorZ. */ -void CResult_COption_MonitorEventZDecodeErrorZ_free(struct LDKCResult_COption_MonitorEventZDecodeErrorZ _res); +void CResult_GossipTimestampFilterDecodeErrorZ_free(struct LDKCResult_GossipTimestampFilterDecodeErrorZ _res); /** - * Creates a new CResult_COption_MonitorEventZDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_GossipTimestampFilterDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_COption_MonitorEventZDecodeErrorZ CResult_COption_MonitorEventZDecodeErrorZ_clone(const struct LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_GossipTimestampFilterDecodeErrorZ CResult_GossipTimestampFilterDecodeErrorZ_clone(const struct LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_HTLCUpdateDecodeErrorZ in the success state. + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -struct LDKCResult_HTLCUpdateDecodeErrorZ CResult_HTLCUpdateDecodeErrorZ_ok(struct LDKHTLCUpdate o); +void CVec_PhantomRouteHintsZ_free(struct LDKCVec_PhantomRouteHintsZ _res); /** - * Creates a new CResult_HTLCUpdateDecodeErrorZ in the error state. + * Creates a new CResult_InvoiceSignOrCreationErrorZ in the success state. */ -struct LDKCResult_HTLCUpdateDecodeErrorZ CResult_HTLCUpdateDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_InvoiceSignOrCreationErrorZ CResult_InvoiceSignOrCreationErrorZ_ok(struct LDKInvoice o); + +/** + * Creates a new CResult_InvoiceSignOrCreationErrorZ in the error state. + */ +struct LDKCResult_InvoiceSignOrCreationErrorZ CResult_InvoiceSignOrCreationErrorZ_err(struct LDKSignOrCreationError e); /** * Checks if the given object is currently in the success state */ -bool CResult_HTLCUpdateDecodeErrorZ_is_ok(const struct LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR o); +bool CResult_InvoiceSignOrCreationErrorZ_is_ok(const struct LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_HTLCUpdateDecodeErrorZ. + * Frees any resources used by the CResult_InvoiceSignOrCreationErrorZ. */ -void CResult_HTLCUpdateDecodeErrorZ_free(struct LDKCResult_HTLCUpdateDecodeErrorZ _res); +void CResult_InvoiceSignOrCreationErrorZ_free(struct LDKCResult_InvoiceSignOrCreationErrorZ _res); /** - * Creates a new CResult_HTLCUpdateDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_InvoiceSignOrCreationErrorZ 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 LDKCResult_InvoiceSignOrCreationErrorZ CResult_InvoiceSignOrCreationErrorZ_clone(const struct LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR orig); /** - * Creates a new tuple which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Constructs a new COption_FilterZ containing a crate::lightning::chain::Filter */ -struct LDKC2Tuple_OutPointScriptZ C2Tuple_OutPointScriptZ_clone(const struct LDKC2Tuple_OutPointScriptZ *NONNULL_PTR orig); +struct LDKCOption_FilterZ COption_FilterZ_some(struct LDKFilter o); /** - * Creates a new C2Tuple_OutPointScriptZ from the contained elements. + * Constructs a new COption_FilterZ containing nothing */ -struct LDKC2Tuple_OutPointScriptZ C2Tuple_OutPointScriptZ_new(struct LDKOutPoint a, struct LDKCVec_u8Z b); +struct LDKCOption_FilterZ COption_FilterZ_none(void); /** - * Frees any resources used by the C2Tuple_OutPointScriptZ. + * Frees any resources associated with the crate::lightning::chain::Filter, if we are in the Some state */ -void C2Tuple_OutPointScriptZ_free(struct LDKC2Tuple_OutPointScriptZ _res); +void COption_FilterZ_free(struct LDKCOption_FilterZ _res); /** - * Creates a new tuple which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Creates a new CResult_LockedChannelMonitorNoneZ in the success state. */ -struct LDKC2Tuple_u32ScriptZ C2Tuple_u32ScriptZ_clone(const struct LDKC2Tuple_u32ScriptZ *NONNULL_PTR orig); +struct LDKCResult_LockedChannelMonitorNoneZ CResult_LockedChannelMonitorNoneZ_ok(struct LDKLockedChannelMonitor o); /** - * Creates a new C2Tuple_u32ScriptZ from the contained elements. + * Creates a new CResult_LockedChannelMonitorNoneZ in the error state. */ -struct LDKC2Tuple_u32ScriptZ C2Tuple_u32ScriptZ_new(uint32_t a, struct LDKCVec_u8Z b); +struct LDKCResult_LockedChannelMonitorNoneZ CResult_LockedChannelMonitorNoneZ_err(void); /** - * Frees any resources used by the C2Tuple_u32ScriptZ. + * Checks if the given object is currently in the success state */ -void C2Tuple_u32ScriptZ_free(struct LDKC2Tuple_u32ScriptZ _res); +bool CResult_LockedChannelMonitorNoneZ_is_ok(const struct LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR o); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Frees any resources used by the CResult_LockedChannelMonitorNoneZ. */ -void CVec_C2Tuple_u32ScriptZZ_free(struct LDKCVec_C2Tuple_u32ScriptZZ _res); +void CResult_LockedChannelMonitorNoneZ_free(struct LDKCResult_LockedChannelMonitorNoneZ _res); /** - * Creates a new tuple 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 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(const struct LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR orig); +void CVec_OutPointZ_free(struct LDKCVec_OutPointZ _res); /** - * Creates a new C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ from the contained elements. + * Frees any resources used by the PaymentPurpose */ -struct LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(struct LDKThirtyTwoBytes a, struct LDKCVec_C2Tuple_u32ScriptZZ b); +void PaymentPurpose_free(struct LDKPaymentPurpose this_ptr); /** - * Frees any resources used by the C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ. + * Creates a copy of the PaymentPurpose */ -void C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(struct LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res); +struct LDKPaymentPurpose PaymentPurpose_clone(const struct LDKPaymentPurpose *NONNULL_PTR orig); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Utility method to constructs a new InvoicePayment-variant PaymentPurpose */ -void CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(struct LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res); +struct LDKPaymentPurpose PaymentPurpose_invoice_payment(struct LDKThirtyTwoBytes payment_preimage, struct LDKThirtyTwoBytes payment_secret); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Utility method to constructs a new SpontaneousPayment-variant PaymentPurpose */ -void CVec_EventZ_free(struct LDKCVec_EventZ _res); +struct LDKPaymentPurpose PaymentPurpose_spontaneous_payment(struct LDKThirtyTwoBytes a); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Serialize the PaymentPurpose object into a byte array which can be read by PaymentPurpose_read */ -void CVec_TransactionZ_free(struct LDKCVec_TransactionZ _res); +struct LDKCVec_u8Z PaymentPurpose_write(const struct LDKPaymentPurpose *NONNULL_PTR obj); /** - * Creates a new tuple which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Read a PaymentPurpose from a byte array, created by PaymentPurpose_write */ -struct LDKC2Tuple_u32TxOutZ C2Tuple_u32TxOutZ_clone(const struct LDKC2Tuple_u32TxOutZ *NONNULL_PTR orig); +struct LDKCResult_PaymentPurposeDecodeErrorZ PaymentPurpose_read(struct LDKu8slice ser); /** - * Creates a new C2Tuple_u32TxOutZ from the contained elements. + * Frees any resources used by the ClosureReason */ -struct LDKC2Tuple_u32TxOutZ C2Tuple_u32TxOutZ_new(uint32_t a, struct LDKTxOut b); +void ClosureReason_free(struct LDKClosureReason this_ptr); /** - * Frees any resources used by the C2Tuple_u32TxOutZ. + * Creates a copy of the ClosureReason */ -void C2Tuple_u32TxOutZ_free(struct LDKC2Tuple_u32TxOutZ _res); +struct LDKClosureReason ClosureReason_clone(const struct LDKClosureReason *NONNULL_PTR orig); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Utility method to constructs a new CounterpartyForceClosed-variant ClosureReason */ -void CVec_C2Tuple_u32TxOutZZ_free(struct LDKCVec_C2Tuple_u32TxOutZZ _res); +struct LDKClosureReason ClosureReason_counterparty_force_closed(struct LDKStr peer_msg); /** - * Creates a new tuple which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Utility method to constructs a new HolderForceClosed-variant ClosureReason */ -struct LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(const struct LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR orig); +struct LDKClosureReason ClosureReason_holder_force_closed(void); /** - * Creates a new C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ from the contained elements. + * Utility method to constructs a new CooperativeClosure-variant ClosureReason */ -struct LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(struct LDKThirtyTwoBytes a, struct LDKCVec_C2Tuple_u32TxOutZZ b); +struct LDKClosureReason ClosureReason_cooperative_closure(void); /** - * Frees any resources used by the C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ. + * Utility method to constructs a new CommitmentTxConfirmed-variant ClosureReason */ -void C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(struct LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res); +struct LDKClosureReason ClosureReason_commitment_tx_confirmed(void); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Utility method to constructs a new FundingTimedOut-variant ClosureReason */ -void CVec_TransactionOutputsZ_free(struct LDKCVec_TransactionOutputsZ _res); +struct LDKClosureReason ClosureReason_funding_timed_out(void); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Utility method to constructs a new ProcessingError-variant ClosureReason */ -void CVec_BalanceZ_free(struct LDKCVec_BalanceZ _res); +struct LDKClosureReason ClosureReason_processing_error(struct LDKStr err); /** - * Creates a new CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ in the success state. + * Utility method to constructs a new DisconnectedPeer-variant ClosureReason */ -struct LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(struct LDKC2Tuple_BlockHashChannelMonitorZ o); +struct LDKClosureReason ClosureReason_disconnected_peer(void); /** - * Creates a new CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ in the error state. + * Utility method to constructs a new OutdatedChannelManager-variant ClosureReason */ -struct LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKClosureReason ClosureReason_outdated_channel_manager(void); /** - * Checks if the given object is currently in the success state + * Checks if two ClosureReasons contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -bool CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok(const struct LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR o); +bool ClosureReason_eq(const struct LDKClosureReason *NONNULL_PTR a, const struct LDKClosureReason *NONNULL_PTR b); /** - * Frees any resources used by the CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ. + * Serialize the ClosureReason object into a byte array which can be read by ClosureReason_read */ -void CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(struct LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res); +struct LDKCVec_u8Z ClosureReason_write(const struct LDKClosureReason *NONNULL_PTR obj); /** - * Creates a new CResult_NoneLightningErrorZ in the success state. + * Read a ClosureReason from a byte array, created by ClosureReason_write */ -struct LDKCResult_NoneLightningErrorZ CResult_NoneLightningErrorZ_ok(void); +struct LDKCResult_COption_ClosureReasonZDecodeErrorZ ClosureReason_read(struct LDKu8slice ser); /** - * Creates a new CResult_NoneLightningErrorZ in the error state. + * Frees any resources used by the HTLCDestination */ -struct LDKCResult_NoneLightningErrorZ CResult_NoneLightningErrorZ_err(struct LDKLightningError e); +void HTLCDestination_free(struct LDKHTLCDestination this_ptr); /** - * Checks if the given object is currently in the success state + * Creates a copy of the HTLCDestination */ -bool CResult_NoneLightningErrorZ_is_ok(const struct LDKCResult_NoneLightningErrorZ *NONNULL_PTR o); +struct LDKHTLCDestination HTLCDestination_clone(const struct LDKHTLCDestination *NONNULL_PTR orig); /** - * Frees any resources used by the CResult_NoneLightningErrorZ. + * Utility method to constructs a new NextHopChannel-variant HTLCDestination */ -void CResult_NoneLightningErrorZ_free(struct LDKCResult_NoneLightningErrorZ _res); +struct LDKHTLCDestination HTLCDestination_next_hop_channel(struct LDKPublicKey node_id, struct LDKThirtyTwoBytes channel_id); /** - * Creates a new CResult_NoneLightningErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Utility method to constructs a new UnknownNextHop-variant HTLCDestination */ -struct LDKCResult_NoneLightningErrorZ CResult_NoneLightningErrorZ_clone(const struct LDKCResult_NoneLightningErrorZ *NONNULL_PTR orig); +struct LDKHTLCDestination HTLCDestination_unknown_next_hop(uint64_t requested_forward_scid); /** - * Creates a new C2Tuple_PublicKeyTypeZ from the contained elements. + * Utility method to constructs a new FailedPayment-variant HTLCDestination */ -struct LDKC2Tuple_PublicKeyTypeZ C2Tuple_PublicKeyTypeZ_new(struct LDKPublicKey a, struct LDKType b); +struct LDKHTLCDestination HTLCDestination_failed_payment(struct LDKThirtyTwoBytes payment_hash); /** - * Frees any resources used by the C2Tuple_PublicKeyTypeZ. + * Checks if two HTLCDestinations contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -void C2Tuple_PublicKeyTypeZ_free(struct LDKC2Tuple_PublicKeyTypeZ _res); +bool HTLCDestination_eq(const struct LDKHTLCDestination *NONNULL_PTR a, const struct LDKHTLCDestination *NONNULL_PTR b); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Serialize the HTLCDestination object into a byte array which can be read by HTLCDestination_read */ -void CVec_C2Tuple_PublicKeyTypeZZ_free(struct LDKCVec_C2Tuple_PublicKeyTypeZZ _res); +struct LDKCVec_u8Z HTLCDestination_write(const struct LDKHTLCDestination *NONNULL_PTR obj); /** - * Creates a new CResult_boolLightningErrorZ in the success state. + * Read a HTLCDestination from a byte array, created by HTLCDestination_write */ -struct LDKCResult_boolLightningErrorZ CResult_boolLightningErrorZ_ok(bool o); +struct LDKCResult_COption_HTLCDestinationZDecodeErrorZ HTLCDestination_read(struct LDKu8slice ser); /** - * Creates a new CResult_boolLightningErrorZ in the error state. + * Frees any resources used by the Event */ -struct LDKCResult_boolLightningErrorZ CResult_boolLightningErrorZ_err(struct LDKLightningError e); +void Event_free(struct LDKEvent this_ptr); /** - * Checks if the given object is currently in the success state + * Creates a copy of the Event */ -bool CResult_boolLightningErrorZ_is_ok(const struct LDKCResult_boolLightningErrorZ *NONNULL_PTR o); +struct LDKEvent Event_clone(const struct LDKEvent *NONNULL_PTR orig); /** - * Frees any resources used by the CResult_boolLightningErrorZ. + * Utility method to constructs a new FundingGenerationReady-variant Event */ -void CResult_boolLightningErrorZ_free(struct LDKCResult_boolLightningErrorZ _res); +struct LDKEvent Event_funding_generation_ready(struct LDKThirtyTwoBytes temporary_channel_id, struct LDKPublicKey counterparty_node_id, uint64_t channel_value_satoshis, struct LDKCVec_u8Z output_script, uint64_t user_channel_id); /** - * Creates a new CResult_boolLightningErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Utility method to constructs a new PaymentReceived-variant Event */ -struct LDKCResult_boolLightningErrorZ CResult_boolLightningErrorZ_clone(const struct LDKCResult_boolLightningErrorZ *NONNULL_PTR orig); +struct LDKEvent Event_payment_received(struct LDKThirtyTwoBytes payment_hash, uint64_t amount_msat, struct LDKPaymentPurpose purpose); /** - * Creates a new tuple which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Utility method to constructs a new PaymentClaimed-variant Event */ -struct LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(const struct LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR orig); +struct LDKEvent Event_payment_claimed(struct LDKThirtyTwoBytes payment_hash, uint64_t amount_msat, struct LDKPaymentPurpose purpose); /** - * Creates a new C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ from the contained elements. + * Utility method to constructs a new PaymentSent-variant Event */ -struct LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(struct LDKChannelAnnouncement a, struct LDKChannelUpdate b, struct LDKChannelUpdate c); +struct LDKEvent Event_payment_sent(struct LDKThirtyTwoBytes payment_id, struct LDKThirtyTwoBytes payment_preimage, struct LDKThirtyTwoBytes payment_hash, struct LDKCOption_u64Z fee_paid_msat); /** - * Frees any resources used by the C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ. + * Utility method to constructs a new PaymentFailed-variant Event */ -void C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(struct LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res); +struct LDKEvent Event_payment_failed(struct LDKThirtyTwoBytes payment_id, struct LDKThirtyTwoBytes payment_hash); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Utility method to constructs a new PaymentPathSuccessful-variant Event */ -void CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(struct LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res); +struct LDKEvent Event_payment_path_successful(struct LDKThirtyTwoBytes payment_id, struct LDKThirtyTwoBytes payment_hash, struct LDKCVec_RouteHopZ path); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Utility method to constructs a new PaymentPathFailed-variant Event */ -void CVec_NodeAnnouncementZ_free(struct LDKCVec_NodeAnnouncementZ _res); +struct LDKEvent Event_payment_path_failed(struct LDKThirtyTwoBytes payment_id, struct LDKThirtyTwoBytes payment_hash, bool payment_failed_permanently, struct LDKCOption_NetworkUpdateZ network_update, bool all_paths_failed, struct LDKCVec_RouteHopZ path, struct LDKCOption_u64Z short_channel_id, struct LDKRouteParameters retry); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Utility method to constructs a new ProbeSuccessful-variant Event */ -void CVec_PublicKeyZ_free(struct LDKCVec_PublicKeyZ _res); +struct LDKEvent Event_probe_successful(struct LDKThirtyTwoBytes payment_id, struct LDKThirtyTwoBytes payment_hash, struct LDKCVec_RouteHopZ path); /** - * Creates a new CResult_CVec_u8ZPeerHandleErrorZ in the success state. + * Utility method to constructs a new ProbeFailed-variant Event */ -struct LDKCResult_CVec_u8ZPeerHandleErrorZ CResult_CVec_u8ZPeerHandleErrorZ_ok(struct LDKCVec_u8Z o); +struct LDKEvent Event_probe_failed(struct LDKThirtyTwoBytes payment_id, struct LDKThirtyTwoBytes payment_hash, struct LDKCVec_RouteHopZ path, struct LDKCOption_u64Z short_channel_id); /** - * Creates a new CResult_CVec_u8ZPeerHandleErrorZ in the error state. + * Utility method to constructs a new PendingHTLCsForwardable-variant Event */ -struct LDKCResult_CVec_u8ZPeerHandleErrorZ CResult_CVec_u8ZPeerHandleErrorZ_err(struct LDKPeerHandleError e); +struct LDKEvent Event_pending_htlcs_forwardable(uint64_t time_forwardable); /** - * Checks if the given object is currently in the success state + * Utility method to constructs a new SpendableOutputs-variant Event */ -bool CResult_CVec_u8ZPeerHandleErrorZ_is_ok(const struct LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR o); +struct LDKEvent Event_spendable_outputs(struct LDKCVec_SpendableOutputDescriptorZ outputs); /** - * Frees any resources used by the CResult_CVec_u8ZPeerHandleErrorZ. + * Utility method to constructs a new PaymentForwarded-variant Event */ -void CResult_CVec_u8ZPeerHandleErrorZ_free(struct LDKCResult_CVec_u8ZPeerHandleErrorZ _res); +struct LDKEvent Event_payment_forwarded(struct LDKThirtyTwoBytes prev_channel_id, struct LDKThirtyTwoBytes next_channel_id, struct LDKCOption_u64Z fee_earned_msat, bool claim_from_onchain_tx); /** - * Creates a new CResult_CVec_u8ZPeerHandleErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Utility method to constructs a new ChannelClosed-variant Event */ -struct LDKCResult_CVec_u8ZPeerHandleErrorZ CResult_CVec_u8ZPeerHandleErrorZ_clone(const struct LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR orig); +struct LDKEvent Event_channel_closed(struct LDKThirtyTwoBytes channel_id, uint64_t user_channel_id, struct LDKClosureReason reason); /** - * Creates a new CResult_NonePeerHandleErrorZ in the success state. + * Utility method to constructs a new DiscardFunding-variant Event */ -struct LDKCResult_NonePeerHandleErrorZ CResult_NonePeerHandleErrorZ_ok(void); +struct LDKEvent Event_discard_funding(struct LDKThirtyTwoBytes channel_id, struct LDKTransaction transaction); /** - * Creates a new CResult_NonePeerHandleErrorZ in the error state. + * Utility method to constructs a new OpenChannelRequest-variant Event */ -struct LDKCResult_NonePeerHandleErrorZ CResult_NonePeerHandleErrorZ_err(struct LDKPeerHandleError e); +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); /** - * Checks if the given object is currently in the success state + * Utility method to constructs a new HTLCHandlingFailed-variant Event */ -bool CResult_NonePeerHandleErrorZ_is_ok(const struct LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR o); +struct LDKEvent Event_htlchandling_failed(struct LDKThirtyTwoBytes prev_channel_id, struct LDKHTLCDestination failed_next_destination); /** - * Frees any resources used by the CResult_NonePeerHandleErrorZ. + * Serialize the Event object into a byte array which can be read by Event_read */ -void CResult_NonePeerHandleErrorZ_free(struct LDKCResult_NonePeerHandleErrorZ _res); +struct LDKCVec_u8Z Event_write(const struct LDKEvent *NONNULL_PTR obj); /** - * Creates a new CResult_NonePeerHandleErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Read a Event from a byte array, created by Event_write */ -struct LDKCResult_NonePeerHandleErrorZ CResult_NonePeerHandleErrorZ_clone(const struct LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR orig); +struct LDKCResult_COption_EventZDecodeErrorZ Event_read(struct LDKu8slice ser); /** - * Creates a new CResult_boolPeerHandleErrorZ in the success state. + * Frees any resources used by the MessageSendEvent */ -struct LDKCResult_boolPeerHandleErrorZ CResult_boolPeerHandleErrorZ_ok(bool o); +void MessageSendEvent_free(struct LDKMessageSendEvent this_ptr); /** - * Creates a new CResult_boolPeerHandleErrorZ in the error state. + * Creates a copy of the MessageSendEvent */ -struct LDKCResult_boolPeerHandleErrorZ CResult_boolPeerHandleErrorZ_err(struct LDKPeerHandleError e); +struct LDKMessageSendEvent MessageSendEvent_clone(const struct LDKMessageSendEvent *NONNULL_PTR orig); /** - * Checks if the given object is currently in the success state + * Utility method to constructs a new SendAcceptChannel-variant MessageSendEvent */ -bool CResult_boolPeerHandleErrorZ_is_ok(const struct LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR o); +struct LDKMessageSendEvent MessageSendEvent_send_accept_channel(struct LDKPublicKey node_id, struct LDKAcceptChannel msg); /** - * Frees any resources used by the CResult_boolPeerHandleErrorZ. + * Utility method to constructs a new SendOpenChannel-variant MessageSendEvent */ -void CResult_boolPeerHandleErrorZ_free(struct LDKCResult_boolPeerHandleErrorZ _res); +struct LDKMessageSendEvent MessageSendEvent_send_open_channel(struct LDKPublicKey node_id, struct LDKOpenChannel msg); /** - * Creates a new CResult_boolPeerHandleErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Utility method to constructs a new SendFundingCreated-variant MessageSendEvent */ -struct LDKCResult_boolPeerHandleErrorZ CResult_boolPeerHandleErrorZ_clone(const struct LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR orig); +struct LDKMessageSendEvent MessageSendEvent_send_funding_created(struct LDKPublicKey node_id, struct LDKFundingCreated msg); /** - * Creates a new CResult_NodeIdDecodeErrorZ in the success state. + * Utility method to constructs a new SendFundingSigned-variant MessageSendEvent */ -struct LDKCResult_NodeIdDecodeErrorZ CResult_NodeIdDecodeErrorZ_ok(struct LDKNodeId o); +struct LDKMessageSendEvent MessageSendEvent_send_funding_signed(struct LDKPublicKey node_id, struct LDKFundingSigned msg); /** - * Creates a new CResult_NodeIdDecodeErrorZ in the error state. + * Utility method to constructs a new SendChannelReady-variant MessageSendEvent */ -struct LDKCResult_NodeIdDecodeErrorZ CResult_NodeIdDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKMessageSendEvent MessageSendEvent_send_channel_ready(struct LDKPublicKey node_id, struct LDKChannelReady msg); /** - * Checks if the given object is currently in the success state + * Utility method to constructs a new SendAnnouncementSignatures-variant MessageSendEvent */ -bool CResult_NodeIdDecodeErrorZ_is_ok(const struct LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR o); +struct LDKMessageSendEvent MessageSendEvent_send_announcement_signatures(struct LDKPublicKey node_id, struct LDKAnnouncementSignatures msg); /** - * Frees any resources used by the CResult_NodeIdDecodeErrorZ. + * Utility method to constructs a new UpdateHTLCs-variant MessageSendEvent */ -void CResult_NodeIdDecodeErrorZ_free(struct LDKCResult_NodeIdDecodeErrorZ _res); +struct LDKMessageSendEvent MessageSendEvent_update_htlcs(struct LDKPublicKey node_id, struct LDKCommitmentUpdate updates); /** - * Creates a new CResult_NodeIdDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Utility method to constructs a new SendRevokeAndACK-variant MessageSendEvent */ -struct LDKCResult_NodeIdDecodeErrorZ CResult_NodeIdDecodeErrorZ_clone(const struct LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR orig); +struct LDKMessageSendEvent MessageSendEvent_send_revoke_and_ack(struct LDKPublicKey node_id, struct LDKRevokeAndACK msg); /** - * Creates a new CResult_COption_NetworkUpdateZDecodeErrorZ in the success state. + * Utility method to constructs a new SendClosingSigned-variant MessageSendEvent */ -struct LDKCResult_COption_NetworkUpdateZDecodeErrorZ CResult_COption_NetworkUpdateZDecodeErrorZ_ok(struct LDKCOption_NetworkUpdateZ o); +struct LDKMessageSendEvent MessageSendEvent_send_closing_signed(struct LDKPublicKey node_id, struct LDKClosingSigned msg); /** - * Creates a new CResult_COption_NetworkUpdateZDecodeErrorZ in the error state. + * Utility method to constructs a new SendShutdown-variant MessageSendEvent */ -struct LDKCResult_COption_NetworkUpdateZDecodeErrorZ CResult_COption_NetworkUpdateZDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKMessageSendEvent MessageSendEvent_send_shutdown(struct LDKPublicKey node_id, struct LDKShutdown msg); /** - * Checks if the given object is currently in the success state + * Utility method to constructs a new SendChannelReestablish-variant MessageSendEvent */ -bool CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok(const struct LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR o); +struct LDKMessageSendEvent MessageSendEvent_send_channel_reestablish(struct LDKPublicKey node_id, struct LDKChannelReestablish msg); /** - * Frees any resources used by the CResult_COption_NetworkUpdateZDecodeErrorZ. + * Utility method to constructs a new SendChannelAnnouncement-variant MessageSendEvent */ -void CResult_COption_NetworkUpdateZDecodeErrorZ_free(struct LDKCResult_COption_NetworkUpdateZDecodeErrorZ _res); +struct LDKMessageSendEvent MessageSendEvent_send_channel_announcement(struct LDKPublicKey node_id, struct LDKChannelAnnouncement msg, struct LDKChannelUpdate update_msg); /** - * Creates a new CResult_COption_NetworkUpdateZDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Utility method to constructs a new BroadcastChannelAnnouncement-variant MessageSendEvent */ -struct LDKCResult_COption_NetworkUpdateZDecodeErrorZ CResult_COption_NetworkUpdateZDecodeErrorZ_clone(const struct LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR orig); +struct LDKMessageSendEvent MessageSendEvent_broadcast_channel_announcement(struct LDKChannelAnnouncement msg, struct LDKChannelUpdate update_msg); /** - * Constructs a new COption_AccessZ containing a crate::lightning::chain::Access + * Utility method to constructs a new BroadcastChannelUpdate-variant MessageSendEvent */ -struct LDKCOption_AccessZ COption_AccessZ_some(struct LDKAccess o); +struct LDKMessageSendEvent MessageSendEvent_broadcast_channel_update(struct LDKChannelUpdate msg); /** - * Constructs a new COption_AccessZ containing nothing + * Utility method to constructs a new SendChannelUpdate-variant MessageSendEvent */ -struct LDKCOption_AccessZ COption_AccessZ_none(void); +struct LDKMessageSendEvent MessageSendEvent_send_channel_update(struct LDKPublicKey node_id, struct LDKChannelUpdate msg); /** - * Frees any resources associated with the crate::lightning::chain::Access, if we are in the Some state + * Utility method to constructs a new HandleError-variant MessageSendEvent */ -void COption_AccessZ_free(struct LDKCOption_AccessZ _res); +struct LDKMessageSendEvent MessageSendEvent_handle_error(struct LDKPublicKey node_id, struct LDKErrorAction action); /** - * Creates a new CResult_ChannelUpdateInfoDecodeErrorZ in the success state. + * Utility method to constructs a new SendChannelRangeQuery-variant MessageSendEvent */ -struct LDKCResult_ChannelUpdateInfoDecodeErrorZ CResult_ChannelUpdateInfoDecodeErrorZ_ok(struct LDKChannelUpdateInfo o); +struct LDKMessageSendEvent MessageSendEvent_send_channel_range_query(struct LDKPublicKey node_id, struct LDKQueryChannelRange msg); /** - * Creates a new CResult_ChannelUpdateInfoDecodeErrorZ in the error state. + * Utility method to constructs a new SendShortIdsQuery-variant MessageSendEvent */ -struct LDKCResult_ChannelUpdateInfoDecodeErrorZ CResult_ChannelUpdateInfoDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKMessageSendEvent MessageSendEvent_send_short_ids_query(struct LDKPublicKey node_id, struct LDKQueryShortChannelIds msg); /** - * Checks if the given object is currently in the success state + * Utility method to constructs a new SendReplyChannelRange-variant MessageSendEvent */ -bool CResult_ChannelUpdateInfoDecodeErrorZ_is_ok(const struct LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR o); +struct LDKMessageSendEvent MessageSendEvent_send_reply_channel_range(struct LDKPublicKey node_id, struct LDKReplyChannelRange msg); /** - * Frees any resources used by the CResult_ChannelUpdateInfoDecodeErrorZ. + * Utility method to constructs a new SendGossipTimestampFilter-variant MessageSendEvent */ -void CResult_ChannelUpdateInfoDecodeErrorZ_free(struct LDKCResult_ChannelUpdateInfoDecodeErrorZ _res); +struct LDKMessageSendEvent MessageSendEvent_send_gossip_timestamp_filter(struct LDKPublicKey node_id, struct LDKGossipTimestampFilter msg); /** - * Creates a new CResult_ChannelUpdateInfoDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Calls the free function if one is set */ -struct LDKCResult_ChannelUpdateInfoDecodeErrorZ CResult_ChannelUpdateInfoDecodeErrorZ_clone(const struct LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR orig); +void MessageSendEventsProvider_free(struct LDKMessageSendEventsProvider this_ptr); /** - * Creates a new CResult_ChannelInfoDecodeErrorZ in the success state. + * Calls the free function if one is set */ -struct LDKCResult_ChannelInfoDecodeErrorZ CResult_ChannelInfoDecodeErrorZ_ok(struct LDKChannelInfo o); +void OnionMessageProvider_free(struct LDKOnionMessageProvider this_ptr); /** - * Creates a new CResult_ChannelInfoDecodeErrorZ in the error state. + * Calls the free function if one is set */ -struct LDKCResult_ChannelInfoDecodeErrorZ CResult_ChannelInfoDecodeErrorZ_err(struct LDKDecodeError e); +void EventsProvider_free(struct LDKEventsProvider this_ptr); /** - * Checks if the given object is currently in the success state + * Calls the free function if one is set */ -bool CResult_ChannelInfoDecodeErrorZ_is_ok(const struct LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR o); +void EventHandler_free(struct LDKEventHandler this_ptr); /** - * Frees any resources used by the CResult_ChannelInfoDecodeErrorZ. + * Frees any resources used by the APIError */ -void CResult_ChannelInfoDecodeErrorZ_free(struct LDKCResult_ChannelInfoDecodeErrorZ _res); +void APIError_free(struct LDKAPIError this_ptr); /** - * Creates a new CResult_ChannelInfoDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Creates a copy of the APIError */ -struct LDKCResult_ChannelInfoDecodeErrorZ CResult_ChannelInfoDecodeErrorZ_clone(const struct LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR orig); +struct LDKAPIError APIError_clone(const struct LDKAPIError *NONNULL_PTR orig); /** - * Creates a new CResult_RoutingFeesDecodeErrorZ in the success state. + * Utility method to constructs a new APIMisuseError-variant APIError */ -struct LDKCResult_RoutingFeesDecodeErrorZ CResult_RoutingFeesDecodeErrorZ_ok(struct LDKRoutingFees o); +struct LDKAPIError APIError_apimisuse_error(struct LDKStr err); /** - * Creates a new CResult_RoutingFeesDecodeErrorZ in the error state. + * Utility method to constructs a new FeeRateTooHigh-variant APIError */ -struct LDKCResult_RoutingFeesDecodeErrorZ CResult_RoutingFeesDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKAPIError APIError_fee_rate_too_high(struct LDKStr err, uint32_t feerate); /** - * Checks if the given object is currently in the success state + * Utility method to constructs a new RouteError-variant APIError */ -bool CResult_RoutingFeesDecodeErrorZ_is_ok(const struct LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR o); +struct LDKAPIError APIError_route_error(struct LDKStr err); /** - * Frees any resources used by the CResult_RoutingFeesDecodeErrorZ. + * Utility method to constructs a new ChannelUnavailable-variant APIError */ -void CResult_RoutingFeesDecodeErrorZ_free(struct LDKCResult_RoutingFeesDecodeErrorZ _res); +struct LDKAPIError APIError_channel_unavailable(struct LDKStr err); /** - * Creates a new CResult_RoutingFeesDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Utility method to constructs a new MonitorUpdateInProgress-variant APIError */ -struct LDKCResult_RoutingFeesDecodeErrorZ CResult_RoutingFeesDecodeErrorZ_clone(const struct LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR orig); +struct LDKAPIError APIError_monitor_update_in_progress(void); /** - * Creates a new CResult_NodeAnnouncementInfoDecodeErrorZ in the success state. + * Utility method to constructs a new IncompatibleShutdownScript-variant APIError */ -struct LDKCResult_NodeAnnouncementInfoDecodeErrorZ CResult_NodeAnnouncementInfoDecodeErrorZ_ok(struct LDKNodeAnnouncementInfo o); +struct LDKAPIError APIError_incompatible_shutdown_script(struct LDKShutdownScript script); /** - * Creates a new CResult_NodeAnnouncementInfoDecodeErrorZ in the error state. + * Checks if two APIErrors contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -struct LDKCResult_NodeAnnouncementInfoDecodeErrorZ CResult_NodeAnnouncementInfoDecodeErrorZ_err(struct LDKDecodeError e); +bool APIError_eq(const struct LDKAPIError *NONNULL_PTR a, const struct LDKAPIError *NONNULL_PTR b); /** - * Checks if the given object is currently in the success state + * Frees any resources used by the BigSize, if is_owned is set and inner is non-NULL. */ -bool CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok(const struct LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR o); +void BigSize_free(struct LDKBigSize this_obj); + +uint64_t BigSize_get_a(const struct LDKBigSize *NONNULL_PTR this_ptr); + +void BigSize_set_a(struct LDKBigSize *NONNULL_PTR this_ptr, uint64_t val); /** - * Frees any resources used by the CResult_NodeAnnouncementInfoDecodeErrorZ. + * Constructs a new BigSize given each field */ -void CResult_NodeAnnouncementInfoDecodeErrorZ_free(struct LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res); +MUST_USE_RES struct LDKBigSize BigSize_new(uint64_t a_arg); /** - * Creates a new CResult_NodeAnnouncementInfoDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Frees any resources used by the Hostname, if is_owned is set and inner is non-NULL. */ -struct LDKCResult_NodeAnnouncementInfoDecodeErrorZ CResult_NodeAnnouncementInfoDecodeErrorZ_clone(const struct LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR orig); +void Hostname_free(struct LDKHostname this_obj); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Creates a copy of the Hostname */ -void CVec_u64Z_free(struct LDKCVec_u64Z _res); +struct LDKHostname Hostname_clone(const struct LDKHostname *NONNULL_PTR orig); /** - * Creates a new CResult_NodeInfoDecodeErrorZ in the success state. + * Checks if two Hostnames contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -struct LDKCResult_NodeInfoDecodeErrorZ CResult_NodeInfoDecodeErrorZ_ok(struct LDKNodeInfo o); +bool Hostname_eq(const struct LDKHostname *NONNULL_PTR a, const struct LDKHostname *NONNULL_PTR b); /** - * Creates a new CResult_NodeInfoDecodeErrorZ in the error state. + * Returns the length of the hostname. */ -struct LDKCResult_NodeInfoDecodeErrorZ CResult_NodeInfoDecodeErrorZ_err(struct LDKDecodeError e); +MUST_USE_RES uint8_t Hostname_len(const struct LDKHostname *NONNULL_PTR this_arg); /** - * Checks if the given object is currently in the success state + * Creates a digital signature of a message given a SecretKey, like the node's secret. + * A receiver knowing the PublicKey (e.g. the node's id) and the message can be sure that the signature was generated by the caller. + * Signatures are EC recoverable, meaning that given the message and the signature the PublicKey of the signer can be extracted. */ -bool CResult_NodeInfoDecodeErrorZ_is_ok(const struct LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR o); +struct LDKCResult_StringErrorZ sign(struct LDKu8slice msg, const uint8_t (*sk)[32]); /** - * Frees any resources used by the CResult_NodeInfoDecodeErrorZ. + * Recovers the PublicKey of the signer of the message given the message and the signature. */ -void CResult_NodeInfoDecodeErrorZ_free(struct LDKCResult_NodeInfoDecodeErrorZ _res); +struct LDKCResult_PublicKeyErrorZ recover_pk(struct LDKu8slice msg, struct LDKStr sig); /** - * Creates a new CResult_NodeInfoDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Verifies a message was signed by a PrivateKey that derives to a given PublicKey, given a message, a signature, + * and the PublicKey. */ -struct LDKCResult_NodeInfoDecodeErrorZ CResult_NodeInfoDecodeErrorZ_clone(const struct LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR orig); +bool verify(struct LDKu8slice msg, struct LDKStr sig, struct LDKPublicKey pk); /** - * Creates a new CResult_NetworkGraphDecodeErrorZ in the success state. + * Construct the invoice's HRP and signatureless data into a preimage to be hashed. */ -struct LDKCResult_NetworkGraphDecodeErrorZ CResult_NetworkGraphDecodeErrorZ_ok(struct LDKNetworkGraph o); +struct LDKCVec_u8Z construct_invoice_preimage(struct LDKu8slice hrp_bytes, struct LDKCVec_u5Z data_without_signature); /** - * Creates a new CResult_NetworkGraphDecodeErrorZ in the error state. + * Calls the free function if one is set */ -struct LDKCResult_NetworkGraphDecodeErrorZ CResult_NetworkGraphDecodeErrorZ_err(struct LDKDecodeError e); +void Persister_free(struct LDKPersister this_ptr); /** - * Checks if the given object is currently in the success state + * Calls the free function if one is set */ -bool CResult_NetworkGraphDecodeErrorZ_is_ok(const struct LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR o); +void FutureCallback_free(struct LDKFutureCallback this_ptr); /** - * Frees any resources used by the CResult_NetworkGraphDecodeErrorZ. + * Frees any resources used by the Future, if is_owned is set and inner is non-NULL. */ -void CResult_NetworkGraphDecodeErrorZ_free(struct LDKCResult_NetworkGraphDecodeErrorZ _res); +void Future_free(struct LDKFuture this_obj); /** - * Creates a new CResult_NetworkGraphDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Registers a callback to be called upon completion of this future. If the future has already + * completed, the callback will be called immediately. */ -struct LDKCResult_NetworkGraphDecodeErrorZ CResult_NetworkGraphDecodeErrorZ_clone(const struct LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR orig); +void Future_register_callback_fn(const struct LDKFuture *NONNULL_PTR this_arg, struct LDKFutureCallback callback); /** - * Constructs a new COption_CVec_NetAddressZZ containing a crate::c_types::derived::CVec_NetAddressZ + * Creates a copy of the Level */ -struct LDKCOption_CVec_NetAddressZZ COption_CVec_NetAddressZZ_some(struct LDKCVec_NetAddressZ o); +enum LDKLevel Level_clone(const enum LDKLevel *NONNULL_PTR orig); /** - * Constructs a new COption_CVec_NetAddressZZ containing nothing + * Utility method to constructs a new Gossip-variant Level */ -struct LDKCOption_CVec_NetAddressZZ COption_CVec_NetAddressZZ_none(void); +enum LDKLevel Level_gossip(void); /** - * Frees any resources associated with the crate::c_types::derived::CVec_NetAddressZ, if we are in the Some state + * Utility method to constructs a new Trace-variant Level */ -void COption_CVec_NetAddressZZ_free(struct LDKCOption_CVec_NetAddressZZ _res); +enum LDKLevel Level_trace(void); /** - * Creates a new COption_CVec_NetAddressZZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Utility method to constructs a new Debug-variant Level */ -struct LDKCOption_CVec_NetAddressZZ COption_CVec_NetAddressZZ_clone(const struct LDKCOption_CVec_NetAddressZZ *NONNULL_PTR orig); +enum LDKLevel Level_debug(void); /** - * Creates a new CResult_NetAddressDecodeErrorZ in the success state. + * Utility method to constructs a new Info-variant Level */ -struct LDKCResult_NetAddressDecodeErrorZ CResult_NetAddressDecodeErrorZ_ok(struct LDKNetAddress o); +enum LDKLevel Level_info(void); /** - * Creates a new CResult_NetAddressDecodeErrorZ in the error state. + * Utility method to constructs a new Warn-variant Level */ -struct LDKCResult_NetAddressDecodeErrorZ CResult_NetAddressDecodeErrorZ_err(struct LDKDecodeError e); +enum LDKLevel Level_warn(void); /** - * Checks if the given object is currently in the success state + * Utility method to constructs a new Error-variant Level */ -bool CResult_NetAddressDecodeErrorZ_is_ok(const struct LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR o); +enum LDKLevel Level_error(void); /** - * Frees any resources used by the CResult_NetAddressDecodeErrorZ. + * Checks if two Levels contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -void CResult_NetAddressDecodeErrorZ_free(struct LDKCResult_NetAddressDecodeErrorZ _res); +bool Level_eq(const enum LDKLevel *NONNULL_PTR a, const enum LDKLevel *NONNULL_PTR b); /** - * Creates a new CResult_NetAddressDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Checks if two Levels contain equal inner contents. */ -struct LDKCResult_NetAddressDecodeErrorZ CResult_NetAddressDecodeErrorZ_clone(const struct LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR orig); +uint64_t Level_hash(const enum LDKLevel *NONNULL_PTR o); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Returns the most verbose logging level. */ -void CVec_UpdateAddHTLCZ_free(struct LDKCVec_UpdateAddHTLCZ _res); +MUST_USE_RES enum LDKLevel Level_max(void); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Frees any resources used by the Record, if is_owned is set and inner is non-NULL. */ -void CVec_UpdateFulfillHTLCZ_free(struct LDKCVec_UpdateFulfillHTLCZ _res); +void Record_free(struct LDKRecord this_obj); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * The verbosity level of the message. */ -void CVec_UpdateFailHTLCZ_free(struct LDKCVec_UpdateFailHTLCZ _res); +enum LDKLevel Record_get_level(const struct LDKRecord *NONNULL_PTR this_ptr); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * The verbosity level of the message. */ -void CVec_UpdateFailMalformedHTLCZ_free(struct LDKCVec_UpdateFailMalformedHTLCZ _res); +void Record_set_level(struct LDKRecord *NONNULL_PTR this_ptr, enum LDKLevel val); /** - * Creates a new CResult_AcceptChannelDecodeErrorZ in the success state. + * The message body. */ -struct LDKCResult_AcceptChannelDecodeErrorZ CResult_AcceptChannelDecodeErrorZ_ok(struct LDKAcceptChannel o); +struct LDKStr Record_get_args(const struct LDKRecord *NONNULL_PTR this_ptr); /** - * Creates a new CResult_AcceptChannelDecodeErrorZ in the error state. + * The message body. */ -struct LDKCResult_AcceptChannelDecodeErrorZ CResult_AcceptChannelDecodeErrorZ_err(struct LDKDecodeError e); +void Record_set_args(struct LDKRecord *NONNULL_PTR this_ptr, struct LDKStr val); /** - * Checks if the given object is currently in the success state + * The module path of the message. */ -bool CResult_AcceptChannelDecodeErrorZ_is_ok(const struct LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR o); +struct LDKStr Record_get_module_path(const struct LDKRecord *NONNULL_PTR this_ptr); /** - * Frees any resources used by the CResult_AcceptChannelDecodeErrorZ. + * The module path of the message. */ -void CResult_AcceptChannelDecodeErrorZ_free(struct LDKCResult_AcceptChannelDecodeErrorZ _res); +void Record_set_module_path(struct LDKRecord *NONNULL_PTR this_ptr, struct LDKStr val); /** - * Creates a new CResult_AcceptChannelDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * The source file containing the message. */ -struct LDKCResult_AcceptChannelDecodeErrorZ CResult_AcceptChannelDecodeErrorZ_clone(const struct LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR orig); +struct LDKStr Record_get_file(const struct LDKRecord *NONNULL_PTR this_ptr); /** - * Creates a new CResult_AnnouncementSignaturesDecodeErrorZ in the success state. + * The source file containing the message. */ -struct LDKCResult_AnnouncementSignaturesDecodeErrorZ CResult_AnnouncementSignaturesDecodeErrorZ_ok(struct LDKAnnouncementSignatures o); +void Record_set_file(struct LDKRecord *NONNULL_PTR this_ptr, struct LDKStr val); /** - * Creates a new CResult_AnnouncementSignaturesDecodeErrorZ in the error state. + * The line containing the message. */ -struct LDKCResult_AnnouncementSignaturesDecodeErrorZ CResult_AnnouncementSignaturesDecodeErrorZ_err(struct LDKDecodeError e); +uint32_t Record_get_line(const struct LDKRecord *NONNULL_PTR this_ptr); /** - * Checks if the given object is currently in the success state + * The line containing the message. */ -bool CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(const struct LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR o); +void Record_set_line(struct LDKRecord *NONNULL_PTR this_ptr, uint32_t val); /** - * Frees any resources used by the CResult_AnnouncementSignaturesDecodeErrorZ. + * Creates a copy of the Record */ -void CResult_AnnouncementSignaturesDecodeErrorZ_free(struct LDKCResult_AnnouncementSignaturesDecodeErrorZ _res); +struct LDKRecord Record_clone(const struct LDKRecord *NONNULL_PTR orig); /** - * Creates a new CResult_AnnouncementSignaturesDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Calls the free function if one is set */ -struct LDKCResult_AnnouncementSignaturesDecodeErrorZ CResult_AnnouncementSignaturesDecodeErrorZ_clone(const struct LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR orig); +void Logger_free(struct LDKLogger this_ptr); /** - * Creates a new CResult_ChannelReestablishDecodeErrorZ in the success state. + * Frees any resources used by the ChannelHandshakeConfig, if is_owned is set and inner is non-NULL. */ -struct LDKCResult_ChannelReestablishDecodeErrorZ CResult_ChannelReestablishDecodeErrorZ_ok(struct LDKChannelReestablish o); +void ChannelHandshakeConfig_free(struct LDKChannelHandshakeConfig this_obj); /** - * Creates a new CResult_ChannelReestablishDecodeErrorZ in the error state. + * Confirmations we will wait for before considering the channel locked in. + * Applied only for inbound channels (see ChannelHandshakeLimits::max_minimum_depth for the + * equivalent limit applied to outbound channels). + * + * A lower-bound of 1 is applied, requiring all channels to have a confirmed commitment + * transaction before operation. If you wish to accept channels with zero confirmations, see + * [`UserConfig::manually_accept_inbound_channels`] and + * [`ChannelManager::accept_inbound_channel_from_trusted_peer_0conf`]. + * + * Default value: 6. + * + * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel + * [`ChannelManager::accept_inbound_channel_from_trusted_peer_0conf`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel_from_trusted_peer_0conf */ -struct LDKCResult_ChannelReestablishDecodeErrorZ CResult_ChannelReestablishDecodeErrorZ_err(struct LDKDecodeError e); +uint32_t ChannelHandshakeConfig_get_minimum_depth(const struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr); /** - * Checks if the given object is currently in the success state + * Confirmations we will wait for before considering the channel locked in. + * Applied only for inbound channels (see ChannelHandshakeLimits::max_minimum_depth for the + * equivalent limit applied to outbound channels). + * + * A lower-bound of 1 is applied, requiring all channels to have a confirmed commitment + * transaction before operation. If you wish to accept channels with zero confirmations, see + * [`UserConfig::manually_accept_inbound_channels`] and + * [`ChannelManager::accept_inbound_channel_from_trusted_peer_0conf`]. + * + * Default value: 6. + * + * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel + * [`ChannelManager::accept_inbound_channel_from_trusted_peer_0conf`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel_from_trusted_peer_0conf */ -bool CResult_ChannelReestablishDecodeErrorZ_is_ok(const struct LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR o); +void ChannelHandshakeConfig_set_minimum_depth(struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr, uint32_t val); /** - * Frees any resources used by the CResult_ChannelReestablishDecodeErrorZ. + * Set to the number of blocks we require our counterparty to wait to claim their money (ie + * the number of blocks we have to punish our counterparty if they broadcast a revoked + * transaction). + * + * This is one of the main parameters of our security model. We (or one of our watchtowers) MUST + * be online to check for revoked transactions on-chain at least once every our_to_self_delay + * blocks (minus some margin to allow us enough time to broadcast and confirm a transaction, + * possibly with time in between to RBF the spending transaction). + * + * Meanwhile, asking for a too high delay, we bother peer to freeze funds for nothing in + * case of an honest unilateral channel close, which implicitly decrease the economic value of + * our channel. + * + * Default value: [`BREAKDOWN_TIMEOUT`], we enforce it as a minimum at channel opening so you + * can tweak config to ask for more security, not less. */ -void CResult_ChannelReestablishDecodeErrorZ_free(struct LDKCResult_ChannelReestablishDecodeErrorZ _res); +uint16_t ChannelHandshakeConfig_get_our_to_self_delay(const struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr); /** - * Creates a new CResult_ChannelReestablishDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Set to the number of blocks we require our counterparty to wait to claim their money (ie + * the number of blocks we have to punish our counterparty if they broadcast a revoked + * transaction). + * + * This is one of the main parameters of our security model. We (or one of our watchtowers) MUST + * be online to check for revoked transactions on-chain at least once every our_to_self_delay + * blocks (minus some margin to allow us enough time to broadcast and confirm a transaction, + * possibly with time in between to RBF the spending transaction). + * + * Meanwhile, asking for a too high delay, we bother peer to freeze funds for nothing in + * case of an honest unilateral channel close, which implicitly decrease the economic value of + * our channel. + * + * Default value: [`BREAKDOWN_TIMEOUT`], we enforce it as a minimum at channel opening so you + * can tweak config to ask for more security, not less. */ -struct LDKCResult_ChannelReestablishDecodeErrorZ CResult_ChannelReestablishDecodeErrorZ_clone(const struct LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR orig); +void ChannelHandshakeConfig_set_our_to_self_delay(struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr, uint16_t val); /** - * Creates a new CResult_ClosingSignedDecodeErrorZ in the success state. + * Set to the smallest value HTLC we will accept to process. + * + * This value is sent to our counterparty on channel-open and we close the channel any time + * our counterparty misbehaves by sending us an HTLC with a value smaller than this. + * + * Default value: 1. If the value is less than 1, it is ignored and set to 1, as is required + * by the protocol. */ -struct LDKCResult_ClosingSignedDecodeErrorZ CResult_ClosingSignedDecodeErrorZ_ok(struct LDKClosingSigned o); +uint64_t ChannelHandshakeConfig_get_our_htlc_minimum_msat(const struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr); /** - * Creates a new CResult_ClosingSignedDecodeErrorZ in the error state. + * Set to the smallest value HTLC we will accept to process. + * + * This value is sent to our counterparty on channel-open and we close the channel any time + * our counterparty misbehaves by sending us an HTLC with a value smaller than this. + * + * Default value: 1. If the value is less than 1, it is ignored and set to 1, as is required + * by the protocol. */ -struct LDKCResult_ClosingSignedDecodeErrorZ CResult_ClosingSignedDecodeErrorZ_err(struct LDKDecodeError e); +void ChannelHandshakeConfig_set_our_htlc_minimum_msat(struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr, uint64_t val); /** - * Checks if the given object is currently in the success state + * Sets the percentage of the channel value we will cap the total value of outstanding inbound + * HTLCs to. + * + * This can be set to a value between 1-100, where the value corresponds to the percent of the + * channel value in whole percentages. + * + * Note that: + * * If configured to another value than the default value 10, any new channels created with + * the non default value will cause versions of LDK prior to 0.0.104 to refuse to read the + * `ChannelManager`. + * + * * This caps the total value for inbound HTLCs in-flight only, and there's currently + * no way to configure the cap for the total value of outbound HTLCs in-flight. + * + * * The requirements for your node being online to ensure the safety of HTLC-encumbered funds + * are different from the non-HTLC-encumbered funds. This makes this an important knob to + * restrict exposure to loss due to being offline for too long. + * See [`ChannelHandshakeConfig::our_to_self_delay`] and [`ChannelConfig::cltv_expiry_delta`] + * for more information. + * + * Default value: 10. + * Minimum value: 1, any values less than 1 will be treated as 1 instead. + * Maximum value: 100, any values larger than 100 will be treated as 100 instead. */ -bool CResult_ClosingSignedDecodeErrorZ_is_ok(const struct LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR o); +uint8_t ChannelHandshakeConfig_get_max_inbound_htlc_value_in_flight_percent_of_channel(const struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr); /** - * Frees any resources used by the CResult_ClosingSignedDecodeErrorZ. + * Sets the percentage of the channel value we will cap the total value of outstanding inbound + * HTLCs to. + * + * This can be set to a value between 1-100, where the value corresponds to the percent of the + * channel value in whole percentages. + * + * Note that: + * * If configured to another value than the default value 10, any new channels created with + * the non default value will cause versions of LDK prior to 0.0.104 to refuse to read the + * `ChannelManager`. + * + * * This caps the total value for inbound HTLCs in-flight only, and there's currently + * no way to configure the cap for the total value of outbound HTLCs in-flight. + * + * * The requirements for your node being online to ensure the safety of HTLC-encumbered funds + * are different from the non-HTLC-encumbered funds. This makes this an important knob to + * restrict exposure to loss due to being offline for too long. + * See [`ChannelHandshakeConfig::our_to_self_delay`] and [`ChannelConfig::cltv_expiry_delta`] + * for more information. + * + * Default value: 10. + * Minimum value: 1, any values less than 1 will be treated as 1 instead. + * Maximum value: 100, any values larger than 100 will be treated as 100 instead. */ -void CResult_ClosingSignedDecodeErrorZ_free(struct LDKCResult_ClosingSignedDecodeErrorZ _res); +void ChannelHandshakeConfig_set_max_inbound_htlc_value_in_flight_percent_of_channel(struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr, uint8_t val); /** - * Creates a new CResult_ClosingSignedDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * 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 + * [`ChannelHandshakeConfig::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 */ -struct LDKCResult_ClosingSignedDecodeErrorZ CResult_ClosingSignedDecodeErrorZ_clone(const struct LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR orig); +bool ChannelHandshakeConfig_get_negotiate_scid_privacy(const struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr); /** - * Creates a new CResult_ClosingSignedFeeRangeDecodeErrorZ in the success state. + * 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 + * [`ChannelHandshakeConfig::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 */ -struct LDKCResult_ClosingSignedFeeRangeDecodeErrorZ CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(struct LDKClosingSignedFeeRange o); +void ChannelHandshakeConfig_set_negotiate_scid_privacy(struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr, bool val); /** - * Creates a new CResult_ClosingSignedFeeRangeDecodeErrorZ in the error state. + * Set to announce the channel publicly and notify all nodes that they can route via this + * channel. + * + * This should only be set to true for nodes which expect to be online reliably. + * + * As the node which funds a channel picks this value this will only apply for new outbound + * channels unless [`ChannelHandshakeLimits::force_announced_channel_preference`] is set. + * + * Default value: false. */ -struct LDKCResult_ClosingSignedFeeRangeDecodeErrorZ CResult_ClosingSignedFeeRangeDecodeErrorZ_err(struct LDKDecodeError e); +bool ChannelHandshakeConfig_get_announced_channel(const struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr); /** - * Checks if the given object is currently in the success state + * Set to announce the channel publicly and notify all nodes that they can route via this + * channel. + * + * This should only be set to true for nodes which expect to be online reliably. + * + * As the node which funds a channel picks this value this will only apply for new outbound + * channels unless [`ChannelHandshakeLimits::force_announced_channel_preference`] is set. + * + * Default value: false. */ -bool CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(const struct LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR o); +void ChannelHandshakeConfig_set_announced_channel(struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr, bool val); /** - * Frees any resources used by the CResult_ClosingSignedFeeRangeDecodeErrorZ. + * When set, we commit to an upfront shutdown_pubkey at channel open. If our counterparty + * supports it, they will then enforce the mutual-close output to us matches what we provided + * at intialization, preventing us from closing to an alternate pubkey. + * + * This is set to true by default to provide a slight increase in security, though ultimately + * any attacker who is able to take control of a channel can just as easily send the funds via + * lightning payments, so we never require that our counterparties support this option. + * + * The upfront key committed is provided from [`KeysInterface::get_shutdown_scriptpubkey`]. + * + * Default value: true. + * + * [`KeysInterface::get_shutdown_scriptpubkey`]: crate::chain::keysinterface::KeysInterface::get_shutdown_scriptpubkey */ -void CResult_ClosingSignedFeeRangeDecodeErrorZ_free(struct LDKCResult_ClosingSignedFeeRangeDecodeErrorZ _res); +bool ChannelHandshakeConfig_get_commit_upfront_shutdown_pubkey(const struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr); /** - * Creates a new CResult_ClosingSignedFeeRangeDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * When set, we commit to an upfront shutdown_pubkey at channel open. If our counterparty + * supports it, they will then enforce the mutual-close output to us matches what we provided + * at intialization, preventing us from closing to an alternate pubkey. + * + * This is set to true by default to provide a slight increase in security, though ultimately + * any attacker who is able to take control of a channel can just as easily send the funds via + * lightning payments, so we never require that our counterparties support this option. + * + * The upfront key committed is provided from [`KeysInterface::get_shutdown_scriptpubkey`]. + * + * Default value: true. + * + * [`KeysInterface::get_shutdown_scriptpubkey`]: crate::chain::keysinterface::KeysInterface::get_shutdown_scriptpubkey */ -struct LDKCResult_ClosingSignedFeeRangeDecodeErrorZ CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(const struct LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR orig); +void ChannelHandshakeConfig_set_commit_upfront_shutdown_pubkey(struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr, bool val); /** - * Creates a new CResult_CommitmentSignedDecodeErrorZ in the success state. + * The Proportion of the channel value to configure as counterparty's channel reserve, + * i.e., `their_channel_reserve_satoshis` for both outbound and inbound channels. + * + * `their_channel_reserve_satoshis` is the minimum balance that the other node has to maintain + * on their side, at all times. + * This ensures that if our counterparty broadcasts a revoked state, we can punish them by + * claiming at least this value on chain. + * + * Channel reserve values greater than 30% could be considered highly unreasonable, since that + * amount can never be used for payments. + * Also, if our selected channel reserve for counterparty and counterparty's selected + * channel reserve for us sum up to equal or greater than channel value, channel negotiations + * will fail. + * + * Note: Versions of LDK earlier than v0.0.104 will fail to read channels with any channel reserve + * other than the default value. + * + * Default value: 1% of channel value, i.e., configured as 10,000 millionths. + * Minimum value: If the calculated proportional value is less than 1000 sats, it will be treated + * as 1000 sats instead, which is a safe implementation-specific lower bound. + * Maximum value: 1,000,000, any values larger than 1 Million will be treated as 1 Million (or 100%) + * instead, although channel negotiations will fail in that case. */ -struct LDKCResult_CommitmentSignedDecodeErrorZ CResult_CommitmentSignedDecodeErrorZ_ok(struct LDKCommitmentSigned o); +uint32_t ChannelHandshakeConfig_get_their_channel_reserve_proportional_millionths(const struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr); /** - * Creates a new CResult_CommitmentSignedDecodeErrorZ in the error state. + * The Proportion of the channel value to configure as counterparty's channel reserve, + * i.e., `their_channel_reserve_satoshis` for both outbound and inbound channels. + * + * `their_channel_reserve_satoshis` is the minimum balance that the other node has to maintain + * on their side, at all times. + * This ensures that if our counterparty broadcasts a revoked state, we can punish them by + * claiming at least this value on chain. + * + * Channel reserve values greater than 30% could be considered highly unreasonable, since that + * amount can never be used for payments. + * Also, if our selected channel reserve for counterparty and counterparty's selected + * channel reserve for us sum up to equal or greater than channel value, channel negotiations + * will fail. + * + * Note: Versions of LDK earlier than v0.0.104 will fail to read channels with any channel reserve + * other than the default value. + * + * Default value: 1% of channel value, i.e., configured as 10,000 millionths. + * Minimum value: If the calculated proportional value is less than 1000 sats, it will be treated + * as 1000 sats instead, which is a safe implementation-specific lower bound. + * Maximum value: 1,000,000, any values larger than 1 Million will be treated as 1 Million (or 100%) + * instead, although channel negotiations will fail in that case. */ -struct LDKCResult_CommitmentSignedDecodeErrorZ CResult_CommitmentSignedDecodeErrorZ_err(struct LDKDecodeError e); +void ChannelHandshakeConfig_set_their_channel_reserve_proportional_millionths(struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr, uint32_t val); /** - * Checks if the given object is currently in the success state + * Constructs a new ChannelHandshakeConfig given each field */ -bool CResult_CommitmentSignedDecodeErrorZ_is_ok(const struct LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR o); +MUST_USE_RES struct LDKChannelHandshakeConfig ChannelHandshakeConfig_new(uint32_t minimum_depth_arg, uint16_t our_to_self_delay_arg, uint64_t our_htlc_minimum_msat_arg, uint8_t max_inbound_htlc_value_in_flight_percent_of_channel_arg, bool negotiate_scid_privacy_arg, bool announced_channel_arg, bool commit_upfront_shutdown_pubkey_arg, uint32_t their_channel_reserve_proportional_millionths_arg); /** - * Frees any resources used by the CResult_CommitmentSignedDecodeErrorZ. + * Creates a copy of the ChannelHandshakeConfig */ -void CResult_CommitmentSignedDecodeErrorZ_free(struct LDKCResult_CommitmentSignedDecodeErrorZ _res); +struct LDKChannelHandshakeConfig ChannelHandshakeConfig_clone(const struct LDKChannelHandshakeConfig *NONNULL_PTR orig); /** - * Creates a new CResult_CommitmentSignedDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Creates a "default" ChannelHandshakeConfig. See struct and individual field documentaiton for details on which values are used. */ -struct LDKCResult_CommitmentSignedDecodeErrorZ CResult_CommitmentSignedDecodeErrorZ_clone(const struct LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR orig); +MUST_USE_RES struct LDKChannelHandshakeConfig ChannelHandshakeConfig_default(void); /** - * Creates a new CResult_FundingCreatedDecodeErrorZ in the success state. + * Frees any resources used by the ChannelHandshakeLimits, if is_owned is set and inner is non-NULL. */ -struct LDKCResult_FundingCreatedDecodeErrorZ CResult_FundingCreatedDecodeErrorZ_ok(struct LDKFundingCreated o); +void ChannelHandshakeLimits_free(struct LDKChannelHandshakeLimits this_obj); /** - * Creates a new CResult_FundingCreatedDecodeErrorZ in the error state. + * Minimum allowed satoshis when a channel is funded. This is supplied by the sender and so + * only applies to inbound channels. + * + * Default value: 0. */ -struct LDKCResult_FundingCreatedDecodeErrorZ CResult_FundingCreatedDecodeErrorZ_err(struct LDKDecodeError e); +uint64_t ChannelHandshakeLimits_get_min_funding_satoshis(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); /** - * Checks if the given object is currently in the success state + * Minimum allowed satoshis when a channel is funded. This is supplied by the sender and so + * only applies to inbound channels. + * + * Default value: 0. */ -bool CResult_FundingCreatedDecodeErrorZ_is_ok(const struct LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR o); +void ChannelHandshakeLimits_set_min_funding_satoshis(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, uint64_t val); /** - * Frees any resources used by the CResult_FundingCreatedDecodeErrorZ. + * Maximum allowed satoshis when a channel is funded. This is supplied by the sender and so + * only applies to inbound channels. + * + * Default value: 2^24 - 1. */ -void CResult_FundingCreatedDecodeErrorZ_free(struct LDKCResult_FundingCreatedDecodeErrorZ _res); +uint64_t ChannelHandshakeLimits_get_max_funding_satoshis(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); /** - * Creates a new CResult_FundingCreatedDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Maximum allowed satoshis when a channel is funded. This is supplied by the sender and so + * only applies to inbound channels. + * + * Default value: 2^24 - 1. */ -struct LDKCResult_FundingCreatedDecodeErrorZ CResult_FundingCreatedDecodeErrorZ_clone(const struct LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR orig); +void ChannelHandshakeLimits_set_max_funding_satoshis(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, uint64_t val); /** - * Creates a new CResult_FundingSignedDecodeErrorZ in the success state. + * The remote node sets a limit on the minimum size of HTLCs we can send to them. This allows + * you to limit the maximum minimum-size they can require. + * + * Default value: u64::max_value. */ -struct LDKCResult_FundingSignedDecodeErrorZ CResult_FundingSignedDecodeErrorZ_ok(struct LDKFundingSigned o); +uint64_t ChannelHandshakeLimits_get_max_htlc_minimum_msat(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); /** - * Creates a new CResult_FundingSignedDecodeErrorZ in the error state. + * The remote node sets a limit on the minimum size of HTLCs we can send to them. This allows + * you to limit the maximum minimum-size they can require. + * + * Default value: u64::max_value. */ -struct LDKCResult_FundingSignedDecodeErrorZ CResult_FundingSignedDecodeErrorZ_err(struct LDKDecodeError e); +void ChannelHandshakeLimits_set_max_htlc_minimum_msat(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, uint64_t val); /** - * Checks if the given object is currently in the success state + * The remote node sets a limit on the maximum value of pending HTLCs to them at any given + * time to limit their funds exposure to HTLCs. This allows you to set a minimum such value. + * + * Default value: 0. */ -bool CResult_FundingSignedDecodeErrorZ_is_ok(const struct LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR o); +uint64_t ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); /** - * Frees any resources used by the CResult_FundingSignedDecodeErrorZ. + * The remote node sets a limit on the maximum value of pending HTLCs to them at any given + * time to limit their funds exposure to HTLCs. This allows you to set a minimum such value. + * + * Default value: 0. */ -void CResult_FundingSignedDecodeErrorZ_free(struct LDKCResult_FundingSignedDecodeErrorZ _res); +void ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, uint64_t val); /** - * Creates a new CResult_FundingSignedDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * The remote node will require we keep a certain amount in direct payment to ourselves at all + * time, ensuring that we are able to be punished if we broadcast an old state. This allows to + * you limit the amount which we will have to keep to ourselves (and cannot use for HTLCs). + * + * Default value: u64::max_value. */ -struct LDKCResult_FundingSignedDecodeErrorZ CResult_FundingSignedDecodeErrorZ_clone(const struct LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR orig); +uint64_t ChannelHandshakeLimits_get_max_channel_reserve_satoshis(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); /** - * Creates a new CResult_FundingLockedDecodeErrorZ in the success state. + * The remote node will require we keep a certain amount in direct payment to ourselves at all + * time, ensuring that we are able to be punished if we broadcast an old state. This allows to + * you limit the amount which we will have to keep to ourselves (and cannot use for HTLCs). + * + * Default value: u64::max_value. */ -struct LDKCResult_FundingLockedDecodeErrorZ CResult_FundingLockedDecodeErrorZ_ok(struct LDKFundingLocked o); +void ChannelHandshakeLimits_set_max_channel_reserve_satoshis(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, uint64_t val); /** - * Creates a new CResult_FundingLockedDecodeErrorZ in the error state. + * The remote node sets a limit on the maximum number of pending HTLCs to them at any given + * time. This allows you to set a minimum such value. + * + * Default value: 0. */ -struct LDKCResult_FundingLockedDecodeErrorZ CResult_FundingLockedDecodeErrorZ_err(struct LDKDecodeError e); +uint16_t ChannelHandshakeLimits_get_min_max_accepted_htlcs(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); /** - * Checks if the given object is currently in the success state + * The remote node sets a limit on the maximum number of pending HTLCs to them at any given + * time. This allows you to set a minimum such value. + * + * Default value: 0. */ -bool CResult_FundingLockedDecodeErrorZ_is_ok(const struct LDKCResult_FundingLockedDecodeErrorZ *NONNULL_PTR o); +void ChannelHandshakeLimits_set_min_max_accepted_htlcs(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, uint16_t val); /** - * Frees any resources used by the CResult_FundingLockedDecodeErrorZ. + * Before a channel is usable the funding transaction will need to be confirmed by at least a + * certain number of blocks, specified by the node which is not the funder (as the funder can + * assume they aren't going to double-spend themselves). + * This config allows you to set a limit on the maximum amount of time to wait. + * + * Default value: 144, or roughly one day and only applies to outbound channels. */ -void CResult_FundingLockedDecodeErrorZ_free(struct LDKCResult_FundingLockedDecodeErrorZ _res); +uint32_t ChannelHandshakeLimits_get_max_minimum_depth(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); /** - * Creates a new CResult_FundingLockedDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Before a channel is usable the funding transaction will need to be confirmed by at least a + * certain number of blocks, specified by the node which is not the funder (as the funder can + * assume they aren't going to double-spend themselves). + * This config allows you to set a limit on the maximum amount of time to wait. + * + * Default value: 144, or roughly one day and only applies to outbound channels. */ -struct LDKCResult_FundingLockedDecodeErrorZ CResult_FundingLockedDecodeErrorZ_clone(const struct LDKCResult_FundingLockedDecodeErrorZ *NONNULL_PTR orig); +void ChannelHandshakeLimits_set_max_minimum_depth(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, uint32_t val); /** - * Creates a new CResult_InitDecodeErrorZ in the success state. + * Whether we implicitly trust funding transactions generated by us for our own outbound + * channels to not be double-spent. + * + * If this is set, we assume that our own funding transactions are *never* double-spent, and + * thus we can trust them without any confirmations. This is generally a reasonable + * assumption, given we're the only ones who could ever double-spend it (assuming we have sole + * control of the signing keys). + * + * You may wish to un-set this if you allow the user to (or do in an automated fashion) + * double-spend the funding transaction to RBF with an alternative channel open. + * + * This only applies if our counterparty set their confirmations-required value to 0, and we + * always trust our own funding transaction at 1 confirmation irrespective of this value. + * Thus, this effectively acts as a `min_minimum_depth`, with the only possible values being + * `true` (0) and `false` (1). + * + * Default value: true */ -struct LDKCResult_InitDecodeErrorZ CResult_InitDecodeErrorZ_ok(struct LDKInit o); +bool ChannelHandshakeLimits_get_trust_own_funding_0conf(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); /** - * Creates a new CResult_InitDecodeErrorZ in the error state. + * Whether we implicitly trust funding transactions generated by us for our own outbound + * channels to not be double-spent. + * + * If this is set, we assume that our own funding transactions are *never* double-spent, and + * thus we can trust them without any confirmations. This is generally a reasonable + * assumption, given we're the only ones who could ever double-spend it (assuming we have sole + * control of the signing keys). + * + * You may wish to un-set this if you allow the user to (or do in an automated fashion) + * double-spend the funding transaction to RBF with an alternative channel open. + * + * This only applies if our counterparty set their confirmations-required value to 0, and we + * always trust our own funding transaction at 1 confirmation irrespective of this value. + * Thus, this effectively acts as a `min_minimum_depth`, with the only possible values being + * `true` (0) and `false` (1). + * + * Default value: true */ -struct LDKCResult_InitDecodeErrorZ CResult_InitDecodeErrorZ_err(struct LDKDecodeError e); +void ChannelHandshakeLimits_set_trust_own_funding_0conf(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, bool val); /** - * Checks if the given object is currently in the success state + * Set to force an incoming channel to match our announced channel preference in + * [`ChannelHandshakeConfig::announced_channel`]. + * + * For a node which is not online reliably, this should be set to true and + * [`ChannelHandshakeConfig::announced_channel`] set to false, ensuring that no announced (aka public) + * channels will ever be opened. + * + * Default value: true. */ -bool CResult_InitDecodeErrorZ_is_ok(const struct LDKCResult_InitDecodeErrorZ *NONNULL_PTR o); +bool ChannelHandshakeLimits_get_force_announced_channel_preference(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); /** - * Frees any resources used by the CResult_InitDecodeErrorZ. + * Set to force an incoming channel to match our announced channel preference in + * [`ChannelHandshakeConfig::announced_channel`]. + * + * For a node which is not online reliably, this should be set to true and + * [`ChannelHandshakeConfig::announced_channel`] set to false, ensuring that no announced (aka public) + * channels will ever be opened. + * + * Default value: true. */ -void CResult_InitDecodeErrorZ_free(struct LDKCResult_InitDecodeErrorZ _res); +void ChannelHandshakeLimits_set_force_announced_channel_preference(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, bool val); /** - * Creates a new CResult_InitDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Set to the amount of time we're willing to wait to claim money back to us. + * + * Not checking this value would be a security issue, as our peer would be able to set it to + * max relative lock-time (a year) and we would \"lose\" money as it would be locked for a long time. + * + * Default value: 2016, which we also enforce as a maximum value so you can tweak config to + * reduce the loss of having useless locked funds (if your peer accepts) */ -struct LDKCResult_InitDecodeErrorZ CResult_InitDecodeErrorZ_clone(const struct LDKCResult_InitDecodeErrorZ *NONNULL_PTR orig); +uint16_t ChannelHandshakeLimits_get_their_to_self_delay(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); /** - * Creates a new CResult_OpenChannelDecodeErrorZ in the success state. + * Set to the amount of time we're willing to wait to claim money back to us. + * + * Not checking this value would be a security issue, as our peer would be able to set it to + * max relative lock-time (a year) and we would \"lose\" money as it would be locked for a long time. + * + * Default value: 2016, which we also enforce as a maximum value so you can tweak config to + * reduce the loss of having useless locked funds (if your peer accepts) */ -struct LDKCResult_OpenChannelDecodeErrorZ CResult_OpenChannelDecodeErrorZ_ok(struct LDKOpenChannel o); +void ChannelHandshakeLimits_set_their_to_self_delay(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, uint16_t val); /** - * Creates a new CResult_OpenChannelDecodeErrorZ in the error state. + * Constructs a new ChannelHandshakeLimits given each field */ -struct LDKCResult_OpenChannelDecodeErrorZ CResult_OpenChannelDecodeErrorZ_err(struct LDKDecodeError e); +MUST_USE_RES struct LDKChannelHandshakeLimits ChannelHandshakeLimits_new(uint64_t min_funding_satoshis_arg, uint64_t max_funding_satoshis_arg, uint64_t max_htlc_minimum_msat_arg, uint64_t min_max_htlc_value_in_flight_msat_arg, uint64_t max_channel_reserve_satoshis_arg, uint16_t min_max_accepted_htlcs_arg, uint32_t max_minimum_depth_arg, bool trust_own_funding_0conf_arg, bool force_announced_channel_preference_arg, uint16_t their_to_self_delay_arg); /** - * Checks if the given object is currently in the success state + * Creates a copy of the ChannelHandshakeLimits */ -bool CResult_OpenChannelDecodeErrorZ_is_ok(const struct LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR o); +struct LDKChannelHandshakeLimits ChannelHandshakeLimits_clone(const struct LDKChannelHandshakeLimits *NONNULL_PTR orig); /** - * Frees any resources used by the CResult_OpenChannelDecodeErrorZ. + * Creates a "default" ChannelHandshakeLimits. See struct and individual field documentaiton for details on which values are used. */ -void CResult_OpenChannelDecodeErrorZ_free(struct LDKCResult_OpenChannelDecodeErrorZ _res); +MUST_USE_RES struct LDKChannelHandshakeLimits ChannelHandshakeLimits_default(void); /** - * Creates a new CResult_OpenChannelDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Frees any resources used by the ChannelConfig, if is_owned is set and inner is non-NULL. */ -struct LDKCResult_OpenChannelDecodeErrorZ CResult_OpenChannelDecodeErrorZ_clone(const struct LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR orig); +void ChannelConfig_free(struct LDKChannelConfig this_obj); /** - * Creates a new CResult_RevokeAndACKDecodeErrorZ in the success state. + * Amount (in millionths of a satoshi) charged per satoshi for payments forwarded outbound + * over the channel. + * This may be allowed to change at runtime in a later update, however doing so must result in + * update messages sent to notify all nodes of our updated relay fee. + * + * Default value: 0. */ -struct LDKCResult_RevokeAndACKDecodeErrorZ CResult_RevokeAndACKDecodeErrorZ_ok(struct LDKRevokeAndACK o); +uint32_t ChannelConfig_get_forwarding_fee_proportional_millionths(const struct LDKChannelConfig *NONNULL_PTR this_ptr); /** - * Creates a new CResult_RevokeAndACKDecodeErrorZ in the error state. + * Amount (in millionths of a satoshi) charged per satoshi for payments forwarded outbound + * over the channel. + * This may be allowed to change at runtime in a later update, however doing so must result in + * update messages sent to notify all nodes of our updated relay fee. + * + * Default value: 0. */ -struct LDKCResult_RevokeAndACKDecodeErrorZ CResult_RevokeAndACKDecodeErrorZ_err(struct LDKDecodeError e); +void ChannelConfig_set_forwarding_fee_proportional_millionths(struct LDKChannelConfig *NONNULL_PTR this_ptr, uint32_t val); /** - * Checks if the given object is currently in the success state + * Amount (in milli-satoshi) charged for payments forwarded outbound over the channel, in + * excess of [`forwarding_fee_proportional_millionths`]. + * This may be allowed to change at runtime in a later update, however doing so must result in + * update messages sent to notify all nodes of our updated relay fee. + * + * The default value of a single satoshi roughly matches the market rate on many routing nodes + * as of July 2021. Adjusting it upwards or downwards may change whether nodes route through + * this node. + * + * Default value: 1000. + * + * [`forwarding_fee_proportional_millionths`]: ChannelConfig::forwarding_fee_proportional_millionths */ -bool CResult_RevokeAndACKDecodeErrorZ_is_ok(const struct LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR o); +uint32_t ChannelConfig_get_forwarding_fee_base_msat(const struct LDKChannelConfig *NONNULL_PTR this_ptr); /** - * Frees any resources used by the CResult_RevokeAndACKDecodeErrorZ. + * Amount (in milli-satoshi) charged for payments forwarded outbound over the channel, in + * excess of [`forwarding_fee_proportional_millionths`]. + * This may be allowed to change at runtime in a later update, however doing so must result in + * update messages sent to notify all nodes of our updated relay fee. + * + * The default value of a single satoshi roughly matches the market rate on many routing nodes + * as of July 2021. Adjusting it upwards or downwards may change whether nodes route through + * this node. + * + * Default value: 1000. + * + * [`forwarding_fee_proportional_millionths`]: ChannelConfig::forwarding_fee_proportional_millionths */ -void CResult_RevokeAndACKDecodeErrorZ_free(struct LDKCResult_RevokeAndACKDecodeErrorZ _res); +void ChannelConfig_set_forwarding_fee_base_msat(struct LDKChannelConfig *NONNULL_PTR this_ptr, uint32_t val); /** - * Creates a new CResult_RevokeAndACKDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * The difference in the CLTV value between incoming HTLCs and an outbound HTLC forwarded over + * the channel this config applies to. + * + * This is analogous to [`ChannelHandshakeConfig::our_to_self_delay`] but applies to in-flight + * HTLC balance when a channel appears on-chain whereas + * [`ChannelHandshakeConfig::our_to_self_delay`] applies to the remaining + * (non-HTLC-encumbered) balance. + * + * Thus, for HTLC-encumbered balances to be enforced on-chain when a channel is force-closed, + * we (or one of our watchtowers) MUST be online to check for broadcast of the current + * commitment transaction at least once per this many blocks (minus some margin to allow us + * enough time to broadcast and confirm a transaction, possibly with time in between to RBF + * the spending transaction). + * + * Default value: 72 (12 hours at an average of 6 blocks/hour). + * Minimum value: [`MIN_CLTV_EXPIRY_DELTA`], any values less than this will be treated as + * [`MIN_CLTV_EXPIRY_DELTA`] instead. + * + * [`MIN_CLTV_EXPIRY_DELTA`]: crate::ln::channelmanager::MIN_CLTV_EXPIRY_DELTA */ -struct LDKCResult_RevokeAndACKDecodeErrorZ CResult_RevokeAndACKDecodeErrorZ_clone(const struct LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR orig); +uint16_t ChannelConfig_get_cltv_expiry_delta(const struct LDKChannelConfig *NONNULL_PTR this_ptr); /** - * Creates a new CResult_ShutdownDecodeErrorZ in the success state. + * The difference in the CLTV value between incoming HTLCs and an outbound HTLC forwarded over + * the channel this config applies to. + * + * This is analogous to [`ChannelHandshakeConfig::our_to_self_delay`] but applies to in-flight + * HTLC balance when a channel appears on-chain whereas + * [`ChannelHandshakeConfig::our_to_self_delay`] applies to the remaining + * (non-HTLC-encumbered) balance. + * + * Thus, for HTLC-encumbered balances to be enforced on-chain when a channel is force-closed, + * we (or one of our watchtowers) MUST be online to check for broadcast of the current + * commitment transaction at least once per this many blocks (minus some margin to allow us + * enough time to broadcast and confirm a transaction, possibly with time in between to RBF + * the spending transaction). + * + * Default value: 72 (12 hours at an average of 6 blocks/hour). + * Minimum value: [`MIN_CLTV_EXPIRY_DELTA`], any values less than this will be treated as + * [`MIN_CLTV_EXPIRY_DELTA`] instead. + * + * [`MIN_CLTV_EXPIRY_DELTA`]: crate::ln::channelmanager::MIN_CLTV_EXPIRY_DELTA */ -struct LDKCResult_ShutdownDecodeErrorZ CResult_ShutdownDecodeErrorZ_ok(struct LDKShutdown o); +void ChannelConfig_set_cltv_expiry_delta(struct LDKChannelConfig *NONNULL_PTR this_ptr, uint16_t val); /** - * Creates a new CResult_ShutdownDecodeErrorZ in the error state. + * Limit our total exposure to in-flight HTLCs which are burned to fees as they are too + * small to claim on-chain. + * + * When an HTLC present in one of our channels is below a \"dust\" threshold, the HTLC will + * not be claimable on-chain, instead being turned into additional miner fees if either + * party force-closes the channel. Because the threshold is per-HTLC, our total exposure + * to such payments may be sustantial if there are many dust HTLCs present when the + * channel is force-closed. + * + * The dust threshold for each HTLC is based on the `dust_limit_satoshis` for each party in a + * channel negotiated throughout the channel open process, along with the fees required to have + * a broadcastable HTLC spending transaction. When a channel supports anchor outputs + * (specifically the zero fee HTLC transaction variant), this threshold no longer takes into + * account the HTLC transaction fee as it is zero. + * + * This limit is applied for sent, forwarded, and received HTLCs and limits the total + * exposure across all three types per-channel. Setting this too low may prevent the + * sending or receipt of low-value HTLCs on high-traffic nodes, and this limit is very + * important to prevent stealing of dust HTLCs by miners. + * + * Default value: 5_000_000 msat. */ -struct LDKCResult_ShutdownDecodeErrorZ CResult_ShutdownDecodeErrorZ_err(struct LDKDecodeError e); +uint64_t ChannelConfig_get_max_dust_htlc_exposure_msat(const struct LDKChannelConfig *NONNULL_PTR this_ptr); /** - * Checks if the given object is currently in the success state + * Limit our total exposure to in-flight HTLCs which are burned to fees as they are too + * small to claim on-chain. + * + * When an HTLC present in one of our channels is below a \"dust\" threshold, the HTLC will + * not be claimable on-chain, instead being turned into additional miner fees if either + * party force-closes the channel. Because the threshold is per-HTLC, our total exposure + * to such payments may be sustantial if there are many dust HTLCs present when the + * channel is force-closed. + * + * The dust threshold for each HTLC is based on the `dust_limit_satoshis` for each party in a + * channel negotiated throughout the channel open process, along with the fees required to have + * a broadcastable HTLC spending transaction. When a channel supports anchor outputs + * (specifically the zero fee HTLC transaction variant), this threshold no longer takes into + * account the HTLC transaction fee as it is zero. + * + * This limit is applied for sent, forwarded, and received HTLCs and limits the total + * exposure across all three types per-channel. Setting this too low may prevent the + * sending or receipt of low-value HTLCs on high-traffic nodes, and this limit is very + * important to prevent stealing of dust HTLCs by miners. + * + * Default value: 5_000_000 msat. */ -bool CResult_ShutdownDecodeErrorZ_is_ok(const struct LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR o); +void ChannelConfig_set_max_dust_htlc_exposure_msat(struct LDKChannelConfig *NONNULL_PTR this_ptr, uint64_t val); /** - * Frees any resources used by the CResult_ShutdownDecodeErrorZ. + * The additional fee we're willing to pay to avoid waiting for the counterparty's + * `to_self_delay` to reclaim funds. + * + * When we close a channel cooperatively with our counterparty, we negotiate a fee for the + * closing transaction which both sides find acceptable, ultimately paid by the channel + * funder/initiator. + * + * When we are the funder, because we have to pay the channel closing fee, we bound the + * acceptable fee by our [`Background`] and [`Normal`] fees, with the upper bound increased by + * this value. Because the on-chain fee we'd pay to force-close the channel is kept near our + * [`Normal`] feerate during normal operation, this value represents the additional fee we're + * willing to pay in order to avoid waiting for our counterparty's to_self_delay to reclaim our + * funds. + * + * When we are not the funder, we require the closing transaction fee pay at least our + * [`Background`] fee estimate, but allow our counterparty to pay as much fee as they like. + * Thus, this value is ignored when we are not the funder. + * + * Default value: 1000 satoshis. + * + * [`Normal`]: crate::chain::chaininterface::ConfirmationTarget::Normal + * [`Background`]: crate::chain::chaininterface::ConfirmationTarget::Background */ -void CResult_ShutdownDecodeErrorZ_free(struct LDKCResult_ShutdownDecodeErrorZ _res); +uint64_t ChannelConfig_get_force_close_avoidance_max_fee_satoshis(const struct LDKChannelConfig *NONNULL_PTR this_ptr); /** - * Creates a new CResult_ShutdownDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * The additional fee we're willing to pay to avoid waiting for the counterparty's + * `to_self_delay` to reclaim funds. + * + * When we close a channel cooperatively with our counterparty, we negotiate a fee for the + * closing transaction which both sides find acceptable, ultimately paid by the channel + * funder/initiator. + * + * When we are the funder, because we have to pay the channel closing fee, we bound the + * acceptable fee by our [`Background`] and [`Normal`] fees, with the upper bound increased by + * this value. Because the on-chain fee we'd pay to force-close the channel is kept near our + * [`Normal`] feerate during normal operation, this value represents the additional fee we're + * willing to pay in order to avoid waiting for our counterparty's to_self_delay to reclaim our + * funds. + * + * When we are not the funder, we require the closing transaction fee pay at least our + * [`Background`] fee estimate, but allow our counterparty to pay as much fee as they like. + * Thus, this value is ignored when we are not the funder. + * + * Default value: 1000 satoshis. + * + * [`Normal`]: crate::chain::chaininterface::ConfirmationTarget::Normal + * [`Background`]: crate::chain::chaininterface::ConfirmationTarget::Background */ -struct LDKCResult_ShutdownDecodeErrorZ CResult_ShutdownDecodeErrorZ_clone(const struct LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR orig); +void ChannelConfig_set_force_close_avoidance_max_fee_satoshis(struct LDKChannelConfig *NONNULL_PTR this_ptr, uint64_t val); /** - * Creates a new CResult_UpdateFailHTLCDecodeErrorZ in the success state. + * Constructs a new ChannelConfig given each field */ -struct LDKCResult_UpdateFailHTLCDecodeErrorZ CResult_UpdateFailHTLCDecodeErrorZ_ok(struct LDKUpdateFailHTLC o); +MUST_USE_RES struct LDKChannelConfig ChannelConfig_new(uint32_t forwarding_fee_proportional_millionths_arg, uint32_t forwarding_fee_base_msat_arg, uint16_t cltv_expiry_delta_arg, uint64_t max_dust_htlc_exposure_msat_arg, uint64_t force_close_avoidance_max_fee_satoshis_arg); /** - * Creates a new CResult_UpdateFailHTLCDecodeErrorZ in the error state. + * Creates a copy of the ChannelConfig */ -struct LDKCResult_UpdateFailHTLCDecodeErrorZ CResult_UpdateFailHTLCDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKChannelConfig ChannelConfig_clone(const struct LDKChannelConfig *NONNULL_PTR orig); /** - * Checks if the given object is currently in the success state + * Checks if two ChannelConfigs 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 CResult_UpdateFailHTLCDecodeErrorZ_is_ok(const struct LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR o); +bool ChannelConfig_eq(const struct LDKChannelConfig *NONNULL_PTR a, const struct LDKChannelConfig *NONNULL_PTR b); /** - * Frees any resources used by the CResult_UpdateFailHTLCDecodeErrorZ. + * Creates a "default" ChannelConfig. See struct and individual field documentaiton for details on which values are used. */ -void CResult_UpdateFailHTLCDecodeErrorZ_free(struct LDKCResult_UpdateFailHTLCDecodeErrorZ _res); +MUST_USE_RES struct LDKChannelConfig ChannelConfig_default(void); /** - * Creates a new CResult_UpdateFailHTLCDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Serialize the ChannelConfig object into a byte array which can be read by ChannelConfig_read */ -struct LDKCResult_UpdateFailHTLCDecodeErrorZ CResult_UpdateFailHTLCDecodeErrorZ_clone(const struct LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR orig); +struct LDKCVec_u8Z ChannelConfig_write(const struct LDKChannelConfig *NONNULL_PTR obj); /** - * Creates a new CResult_UpdateFailMalformedHTLCDecodeErrorZ in the success state. + * Read a ChannelConfig from a byte array, created by ChannelConfig_write */ -struct LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(struct LDKUpdateFailMalformedHTLC o); +struct LDKCResult_ChannelConfigDecodeErrorZ ChannelConfig_read(struct LDKu8slice ser); /** - * Creates a new CResult_UpdateFailMalformedHTLCDecodeErrorZ in the error state. + * Frees any resources used by the UserConfig, if is_owned is set and inner is non-NULL. */ -struct LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(struct LDKDecodeError e); +void UserConfig_free(struct LDKUserConfig this_obj); /** - * Checks if the given object is currently in the success state + * Channel handshake config that we propose to our counterparty. */ -bool CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(const struct LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR o); +struct LDKChannelHandshakeConfig UserConfig_get_channel_handshake_config(const struct LDKUserConfig *NONNULL_PTR this_ptr); /** - * Frees any resources used by the CResult_UpdateFailMalformedHTLCDecodeErrorZ. + * Channel handshake config that we propose to our counterparty. */ -void CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(struct LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res); +void UserConfig_set_channel_handshake_config(struct LDKUserConfig *NONNULL_PTR this_ptr, struct LDKChannelHandshakeConfig val); /** - * Creates a new CResult_UpdateFailMalformedHTLCDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Limits applied to our counterparty's proposed channel handshake config settings. */ -struct LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(const struct LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR orig); +struct LDKChannelHandshakeLimits UserConfig_get_channel_handshake_limits(const struct LDKUserConfig *NONNULL_PTR this_ptr); /** - * Creates a new CResult_UpdateFeeDecodeErrorZ in the success state. + * Limits applied to our counterparty's proposed channel handshake config settings. */ -struct LDKCResult_UpdateFeeDecodeErrorZ CResult_UpdateFeeDecodeErrorZ_ok(struct LDKUpdateFee o); +void UserConfig_set_channel_handshake_limits(struct LDKUserConfig *NONNULL_PTR this_ptr, struct LDKChannelHandshakeLimits val); /** - * Creates a new CResult_UpdateFeeDecodeErrorZ in the error state. + * Channel config which affects behavior during channel lifetime. */ -struct LDKCResult_UpdateFeeDecodeErrorZ CResult_UpdateFeeDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKChannelConfig UserConfig_get_channel_config(const struct LDKUserConfig *NONNULL_PTR this_ptr); /** - * Checks if the given object is currently in the success state + * Channel config which affects behavior during channel lifetime. */ -bool CResult_UpdateFeeDecodeErrorZ_is_ok(const struct LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR o); +void UserConfig_set_channel_config(struct LDKUserConfig *NONNULL_PTR this_ptr, struct LDKChannelConfig val); /** - * Frees any resources used by the CResult_UpdateFeeDecodeErrorZ. + * If this is set to false, we will reject any HTLCs which were to be forwarded over private + * channels. This prevents us from taking on HTLC-forwarding risk when we intend to run as a + * node which is not online reliably. + * + * For nodes which are not online reliably, you should set all channels to *not* be announced + * (using [`ChannelHandshakeConfig::announced_channel`] and + * [`ChannelHandshakeLimits::force_announced_channel_preference`]) and set this to false to + * ensure you are not exposed to any forwarding risk. + * + * Note that because you cannot change a channel's announced state after creation, there is no + * way to disable forwarding on public channels retroactively. Thus, in order to change a node + * from a publicly-announced forwarding node to a private non-forwarding node you must close + * all your channels and open new ones. For privacy, you should also change your node_id + * (swapping all private and public key material for new ones) at that time. + * + * Default value: false. */ -void CResult_UpdateFeeDecodeErrorZ_free(struct LDKCResult_UpdateFeeDecodeErrorZ _res); +bool UserConfig_get_accept_forwards_to_priv_channels(const struct LDKUserConfig *NONNULL_PTR this_ptr); /** - * Creates a new CResult_UpdateFeeDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * If this is set to false, we will reject any HTLCs which were to be forwarded over private + * channels. This prevents us from taking on HTLC-forwarding risk when we intend to run as a + * node which is not online reliably. + * + * For nodes which are not online reliably, you should set all channels to *not* be announced + * (using [`ChannelHandshakeConfig::announced_channel`] and + * [`ChannelHandshakeLimits::force_announced_channel_preference`]) and set this to false to + * ensure you are not exposed to any forwarding risk. + * + * Note that because you cannot change a channel's announced state after creation, there is no + * way to disable forwarding on public channels retroactively. Thus, in order to change a node + * from a publicly-announced forwarding node to a private non-forwarding node you must close + * all your channels and open new ones. For privacy, you should also change your node_id + * (swapping all private and public key material for new ones) at that time. + * + * Default value: false. */ -struct LDKCResult_UpdateFeeDecodeErrorZ CResult_UpdateFeeDecodeErrorZ_clone(const struct LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR orig); +void UserConfig_set_accept_forwards_to_priv_channels(struct LDKUserConfig *NONNULL_PTR this_ptr, bool val); /** - * Creates a new CResult_UpdateFulfillHTLCDecodeErrorZ in the success state. + * If this is set to false, we do not accept inbound requests to open a new channel. + * Default value: true. */ -struct LDKCResult_UpdateFulfillHTLCDecodeErrorZ CResult_UpdateFulfillHTLCDecodeErrorZ_ok(struct LDKUpdateFulfillHTLC o); +bool UserConfig_get_accept_inbound_channels(const struct LDKUserConfig *NONNULL_PTR this_ptr); /** - * Creates a new CResult_UpdateFulfillHTLCDecodeErrorZ in the error state. + * If this is set to false, we do not accept inbound requests to open a new channel. + * Default value: true. */ -struct LDKCResult_UpdateFulfillHTLCDecodeErrorZ CResult_UpdateFulfillHTLCDecodeErrorZ_err(struct LDKDecodeError e); +void UserConfig_set_accept_inbound_channels(struct LDKUserConfig *NONNULL_PTR this_ptr, bool val); /** - * Checks if the given object is currently in the success state + * 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 CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(const struct LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR o); +bool UserConfig_get_manually_accept_inbound_channels(const struct LDKUserConfig *NONNULL_PTR this_ptr); /** - * Frees any resources used by the CResult_UpdateFulfillHTLCDecodeErrorZ. + * 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 CResult_UpdateFulfillHTLCDecodeErrorZ_free(struct LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res); +void UserConfig_set_manually_accept_inbound_channels(struct LDKUserConfig *NONNULL_PTR this_ptr, bool val); /** - * Creates a new CResult_UpdateFulfillHTLCDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Constructs a new UserConfig given each field */ -struct LDKCResult_UpdateFulfillHTLCDecodeErrorZ CResult_UpdateFulfillHTLCDecodeErrorZ_clone(const struct LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR orig); +MUST_USE_RES struct LDKUserConfig UserConfig_new(struct LDKChannelHandshakeConfig channel_handshake_config_arg, struct LDKChannelHandshakeLimits channel_handshake_limits_arg, struct LDKChannelConfig channel_config_arg, bool accept_forwards_to_priv_channels_arg, bool accept_inbound_channels_arg, bool manually_accept_inbound_channels_arg); /** - * Creates a new CResult_UpdateAddHTLCDecodeErrorZ in the success state. + * Creates a copy of the UserConfig */ -struct LDKCResult_UpdateAddHTLCDecodeErrorZ CResult_UpdateAddHTLCDecodeErrorZ_ok(struct LDKUpdateAddHTLC o); +struct LDKUserConfig UserConfig_clone(const struct LDKUserConfig *NONNULL_PTR orig); /** - * Creates a new CResult_UpdateAddHTLCDecodeErrorZ in the error state. + * Creates a "default" UserConfig. See struct and individual field documentaiton for details on which values are used. */ -struct LDKCResult_UpdateAddHTLCDecodeErrorZ CResult_UpdateAddHTLCDecodeErrorZ_err(struct LDKDecodeError e); +MUST_USE_RES struct LDKUserConfig UserConfig_default(void); /** - * Checks if the given object is currently in the success state + * Frees any resources used by the BestBlock, if is_owned is set and inner is non-NULL. */ -bool CResult_UpdateAddHTLCDecodeErrorZ_is_ok(const struct LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR o); +void BestBlock_free(struct LDKBestBlock this_obj); /** - * Frees any resources used by the CResult_UpdateAddHTLCDecodeErrorZ. + * Creates a copy of the BestBlock */ -void CResult_UpdateAddHTLCDecodeErrorZ_free(struct LDKCResult_UpdateAddHTLCDecodeErrorZ _res); +struct LDKBestBlock BestBlock_clone(const struct LDKBestBlock *NONNULL_PTR orig); /** - * Creates a new CResult_UpdateAddHTLCDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Checks if two BestBlocks contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -struct LDKCResult_UpdateAddHTLCDecodeErrorZ CResult_UpdateAddHTLCDecodeErrorZ_clone(const struct LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR orig); +bool BestBlock_eq(const struct LDKBestBlock *NONNULL_PTR a, const struct LDKBestBlock *NONNULL_PTR b); /** - * Creates a new CResult_PingDecodeErrorZ in the success state. + * Constructs a `BestBlock` that represents the genesis block at height 0 of the given + * network. */ -struct LDKCResult_PingDecodeErrorZ CResult_PingDecodeErrorZ_ok(struct LDKPing o); +MUST_USE_RES struct LDKBestBlock BestBlock_from_genesis(enum LDKNetwork network); /** - * Creates a new CResult_PingDecodeErrorZ in the error state. + * Returns a `BestBlock` as identified by the given block hash and height. */ -struct LDKCResult_PingDecodeErrorZ CResult_PingDecodeErrorZ_err(struct LDKDecodeError e); +MUST_USE_RES struct LDKBestBlock BestBlock_new(struct LDKThirtyTwoBytes block_hash, uint32_t height); /** - * Checks if the given object is currently in the success state + * Returns the best block hash. */ -bool CResult_PingDecodeErrorZ_is_ok(const struct LDKCResult_PingDecodeErrorZ *NONNULL_PTR o); +MUST_USE_RES struct LDKThirtyTwoBytes BestBlock_block_hash(const struct LDKBestBlock *NONNULL_PTR this_arg); /** - * Frees any resources used by the CResult_PingDecodeErrorZ. + * Returns the best block height. */ -void CResult_PingDecodeErrorZ_free(struct LDKCResult_PingDecodeErrorZ _res); +MUST_USE_RES uint32_t BestBlock_height(const struct LDKBestBlock *NONNULL_PTR this_arg); /** - * Creates a new CResult_PingDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Creates a copy of the AccessError */ -struct LDKCResult_PingDecodeErrorZ CResult_PingDecodeErrorZ_clone(const struct LDKCResult_PingDecodeErrorZ *NONNULL_PTR orig); +enum LDKAccessError AccessError_clone(const enum LDKAccessError *NONNULL_PTR orig); /** - * Creates a new CResult_PongDecodeErrorZ in the success state. + * Utility method to constructs a new UnknownChain-variant AccessError */ -struct LDKCResult_PongDecodeErrorZ CResult_PongDecodeErrorZ_ok(struct LDKPong o); +enum LDKAccessError AccessError_unknown_chain(void); /** - * Creates a new CResult_PongDecodeErrorZ in the error state. + * Utility method to constructs a new UnknownTx-variant AccessError */ -struct LDKCResult_PongDecodeErrorZ CResult_PongDecodeErrorZ_err(struct LDKDecodeError e); +enum LDKAccessError AccessError_unknown_tx(void); /** - * Checks if the given object is currently in the success state + * Calls the free function if one is set */ -bool CResult_PongDecodeErrorZ_is_ok(const struct LDKCResult_PongDecodeErrorZ *NONNULL_PTR o); +void Access_free(struct LDKAccess this_ptr); /** - * Frees any resources used by the CResult_PongDecodeErrorZ. + * Calls the free function if one is set */ -void CResult_PongDecodeErrorZ_free(struct LDKCResult_PongDecodeErrorZ _res); +void Listen_free(struct LDKListen this_ptr); /** - * Creates a new CResult_PongDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Calls the free function if one is set */ -struct LDKCResult_PongDecodeErrorZ CResult_PongDecodeErrorZ_clone(const struct LDKCResult_PongDecodeErrorZ *NONNULL_PTR orig); +void Confirm_free(struct LDKConfirm this_ptr); /** - * Creates a new CResult_UnsignedChannelAnnouncementDecodeErrorZ in the success state. + * Creates a copy of the ChannelMonitorUpdateStatus */ -struct LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(struct LDKUnsignedChannelAnnouncement o); +enum LDKChannelMonitorUpdateStatus ChannelMonitorUpdateStatus_clone(const enum LDKChannelMonitorUpdateStatus *NONNULL_PTR orig); /** - * Creates a new CResult_UnsignedChannelAnnouncementDecodeErrorZ in the error state. + * Utility method to constructs a new Completed-variant ChannelMonitorUpdateStatus */ -struct LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(struct LDKDecodeError e); +enum LDKChannelMonitorUpdateStatus ChannelMonitorUpdateStatus_completed(void); /** - * Checks if the given object is currently in the success state + * Utility method to constructs a new InProgress-variant ChannelMonitorUpdateStatus */ -bool CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(const struct LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR o); +enum LDKChannelMonitorUpdateStatus ChannelMonitorUpdateStatus_in_progress(void); /** - * Frees any resources used by the CResult_UnsignedChannelAnnouncementDecodeErrorZ. + * Utility method to constructs a new PermanentFailure-variant ChannelMonitorUpdateStatus */ -void CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(struct LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res); +enum LDKChannelMonitorUpdateStatus ChannelMonitorUpdateStatus_permanent_failure(void); /** - * Creates a new CResult_UnsignedChannelAnnouncementDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Checks if two ChannelMonitorUpdateStatuss contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -struct LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(const struct LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR orig); +bool ChannelMonitorUpdateStatus_eq(const enum LDKChannelMonitorUpdateStatus *NONNULL_PTR a, const enum LDKChannelMonitorUpdateStatus *NONNULL_PTR b); /** - * Creates a new CResult_ChannelAnnouncementDecodeErrorZ in the success state. + * Calls the free function if one is set */ -struct LDKCResult_ChannelAnnouncementDecodeErrorZ CResult_ChannelAnnouncementDecodeErrorZ_ok(struct LDKChannelAnnouncement o); +void Watch_free(struct LDKWatch this_ptr); /** - * Creates a new CResult_ChannelAnnouncementDecodeErrorZ in the error state. + * Calls the free function if one is set */ -struct LDKCResult_ChannelAnnouncementDecodeErrorZ CResult_ChannelAnnouncementDecodeErrorZ_err(struct LDKDecodeError e); +void Filter_free(struct LDKFilter this_ptr); /** - * Checks if the given object is currently in the success state + * Frees any resources used by the WatchedOutput, if is_owned is set and inner is non-NULL. */ -bool CResult_ChannelAnnouncementDecodeErrorZ_is_ok(const struct LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR o); +void WatchedOutput_free(struct LDKWatchedOutput this_obj); /** - * Frees any resources used by the CResult_ChannelAnnouncementDecodeErrorZ. + * First block where the transaction output may have been spent. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void CResult_ChannelAnnouncementDecodeErrorZ_free(struct LDKCResult_ChannelAnnouncementDecodeErrorZ _res); +struct LDKThirtyTwoBytes WatchedOutput_get_block_hash(const struct LDKWatchedOutput *NONNULL_PTR this_ptr); /** - * Creates a new CResult_ChannelAnnouncementDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * First block where the transaction output may have been spent. + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKCResult_ChannelAnnouncementDecodeErrorZ CResult_ChannelAnnouncementDecodeErrorZ_clone(const struct LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR orig); +void WatchedOutput_set_block_hash(struct LDKWatchedOutput *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Creates a new CResult_UnsignedChannelUpdateDecodeErrorZ in the success state. + * Outpoint identifying the transaction output. */ -struct LDKCResult_UnsignedChannelUpdateDecodeErrorZ CResult_UnsignedChannelUpdateDecodeErrorZ_ok(struct LDKUnsignedChannelUpdate o); +struct LDKOutPoint WatchedOutput_get_outpoint(const struct LDKWatchedOutput *NONNULL_PTR this_ptr); /** - * Creates a new CResult_UnsignedChannelUpdateDecodeErrorZ in the error state. + * Outpoint identifying the transaction output. */ -struct LDKCResult_UnsignedChannelUpdateDecodeErrorZ CResult_UnsignedChannelUpdateDecodeErrorZ_err(struct LDKDecodeError e); +void WatchedOutput_set_outpoint(struct LDKWatchedOutput *NONNULL_PTR this_ptr, struct LDKOutPoint val); /** - * Checks if the given object is currently in the success state + * Spending condition of the transaction output. */ -bool CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(const struct LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR o); +struct LDKu8slice WatchedOutput_get_script_pubkey(const struct LDKWatchedOutput *NONNULL_PTR this_ptr); /** - * Frees any resources used by the CResult_UnsignedChannelUpdateDecodeErrorZ. + * Spending condition of the transaction output. */ -void CResult_UnsignedChannelUpdateDecodeErrorZ_free(struct LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res); +void WatchedOutput_set_script_pubkey(struct LDKWatchedOutput *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val); /** - * Creates a new CResult_UnsignedChannelUpdateDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Constructs a new WatchedOutput given each field */ -struct LDKCResult_UnsignedChannelUpdateDecodeErrorZ CResult_UnsignedChannelUpdateDecodeErrorZ_clone(const struct LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR orig); +MUST_USE_RES struct LDKWatchedOutput WatchedOutput_new(struct LDKThirtyTwoBytes block_hash_arg, struct LDKOutPoint outpoint_arg, struct LDKCVec_u8Z script_pubkey_arg); /** - * Creates a new CResult_ChannelUpdateDecodeErrorZ in the success state. + * Creates a copy of the WatchedOutput */ -struct LDKCResult_ChannelUpdateDecodeErrorZ CResult_ChannelUpdateDecodeErrorZ_ok(struct LDKChannelUpdate o); +struct LDKWatchedOutput WatchedOutput_clone(const struct LDKWatchedOutput *NONNULL_PTR orig); /** - * Creates a new CResult_ChannelUpdateDecodeErrorZ in the error state. + * Checks if two WatchedOutputs contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -struct LDKCResult_ChannelUpdateDecodeErrorZ CResult_ChannelUpdateDecodeErrorZ_err(struct LDKDecodeError e); +bool WatchedOutput_eq(const struct LDKWatchedOutput *NONNULL_PTR a, const struct LDKWatchedOutput *NONNULL_PTR b); /** - * Checks if the given object is currently in the success state + * Checks if two WatchedOutputs contain equal inner contents. */ -bool CResult_ChannelUpdateDecodeErrorZ_is_ok(const struct LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR o); +uint64_t WatchedOutput_hash(const struct LDKWatchedOutput *NONNULL_PTR o); /** - * Frees any resources used by the CResult_ChannelUpdateDecodeErrorZ. + * Calls the free function if one is set */ -void CResult_ChannelUpdateDecodeErrorZ_free(struct LDKCResult_ChannelUpdateDecodeErrorZ _res); +void BroadcasterInterface_free(struct LDKBroadcasterInterface this_ptr); /** - * Creates a new CResult_ChannelUpdateDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Creates a copy of the ConfirmationTarget */ -struct LDKCResult_ChannelUpdateDecodeErrorZ CResult_ChannelUpdateDecodeErrorZ_clone(const struct LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR orig); +enum LDKConfirmationTarget ConfirmationTarget_clone(const enum LDKConfirmationTarget *NONNULL_PTR orig); /** - * Creates a new CResult_ErrorMessageDecodeErrorZ in the success state. + * Utility method to constructs a new Background-variant ConfirmationTarget */ -struct LDKCResult_ErrorMessageDecodeErrorZ CResult_ErrorMessageDecodeErrorZ_ok(struct LDKErrorMessage o); +enum LDKConfirmationTarget ConfirmationTarget_background(void); /** - * Creates a new CResult_ErrorMessageDecodeErrorZ in the error state. + * Utility method to constructs a new Normal-variant ConfirmationTarget */ -struct LDKCResult_ErrorMessageDecodeErrorZ CResult_ErrorMessageDecodeErrorZ_err(struct LDKDecodeError e); +enum LDKConfirmationTarget ConfirmationTarget_normal(void); /** - * Checks if the given object is currently in the success state + * Utility method to constructs a new HighPriority-variant ConfirmationTarget */ -bool CResult_ErrorMessageDecodeErrorZ_is_ok(const struct LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR o); +enum LDKConfirmationTarget ConfirmationTarget_high_priority(void); /** - * Frees any resources used by the CResult_ErrorMessageDecodeErrorZ. + * Checks if two ConfirmationTargets contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -void CResult_ErrorMessageDecodeErrorZ_free(struct LDKCResult_ErrorMessageDecodeErrorZ _res); +bool ConfirmationTarget_eq(const enum LDKConfirmationTarget *NONNULL_PTR a, const enum LDKConfirmationTarget *NONNULL_PTR b); /** - * Creates a new CResult_ErrorMessageDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Calls the free function if one is set */ -struct LDKCResult_ErrorMessageDecodeErrorZ CResult_ErrorMessageDecodeErrorZ_clone(const struct LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR orig); +void FeeEstimator_free(struct LDKFeeEstimator this_ptr); /** - * Creates a new CResult_WarningMessageDecodeErrorZ in the success state. + * Frees any resources used by the MonitorUpdateId, if is_owned is set and inner is non-NULL. */ -struct LDKCResult_WarningMessageDecodeErrorZ CResult_WarningMessageDecodeErrorZ_ok(struct LDKWarningMessage o); +void MonitorUpdateId_free(struct LDKMonitorUpdateId this_obj); /** - * Creates a new CResult_WarningMessageDecodeErrorZ in the error state. + * Creates a copy of the MonitorUpdateId */ -struct LDKCResult_WarningMessageDecodeErrorZ CResult_WarningMessageDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKMonitorUpdateId MonitorUpdateId_clone(const struct LDKMonitorUpdateId *NONNULL_PTR orig); /** - * Checks if the given object is currently in the success state + * Checks if two MonitorUpdateIds contain equal inner contents. */ -bool CResult_WarningMessageDecodeErrorZ_is_ok(const struct LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR o); +uint64_t MonitorUpdateId_hash(const struct LDKMonitorUpdateId *NONNULL_PTR o); /** - * Frees any resources used by the CResult_WarningMessageDecodeErrorZ. + * Checks if two MonitorUpdateIds contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void CResult_WarningMessageDecodeErrorZ_free(struct LDKCResult_WarningMessageDecodeErrorZ _res); +bool MonitorUpdateId_eq(const struct LDKMonitorUpdateId *NONNULL_PTR a, const struct LDKMonitorUpdateId *NONNULL_PTR b); /** - * Creates a new CResult_WarningMessageDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Calls the free function if one is set */ -struct LDKCResult_WarningMessageDecodeErrorZ CResult_WarningMessageDecodeErrorZ_clone(const struct LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR orig); +void Persist_free(struct LDKPersist this_ptr); /** - * Creates a new CResult_UnsignedNodeAnnouncementDecodeErrorZ in the success state. + * Frees any resources used by the LockedChannelMonitor, if is_owned is set and inner is non-NULL. */ -struct LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(struct LDKUnsignedNodeAnnouncement o); +void LockedChannelMonitor_free(struct LDKLockedChannelMonitor this_obj); /** - * Creates a new CResult_UnsignedNodeAnnouncementDecodeErrorZ in the error state. + * Frees any resources used by the ChainMonitor, if is_owned is set and inner is non-NULL. */ -struct LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(struct LDKDecodeError e); +void ChainMonitor_free(struct LDKChainMonitor this_obj); /** - * Checks if the given object is currently in the success state + * Creates a new `ChainMonitor` used to watch on-chain activity pertaining to channels. + * + * When an optional chain source implementing [`chain::Filter`] is provided, the chain monitor + * will call back to it indicating transactions and outputs of interest. This allows clients to + * pre-filter blocks or only fetch blocks matching a compact filter. Otherwise, clients may + * always need to fetch full blocks absent another means for determining which blocks contain + * transactions relevant to the watched channels. */ -bool CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(const struct LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR o); +MUST_USE_RES struct LDKChainMonitor ChainMonitor_new(struct LDKCOption_FilterZ chain_source, struct LDKBroadcasterInterface broadcaster, struct LDKLogger logger, struct LDKFeeEstimator feeest, struct LDKPersist persister); /** - * Frees any resources used by the CResult_UnsignedNodeAnnouncementDecodeErrorZ. + * Gets the balances in the contained [`ChannelMonitor`]s which are claimable on-chain or + * claims which are awaiting confirmation. + * + * Includes the balances from each [`ChannelMonitor`] *except* those included in + * `ignored_channels`, allowing you to filter out balances from channels which are still open + * (and whose balance should likely be pulled from the [`ChannelDetails`]). + * + * See [`ChannelMonitor::get_claimable_balances`] for more details on the exact criteria for + * inclusion in the return value. */ -void CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(struct LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res); +MUST_USE_RES struct LDKCVec_BalanceZ ChainMonitor_get_claimable_balances(const struct LDKChainMonitor *NONNULL_PTR this_arg, struct LDKCVec_ChannelDetailsZ ignored_channels); /** - * Creates a new CResult_UnsignedNodeAnnouncementDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Gets the [`LockedChannelMonitor`] for a given funding outpoint, returning an `Err` if no + * such [`ChannelMonitor`] is currently being monitored for. + * + * Note that the result holds a mutex over our monitor set, and should not be held + * indefinitely. */ -struct LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(const struct LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR orig); +MUST_USE_RES struct LDKCResult_LockedChannelMonitorNoneZ ChainMonitor_get_monitor(const struct LDKChainMonitor *NONNULL_PTR this_arg, struct LDKOutPoint funding_txo); /** - * Creates a new CResult_NodeAnnouncementDecodeErrorZ in the success state. + * Lists the funding outpoint of each [`ChannelMonitor`] being monitored. + * + * Note that [`ChannelMonitor`]s are not removed when a channel is closed as they are always + * monitoring for on-chain state resolutions. */ -struct LDKCResult_NodeAnnouncementDecodeErrorZ CResult_NodeAnnouncementDecodeErrorZ_ok(struct LDKNodeAnnouncement o); +MUST_USE_RES struct LDKCVec_OutPointZ ChainMonitor_list_monitors(const struct LDKChainMonitor *NONNULL_PTR this_arg); /** - * Creates a new CResult_NodeAnnouncementDecodeErrorZ in the error state. + * Indicates the persistence of a [`ChannelMonitor`] has completed after + * [`ChannelMonitorUpdateStatus::InProgress`] was returned from an update operation. + * + * Thus, the anticipated use is, at a high level: + * 1) This [`ChainMonitor`] calls [`Persist::update_persisted_channel`] which stores the + * update to disk and begins updating any remote (e.g. watchtower/backup) copies, + * returning [`ChannelMonitorUpdateStatus::InProgress`], + * 2) once all remote copies are updated, you call this function with the + * `completed_update_id` that completed, and once all pending updates have completed the + * channel will be re-enabled. + * + * Returns an [`APIError::APIMisuseError`] if `funding_txo` does not match any currently + * registered [`ChannelMonitor`]s. */ -struct LDKCResult_NodeAnnouncementDecodeErrorZ CResult_NodeAnnouncementDecodeErrorZ_err(struct LDKDecodeError e); +MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChainMonitor_channel_monitor_updated(const struct LDKChainMonitor *NONNULL_PTR this_arg, struct LDKOutPoint funding_txo, struct LDKMonitorUpdateId completed_update_id); /** - * Checks if the given object is currently in the success state + * Constructs a new Listen which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned Listen must be freed before this_arg is */ -bool CResult_NodeAnnouncementDecodeErrorZ_is_ok(const struct LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR o); +struct LDKListen ChainMonitor_as_Listen(const struct LDKChainMonitor *NONNULL_PTR this_arg); /** - * Frees any resources used by the CResult_NodeAnnouncementDecodeErrorZ. + * Constructs a new Confirm which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned Confirm must be freed before this_arg is */ -void CResult_NodeAnnouncementDecodeErrorZ_free(struct LDKCResult_NodeAnnouncementDecodeErrorZ _res); +struct LDKConfirm ChainMonitor_as_Confirm(const struct LDKChainMonitor *NONNULL_PTR this_arg); /** - * Creates a new CResult_NodeAnnouncementDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Constructs a new Watch which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned Watch must be freed before this_arg is */ -struct LDKCResult_NodeAnnouncementDecodeErrorZ CResult_NodeAnnouncementDecodeErrorZ_clone(const struct LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR orig); +struct LDKWatch ChainMonitor_as_Watch(const struct LDKChainMonitor *NONNULL_PTR this_arg); /** - * Creates a new CResult_QueryShortChannelIdsDecodeErrorZ in the success state. + * Constructs a new EventsProvider which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned EventsProvider must be freed before this_arg is */ -struct LDKCResult_QueryShortChannelIdsDecodeErrorZ CResult_QueryShortChannelIdsDecodeErrorZ_ok(struct LDKQueryShortChannelIds o); +struct LDKEventsProvider ChainMonitor_as_EventsProvider(const struct LDKChainMonitor *NONNULL_PTR this_arg); /** - * Creates a new CResult_QueryShortChannelIdsDecodeErrorZ in the error state. + * Frees any resources used by the ChannelMonitorUpdate, if is_owned is set and inner is non-NULL. */ -struct LDKCResult_QueryShortChannelIdsDecodeErrorZ CResult_QueryShortChannelIdsDecodeErrorZ_err(struct LDKDecodeError e); +void ChannelMonitorUpdate_free(struct LDKChannelMonitorUpdate this_obj); /** - * Checks if the given object is currently in the success state + * The sequence number of this update. Updates *must* be replayed in-order according to this + * sequence number (and updates may panic if they are not). The update_id values are strictly + * increasing and increase by one for each new update, with one exception specified below. + * + * This sequence number is also used to track up to which points updates which returned + * [`ChannelMonitorUpdateStatus::InProgress`] have been applied to all copies of a given + * ChannelMonitor when ChannelManager::channel_monitor_updated is called. + * + * The only instance where update_id values are not strictly increasing is the case where we + * allow post-force-close updates with a special update ID of [`CLOSED_CHANNEL_UPDATE_ID`]. See + * its docs for more details. + * + * [`ChannelMonitorUpdateStatus::InProgress`]: super::ChannelMonitorUpdateStatus::InProgress */ -bool CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(const struct LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR o); +uint64_t ChannelMonitorUpdate_get_update_id(const struct LDKChannelMonitorUpdate *NONNULL_PTR this_ptr); /** - * Frees any resources used by the CResult_QueryShortChannelIdsDecodeErrorZ. + * The sequence number of this update. Updates *must* be replayed in-order according to this + * sequence number (and updates may panic if they are not). The update_id values are strictly + * increasing and increase by one for each new update, with one exception specified below. + * + * This sequence number is also used to track up to which points updates which returned + * [`ChannelMonitorUpdateStatus::InProgress`] have been applied to all copies of a given + * ChannelMonitor when ChannelManager::channel_monitor_updated is called. + * + * The only instance where update_id values are not strictly increasing is the case where we + * allow post-force-close updates with a special update ID of [`CLOSED_CHANNEL_UPDATE_ID`]. See + * its docs for more details. + * + * [`ChannelMonitorUpdateStatus::InProgress`]: super::ChannelMonitorUpdateStatus::InProgress */ -void CResult_QueryShortChannelIdsDecodeErrorZ_free(struct LDKCResult_QueryShortChannelIdsDecodeErrorZ _res); +void ChannelMonitorUpdate_set_update_id(struct LDKChannelMonitorUpdate *NONNULL_PTR this_ptr, uint64_t val); /** - * Creates a new CResult_QueryShortChannelIdsDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Creates a copy of the ChannelMonitorUpdate */ -struct LDKCResult_QueryShortChannelIdsDecodeErrorZ CResult_QueryShortChannelIdsDecodeErrorZ_clone(const struct LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR orig); +struct LDKChannelMonitorUpdate ChannelMonitorUpdate_clone(const struct LDKChannelMonitorUpdate *NONNULL_PTR orig); /** - * Creates a new CResult_ReplyShortChannelIdsEndDecodeErrorZ in the success state. + * Serialize the ChannelMonitorUpdate object into a byte array which can be read by ChannelMonitorUpdate_read */ -struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(struct LDKReplyShortChannelIdsEnd o); +struct LDKCVec_u8Z ChannelMonitorUpdate_write(const struct LDKChannelMonitorUpdate *NONNULL_PTR obj); /** - * Creates a new CResult_ReplyShortChannelIdsEndDecodeErrorZ in the error state. + * Read a ChannelMonitorUpdate from a byte array, created by ChannelMonitorUpdate_write */ -struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_ChannelMonitorUpdateDecodeErrorZ ChannelMonitorUpdate_read(struct LDKu8slice ser); /** - * Checks if the given object is currently in the success state + * Frees any resources used by the MonitorEvent */ -bool CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(const struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR o); +void MonitorEvent_free(struct LDKMonitorEvent this_ptr); /** - * Frees any resources used by the CResult_ReplyShortChannelIdsEndDecodeErrorZ. + * Creates a copy of the MonitorEvent */ -void CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res); +struct LDKMonitorEvent MonitorEvent_clone(const struct LDKMonitorEvent *NONNULL_PTR orig); /** - * Creates a new CResult_ReplyShortChannelIdsEndDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Utility method to constructs a new HTLCEvent-variant MonitorEvent */ -struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(const struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR orig); +struct LDKMonitorEvent MonitorEvent_htlcevent(struct LDKHTLCUpdate a); /** - * Creates a new CResult_QueryChannelRangeDecodeErrorZ in the success state. + * Utility method to constructs a new CommitmentTxConfirmed-variant MonitorEvent */ -struct LDKCResult_QueryChannelRangeDecodeErrorZ CResult_QueryChannelRangeDecodeErrorZ_ok(struct LDKQueryChannelRange o); +struct LDKMonitorEvent MonitorEvent_commitment_tx_confirmed(struct LDKOutPoint a); /** - * Creates a new CResult_QueryChannelRangeDecodeErrorZ in the error state. + * Utility method to constructs a new Completed-variant MonitorEvent */ -struct LDKCResult_QueryChannelRangeDecodeErrorZ CResult_QueryChannelRangeDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKMonitorEvent MonitorEvent_completed(struct LDKOutPoint funding_txo, uint64_t monitor_update_id); /** - * Checks if the given object is currently in the success state + * Utility method to constructs a new UpdateFailed-variant MonitorEvent */ -bool CResult_QueryChannelRangeDecodeErrorZ_is_ok(const struct LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR o); +struct LDKMonitorEvent MonitorEvent_update_failed(struct LDKOutPoint a); /** - * Frees any resources used by the CResult_QueryChannelRangeDecodeErrorZ. + * Checks if two MonitorEvents contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -void CResult_QueryChannelRangeDecodeErrorZ_free(struct LDKCResult_QueryChannelRangeDecodeErrorZ _res); +bool MonitorEvent_eq(const struct LDKMonitorEvent *NONNULL_PTR a, const struct LDKMonitorEvent *NONNULL_PTR b); /** - * Creates a new CResult_QueryChannelRangeDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Serialize the MonitorEvent object into a byte array which can be read by MonitorEvent_read */ -struct LDKCResult_QueryChannelRangeDecodeErrorZ CResult_QueryChannelRangeDecodeErrorZ_clone(const struct LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR orig); +struct LDKCVec_u8Z MonitorEvent_write(const struct LDKMonitorEvent *NONNULL_PTR obj); /** - * Creates a new CResult_ReplyChannelRangeDecodeErrorZ in the success state. + * Read a MonitorEvent from a byte array, created by MonitorEvent_write */ -struct LDKCResult_ReplyChannelRangeDecodeErrorZ CResult_ReplyChannelRangeDecodeErrorZ_ok(struct LDKReplyChannelRange o); +struct LDKCResult_COption_MonitorEventZDecodeErrorZ MonitorEvent_read(struct LDKu8slice ser); /** - * Creates a new CResult_ReplyChannelRangeDecodeErrorZ in the error state. + * Frees any resources used by the HTLCUpdate, if is_owned is set and inner is non-NULL. */ -struct LDKCResult_ReplyChannelRangeDecodeErrorZ CResult_ReplyChannelRangeDecodeErrorZ_err(struct LDKDecodeError e); +void HTLCUpdate_free(struct LDKHTLCUpdate this_obj); /** - * Checks if the given object is currently in the success state + * Creates a copy of the HTLCUpdate */ -bool CResult_ReplyChannelRangeDecodeErrorZ_is_ok(const struct LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR o); +struct LDKHTLCUpdate HTLCUpdate_clone(const struct LDKHTLCUpdate *NONNULL_PTR orig); /** - * Frees any resources used by the CResult_ReplyChannelRangeDecodeErrorZ. + * Checks if two HTLCUpdates contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void CResult_ReplyChannelRangeDecodeErrorZ_free(struct LDKCResult_ReplyChannelRangeDecodeErrorZ _res); +bool HTLCUpdate_eq(const struct LDKHTLCUpdate *NONNULL_PTR a, const struct LDKHTLCUpdate *NONNULL_PTR b); /** - * Creates a new CResult_ReplyChannelRangeDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Serialize the HTLCUpdate object into a byte array which can be read by HTLCUpdate_read */ -struct LDKCResult_ReplyChannelRangeDecodeErrorZ CResult_ReplyChannelRangeDecodeErrorZ_clone(const struct LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR orig); +struct LDKCVec_u8Z HTLCUpdate_write(const struct LDKHTLCUpdate *NONNULL_PTR obj); /** - * Creates a new CResult_GossipTimestampFilterDecodeErrorZ in the success state. + * Read a HTLCUpdate from a byte array, created by HTLCUpdate_write */ -struct LDKCResult_GossipTimestampFilterDecodeErrorZ CResult_GossipTimestampFilterDecodeErrorZ_ok(struct LDKGossipTimestampFilter o); +struct LDKCResult_HTLCUpdateDecodeErrorZ HTLCUpdate_read(struct LDKu8slice ser); /** - * Creates a new CResult_GossipTimestampFilterDecodeErrorZ in the error state. + * Frees any resources used by the Balance */ -struct LDKCResult_GossipTimestampFilterDecodeErrorZ CResult_GossipTimestampFilterDecodeErrorZ_err(struct LDKDecodeError e); +void Balance_free(struct LDKBalance this_ptr); /** - * Checks if the given object is currently in the success state + * Creates a copy of the Balance */ -bool CResult_GossipTimestampFilterDecodeErrorZ_is_ok(const struct LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR o); +struct LDKBalance Balance_clone(const struct LDKBalance *NONNULL_PTR orig); /** - * Frees any resources used by the CResult_GossipTimestampFilterDecodeErrorZ. + * Utility method to constructs a new ClaimableOnChannelClose-variant Balance */ -void CResult_GossipTimestampFilterDecodeErrorZ_free(struct LDKCResult_GossipTimestampFilterDecodeErrorZ _res); +struct LDKBalance Balance_claimable_on_channel_close(uint64_t claimable_amount_satoshis); /** - * Creates a new CResult_GossipTimestampFilterDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Utility method to constructs a new ClaimableAwaitingConfirmations-variant Balance */ -struct LDKCResult_GossipTimestampFilterDecodeErrorZ CResult_GossipTimestampFilterDecodeErrorZ_clone(const struct LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR orig); +struct LDKBalance Balance_claimable_awaiting_confirmations(uint64_t claimable_amount_satoshis, uint32_t confirmation_height); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Utility method to constructs a new ContentiousClaimable-variant Balance */ -void CVec_PhantomRouteHintsZ_free(struct LDKCVec_PhantomRouteHintsZ _res); +struct LDKBalance Balance_contentious_claimable(uint64_t claimable_amount_satoshis, uint32_t timeout_height); /** - * Creates a new CResult_InvoiceSignOrCreationErrorZ in the success state. + * Utility method to constructs a new MaybeTimeoutClaimableHTLC-variant Balance */ -struct LDKCResult_InvoiceSignOrCreationErrorZ CResult_InvoiceSignOrCreationErrorZ_ok(struct LDKInvoice o); +struct LDKBalance Balance_maybe_timeout_claimable_htlc(uint64_t claimable_amount_satoshis, uint32_t claimable_height); /** - * Creates a new CResult_InvoiceSignOrCreationErrorZ in the error state. + * Utility method to constructs a new MaybePreimageClaimableHTLC-variant Balance */ -struct LDKCResult_InvoiceSignOrCreationErrorZ CResult_InvoiceSignOrCreationErrorZ_err(struct LDKSignOrCreationError e); +struct LDKBalance Balance_maybe_preimage_claimable_htlc(uint64_t claimable_amount_satoshis, uint32_t expiry_height); /** - * Checks if the given object is currently in the success state + * Utility method to constructs a new CounterpartyRevokedOutputClaimable-variant Balance */ -bool CResult_InvoiceSignOrCreationErrorZ_is_ok(const struct LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR o); +struct LDKBalance Balance_counterparty_revoked_output_claimable(uint64_t claimable_amount_satoshis); /** - * Frees any resources used by the CResult_InvoiceSignOrCreationErrorZ. + * Checks if two Balances contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -void CResult_InvoiceSignOrCreationErrorZ_free(struct LDKCResult_InvoiceSignOrCreationErrorZ _res); +bool Balance_eq(const struct LDKBalance *NONNULL_PTR a, const struct LDKBalance *NONNULL_PTR b); /** - * Creates a new CResult_InvoiceSignOrCreationErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Frees any resources used by the ChannelMonitor, if is_owned is set and inner is non-NULL. */ -struct LDKCResult_InvoiceSignOrCreationErrorZ CResult_InvoiceSignOrCreationErrorZ_clone(const struct LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR orig); +void ChannelMonitor_free(struct LDKChannelMonitor this_obj); /** - * Constructs a new COption_FilterZ containing a crate::lightning::chain::Filter + * Serialize the ChannelMonitor object into a byte array which can be read by ChannelMonitor_read */ -struct LDKCOption_FilterZ COption_FilterZ_some(struct LDKFilter o); +struct LDKCVec_u8Z ChannelMonitor_write(const struct LDKChannelMonitor *NONNULL_PTR obj); /** - * Constructs a new COption_FilterZ containing nothing + * Updates a ChannelMonitor on the basis of some new information provided by the Channel + * itself. + * + * panics if the given update is not the next update by update_id. */ -struct LDKCOption_FilterZ COption_FilterZ_none(void); +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, struct LDKFeeEstimator fee_estimator, const struct LDKLogger *NONNULL_PTR logger); /** - * Frees any resources associated with the crate::lightning::chain::Filter, if we are in the Some state + * Gets the update_id from the latest ChannelMonitorUpdate which was applied to this + * ChannelMonitor. */ -void COption_FilterZ_free(struct LDKCOption_FilterZ _res); +MUST_USE_RES uint64_t ChannelMonitor_get_latest_update_id(const struct LDKChannelMonitor *NONNULL_PTR this_arg); /** - * Creates a new CResult_LockedChannelMonitorNoneZ in the success state. + * Gets the funding transaction outpoint of the channel this ChannelMonitor is monitoring for. */ -struct LDKCResult_LockedChannelMonitorNoneZ CResult_LockedChannelMonitorNoneZ_ok(struct LDKLockedChannelMonitor o); +MUST_USE_RES struct LDKC2Tuple_OutPointScriptZ ChannelMonitor_get_funding_txo(const struct LDKChannelMonitor *NONNULL_PTR this_arg); /** - * Creates a new CResult_LockedChannelMonitorNoneZ in the error state. + * Gets a list of txids, with their output scripts (in the order they appear in the + * transaction), which we must learn about spends of via block_connected(). */ -struct LDKCResult_LockedChannelMonitorNoneZ CResult_LockedChannelMonitorNoneZ_err(void); +MUST_USE_RES struct LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ChannelMonitor_get_outputs_to_watch(const struct LDKChannelMonitor *NONNULL_PTR this_arg); /** - * Checks if the given object is currently in the success state + * Loads the funding txo and outputs to watch into the given `chain::Filter` by repeatedly + * calling `chain::Filter::register_output` and `chain::Filter::register_tx` until all outputs + * have been registered. */ -bool CResult_LockedChannelMonitorNoneZ_is_ok(const struct LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR o); +void ChannelMonitor_load_outputs_to_watch(const struct LDKChannelMonitor *NONNULL_PTR this_arg, const struct LDKFilter *NONNULL_PTR filter); /** - * Frees any resources used by the CResult_LockedChannelMonitorNoneZ. + * Get the list of HTLCs who's status has been updated on chain. This should be called by + * ChannelManager via [`chain::Watch::release_pending_monitor_events`]. */ -void CResult_LockedChannelMonitorNoneZ_free(struct LDKCResult_LockedChannelMonitorNoneZ _res); +MUST_USE_RES struct LDKCVec_MonitorEventZ ChannelMonitor_get_and_clear_pending_monitor_events(const struct LDKChannelMonitor *NONNULL_PTR this_arg); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Gets the list of pending events which were generated by previous actions, clearing the list + * in the process. + * + * This is called by ChainMonitor::get_and_clear_pending_events() and is equivalent to + * EventsProvider::get_and_clear_pending_events() except that it requires &mut self as we do + * no internal locking in ChannelMonitors. */ -void CVec_OutPointZ_free(struct LDKCVec_OutPointZ _res); +MUST_USE_RES struct LDKCVec_EventZ ChannelMonitor_get_and_clear_pending_events(const struct LDKChannelMonitor *NONNULL_PTR this_arg); /** - * Frees any resources used by the PaymentPurpose + * Gets the `node_id` of the counterparty for this channel. + * + * Will be `None` for channels constructed on LDK versions prior to 0.0.110 and always `Some` + * otherwise. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void PaymentPurpose_free(struct LDKPaymentPurpose this_ptr); +MUST_USE_RES struct LDKPublicKey ChannelMonitor_get_counterparty_node_id(const struct LDKChannelMonitor *NONNULL_PTR this_arg); /** - * Creates a copy of the PaymentPurpose + * Used by ChannelManager deserialization to broadcast the latest holder state if its copy of + * the Channel was out-of-date. + * + * You may also use this to broadcast the latest local commitment transaction, either because + * a monitor update failed with [`ChannelMonitorUpdateStatus::PermanentFailure`] or because we've + * fallen behind (i.e. we've received proof that our counterparty side knows a revocation + * secret we gave them that they shouldn't know). + * + * Broadcasting these transactions in the second case is UNSAFE, as they allow counterparty + * side to punish you. Nevertheless you may want to broadcast them if counterparty doesn't + * close channel with their commitment transaction after a substantial amount of time. Best + * may be to contact the other node operator out-of-band to coordinate other options available + * to you. In any-case, the choice is up to you. + * + * [`ChannelMonitorUpdateStatus::PermanentFailure`]: super::ChannelMonitorUpdateStatus::PermanentFailure */ -struct LDKPaymentPurpose PaymentPurpose_clone(const struct LDKPaymentPurpose *NONNULL_PTR orig); +MUST_USE_RES struct LDKCVec_TransactionZ ChannelMonitor_get_latest_holder_commitment_txn(const struct LDKChannelMonitor *NONNULL_PTR this_arg, const struct LDKLogger *NONNULL_PTR logger); /** - * Utility method to constructs a new InvoicePayment-variant PaymentPurpose + * Processes transactions in a newly connected block, which may result in any of the following: + * - update the monitor's state against resolved HTLCs + * - punish the counterparty in the case of seeing a revoked commitment transaction + * - force close the channel and claim/timeout incoming/outgoing HTLCs if near expiration + * - detect settled outputs for later spending + * - schedule and bump any in-flight claims + * + * Returns any new outputs to watch from `txdata`; after called, these are also included in + * [`get_outputs_to_watch`]. + * + * [`get_outputs_to_watch`]: #method.get_outputs_to_watch */ -struct LDKPaymentPurpose PaymentPurpose_invoice_payment(struct LDKThirtyTwoBytes payment_preimage, struct LDKThirtyTwoBytes payment_secret); +MUST_USE_RES struct LDKCVec_TransactionOutputsZ ChannelMonitor_block_connected(const struct LDKChannelMonitor *NONNULL_PTR this_arg, const uint8_t (*header)[80], struct LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height, struct LDKBroadcasterInterface broadcaster, struct LDKFeeEstimator fee_estimator, struct LDKLogger logger); /** - * Utility method to constructs a new SpontaneousPayment-variant PaymentPurpose + * Determines if the disconnected block contained any transactions of interest and updates + * appropriately. */ -struct LDKPaymentPurpose PaymentPurpose_spontaneous_payment(struct LDKThirtyTwoBytes a); +void ChannelMonitor_block_disconnected(const struct LDKChannelMonitor *NONNULL_PTR this_arg, const uint8_t (*header)[80], uint32_t height, struct LDKBroadcasterInterface broadcaster, struct LDKFeeEstimator fee_estimator, struct LDKLogger logger); /** - * Frees any resources used by the ClosureReason + * Processes transactions confirmed in a block with the given header and height, returning new + * outputs to watch. See [`block_connected`] for details. + * + * Used instead of [`block_connected`] by clients that are notified of transactions rather than + * blocks. See [`chain::Confirm`] for calling expectations. + * + * [`block_connected`]: Self::block_connected */ -void ClosureReason_free(struct LDKClosureReason this_ptr); +MUST_USE_RES struct LDKCVec_TransactionOutputsZ ChannelMonitor_transactions_confirmed(const struct LDKChannelMonitor *NONNULL_PTR this_arg, const uint8_t (*header)[80], struct LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height, struct LDKBroadcasterInterface broadcaster, struct LDKFeeEstimator fee_estimator, struct LDKLogger logger); /** - * Creates a copy of the ClosureReason + * Processes a transaction that was reorganized out of the chain. + * + * Used instead of [`block_disconnected`] by clients that are notified of transactions rather + * than blocks. See [`chain::Confirm`] for calling expectations. + * + * [`block_disconnected`]: Self::block_disconnected */ -struct LDKClosureReason ClosureReason_clone(const struct LDKClosureReason *NONNULL_PTR orig); +void ChannelMonitor_transaction_unconfirmed(const struct LDKChannelMonitor *NONNULL_PTR this_arg, const uint8_t (*txid)[32], struct LDKBroadcasterInterface broadcaster, struct LDKFeeEstimator fee_estimator, struct LDKLogger logger); /** - * Utility method to constructs a new CounterpartyForceClosed-variant ClosureReason + * Updates the monitor with the current best chain tip, returning new outputs to watch. See + * [`block_connected`] for details. + * + * Used instead of [`block_connected`] by clients that are notified of transactions rather than + * blocks. See [`chain::Confirm`] for calling expectations. + * + * [`block_connected`]: Self::block_connected */ -struct LDKClosureReason ClosureReason_counterparty_force_closed(struct LDKStr peer_msg); +MUST_USE_RES struct LDKCVec_TransactionOutputsZ ChannelMonitor_best_block_updated(const struct LDKChannelMonitor *NONNULL_PTR this_arg, const uint8_t (*header)[80], uint32_t height, struct LDKBroadcasterInterface broadcaster, struct LDKFeeEstimator fee_estimator, struct LDKLogger logger); /** - * Utility method to constructs a new HolderForceClosed-variant ClosureReason + * Returns the set of txids that should be monitored for re-organization out of the chain. */ -struct LDKClosureReason ClosureReason_holder_force_closed(void); +MUST_USE_RES struct LDKCVec_TxidZ ChannelMonitor_get_relevant_txids(const struct LDKChannelMonitor *NONNULL_PTR this_arg); /** - * Utility method to constructs a new CooperativeClosure-variant ClosureReason + * Gets the latest best block which was connected either via the [`chain::Listen`] or + * [`chain::Confirm`] interfaces. */ -struct LDKClosureReason ClosureReason_cooperative_closure(void); +MUST_USE_RES struct LDKBestBlock ChannelMonitor_current_best_block(const struct LDKChannelMonitor *NONNULL_PTR this_arg); /** - * Utility method to constructs a new CommitmentTxConfirmed-variant ClosureReason + * Gets the balances in this channel which are either claimable by us if we were to + * force-close the channel now or which are claimable on-chain (possibly awaiting + * confirmation). + * + * Any balances in the channel which are available on-chain (excluding on-chain fees) are + * included here until an [`Event::SpendableOutputs`] event has been generated for the + * balance, or until our counterparty has claimed the balance and accrued several + * confirmations on the claim transaction. + * + * Note that for `ChannelMonitors` which track a channel which went on-chain with versions of + * LDK prior to 0.0.111, balances may not be fully captured if our counterparty broadcasted + * a revoked state. + * + * See [`Balance`] for additional details on the types of claimable balances which + * may be returned here and their meanings. */ -struct LDKClosureReason ClosureReason_commitment_tx_confirmed(void); +MUST_USE_RES struct LDKCVec_BalanceZ ChannelMonitor_get_claimable_balances(const struct LDKChannelMonitor *NONNULL_PTR this_arg); /** - * Utility method to constructs a new FundingTimedOut-variant ClosureReason + * Read a C2Tuple_BlockHashChannelMonitorZ from a byte array, created by C2Tuple_BlockHashChannelMonitorZ_write */ -struct LDKClosureReason ClosureReason_funding_timed_out(void); +struct LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ C2Tuple_BlockHashChannelMonitorZ_read(struct LDKu8slice ser, const struct LDKKeysInterface *NONNULL_PTR arg); /** - * Utility method to constructs a new ProcessingError-variant ClosureReason + * Frees any resources used by the OutPoint, if is_owned is set and inner is non-NULL. */ -struct LDKClosureReason ClosureReason_processing_error(struct LDKStr err); +void OutPoint_free(struct LDKOutPoint this_obj); /** - * Utility method to constructs a new DisconnectedPeer-variant ClosureReason + * The referenced transaction's txid. */ -struct LDKClosureReason ClosureReason_disconnected_peer(void); +const uint8_t (*OutPoint_get_txid(const struct LDKOutPoint *NONNULL_PTR this_ptr))[32]; /** - * Utility method to constructs a new OutdatedChannelManager-variant ClosureReason + * The referenced transaction's txid. */ -struct LDKClosureReason ClosureReason_outdated_channel_manager(void); +void OutPoint_set_txid(struct LDKOutPoint *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Serialize the ClosureReason object into a byte array which can be read by ClosureReason_read + * The index of the referenced output in its transaction's vout. */ -struct LDKCVec_u8Z ClosureReason_write(const struct LDKClosureReason *NONNULL_PTR obj); +uint16_t OutPoint_get_index(const struct LDKOutPoint *NONNULL_PTR this_ptr); /** - * Read a ClosureReason from a byte array, created by ClosureReason_write + * The index of the referenced output in its transaction's vout. */ -struct LDKCResult_COption_ClosureReasonZDecodeErrorZ ClosureReason_read(struct LDKu8slice ser); +void OutPoint_set_index(struct LDKOutPoint *NONNULL_PTR this_ptr, uint16_t val); /** - * Frees any resources used by the Event + * Constructs a new OutPoint given each field */ -void Event_free(struct LDKEvent this_ptr); +MUST_USE_RES struct LDKOutPoint OutPoint_new(struct LDKThirtyTwoBytes txid_arg, uint16_t index_arg); /** - * Creates a copy of the Event + * Creates a copy of the OutPoint */ -struct LDKEvent Event_clone(const struct LDKEvent *NONNULL_PTR orig); +struct LDKOutPoint OutPoint_clone(const struct LDKOutPoint *NONNULL_PTR orig); /** - * Utility method to constructs a new FundingGenerationReady-variant Event + * Checks if two OutPoints contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -struct LDKEvent Event_funding_generation_ready(struct LDKThirtyTwoBytes temporary_channel_id, uint64_t channel_value_satoshis, struct LDKCVec_u8Z output_script, uint64_t user_channel_id); +bool OutPoint_eq(const struct LDKOutPoint *NONNULL_PTR a, const struct LDKOutPoint *NONNULL_PTR b); /** - * Utility method to constructs a new PaymentReceived-variant Event + * Checks if two OutPoints contain equal inner contents. */ -struct LDKEvent Event_payment_received(struct LDKThirtyTwoBytes payment_hash, uint64_t amt, struct LDKPaymentPurpose purpose); +uint64_t OutPoint_hash(const struct LDKOutPoint *NONNULL_PTR o); /** - * Utility method to constructs a new PaymentSent-variant Event + * Convert an `OutPoint` to a lightning channel id. */ -struct LDKEvent Event_payment_sent(struct LDKThirtyTwoBytes payment_id, struct LDKThirtyTwoBytes payment_preimage, struct LDKThirtyTwoBytes payment_hash, struct LDKCOption_u64Z fee_paid_msat); +MUST_USE_RES struct LDKThirtyTwoBytes OutPoint_to_channel_id(const struct LDKOutPoint *NONNULL_PTR this_arg); /** - * Utility method to constructs a new PaymentPathFailed-variant Event + * Serialize the OutPoint object into a byte array which can be read by OutPoint_read */ -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); +struct LDKCVec_u8Z OutPoint_write(const struct LDKOutPoint *NONNULL_PTR obj); /** - * Utility method to constructs a new PaymentFailed-variant Event + * Read a OutPoint from a byte array, created by OutPoint_write */ -struct LDKEvent Event_payment_failed(struct LDKThirtyTwoBytes payment_id, struct LDKThirtyTwoBytes payment_hash); +struct LDKCResult_OutPointDecodeErrorZ OutPoint_read(struct LDKu8slice ser); /** - * Utility method to constructs a new PendingHTLCsForwardable-variant Event + * Frees any resources used by the DelayedPaymentOutputDescriptor, if is_owned is set and inner is non-NULL. */ -struct LDKEvent Event_pending_htlcs_forwardable(uint64_t time_forwardable); +void DelayedPaymentOutputDescriptor_free(struct LDKDelayedPaymentOutputDescriptor this_obj); /** - * Utility method to constructs a new SpendableOutputs-variant Event + * The outpoint which is spendable */ -struct LDKEvent Event_spendable_outputs(struct LDKCVec_SpendableOutputDescriptorZ outputs); +struct LDKOutPoint DelayedPaymentOutputDescriptor_get_outpoint(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr); /** - * Utility method to constructs a new PaymentForwarded-variant Event + * The outpoint which is spendable */ -struct LDKEvent Event_payment_forwarded(struct LDKCOption_u64Z fee_earned_msat, bool claim_from_onchain_tx); +void DelayedPaymentOutputDescriptor_set_outpoint(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKOutPoint val); /** - * Utility method to constructs a new ChannelClosed-variant Event + * Per commitment point to derive delayed_payment_key by key holder */ -struct LDKEvent Event_channel_closed(struct LDKThirtyTwoBytes channel_id, uint64_t user_channel_id, struct LDKClosureReason reason); +struct LDKPublicKey DelayedPaymentOutputDescriptor_get_per_commitment_point(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr); /** - * Utility method to constructs a new DiscardFunding-variant Event + * Per commitment point to derive delayed_payment_key by key holder */ -struct LDKEvent Event_discard_funding(struct LDKThirtyTwoBytes channel_id, struct LDKTransaction transaction); +void DelayedPaymentOutputDescriptor_set_per_commitment_point(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Utility method to constructs a new PaymentPathSuccessful-variant Event + * The nSequence value which must be set in the spending input to satisfy the OP_CSV in + * the witness_script. */ -struct LDKEvent Event_payment_path_successful(struct LDKThirtyTwoBytes payment_id, struct LDKThirtyTwoBytes payment_hash, struct LDKCVec_RouteHopZ path); +uint16_t DelayedPaymentOutputDescriptor_get_to_self_delay(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr); /** - * Utility method to constructs a new OpenChannelRequest-variant Event + * The nSequence value which must be set in the spending input to satisfy the OP_CSV in + * the witness_script. */ -struct LDKEvent Event_open_channel_request(struct LDKThirtyTwoBytes temporary_channel_id, struct LDKPublicKey counterparty_node_id, uint64_t funding_satoshis, uint64_t push_msat); +void DelayedPaymentOutputDescriptor_set_to_self_delay(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, uint16_t val); /** - * Serialize the Event object into a byte array which can be read by Event_read + * The output which is referenced by the given outpoint + * + * Returns a copy of the field. */ -struct LDKCVec_u8Z Event_write(const struct LDKEvent *NONNULL_PTR obj); +struct LDKTxOut DelayedPaymentOutputDescriptor_get_output(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr); /** - * Read a Event from a byte array, created by Event_write + * The output which is referenced by the given outpoint */ -struct LDKCResult_COption_EventZDecodeErrorZ Event_read(struct LDKu8slice ser); +void DelayedPaymentOutputDescriptor_set_output(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKTxOut val); /** - * Frees any resources used by the MessageSendEvent + * The revocation point specific to the commitment transaction which was broadcast. Used to + * derive the witnessScript for this output. */ -void MessageSendEvent_free(struct LDKMessageSendEvent this_ptr); +struct LDKPublicKey DelayedPaymentOutputDescriptor_get_revocation_pubkey(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr); /** - * Creates a copy of the MessageSendEvent + * The revocation point specific to the commitment transaction which was broadcast. Used to + * derive the witnessScript for this output. */ -struct LDKMessageSendEvent MessageSendEvent_clone(const struct LDKMessageSendEvent *NONNULL_PTR orig); +void DelayedPaymentOutputDescriptor_set_revocation_pubkey(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Utility method to constructs a new SendAcceptChannel-variant MessageSendEvent + * Arbitrary identification information returned by a call to + * `Sign::channel_keys_id()`. This may be useful in re-deriving keys used in + * the channel to spend the output. */ -struct LDKMessageSendEvent MessageSendEvent_send_accept_channel(struct LDKPublicKey node_id, struct LDKAcceptChannel msg); +const uint8_t (*DelayedPaymentOutputDescriptor_get_channel_keys_id(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr))[32]; /** - * Utility method to constructs a new SendOpenChannel-variant MessageSendEvent + * Arbitrary identification information returned by a call to + * `Sign::channel_keys_id()`. This may be useful in re-deriving keys used in + * the channel to spend the output. */ -struct LDKMessageSendEvent MessageSendEvent_send_open_channel(struct LDKPublicKey node_id, struct LDKOpenChannel msg); +void DelayedPaymentOutputDescriptor_set_channel_keys_id(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Utility method to constructs a new SendFundingCreated-variant MessageSendEvent + * The value of the channel which this output originated from, possibly indirectly. */ -struct LDKMessageSendEvent MessageSendEvent_send_funding_created(struct LDKPublicKey node_id, struct LDKFundingCreated msg); +uint64_t DelayedPaymentOutputDescriptor_get_channel_value_satoshis(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr); /** - * Utility method to constructs a new SendFundingSigned-variant MessageSendEvent + * The value of the channel which this output originated from, possibly indirectly. */ -struct LDKMessageSendEvent MessageSendEvent_send_funding_signed(struct LDKPublicKey node_id, struct LDKFundingSigned msg); +void DelayedPaymentOutputDescriptor_set_channel_value_satoshis(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, uint64_t val); /** - * Utility method to constructs a new SendFundingLocked-variant MessageSendEvent + * Constructs a new DelayedPaymentOutputDescriptor given each field */ -struct LDKMessageSendEvent MessageSendEvent_send_funding_locked(struct LDKPublicKey node_id, struct LDKFundingLocked msg); +MUST_USE_RES struct LDKDelayedPaymentOutputDescriptor DelayedPaymentOutputDescriptor_new(struct LDKOutPoint outpoint_arg, struct LDKPublicKey per_commitment_point_arg, uint16_t to_self_delay_arg, struct LDKTxOut output_arg, struct LDKPublicKey revocation_pubkey_arg, struct LDKThirtyTwoBytes channel_keys_id_arg, uint64_t channel_value_satoshis_arg); /** - * Utility method to constructs a new SendAnnouncementSignatures-variant MessageSendEvent + * Creates a copy of the DelayedPaymentOutputDescriptor */ -struct LDKMessageSendEvent MessageSendEvent_send_announcement_signatures(struct LDKPublicKey node_id, struct LDKAnnouncementSignatures msg); +struct LDKDelayedPaymentOutputDescriptor DelayedPaymentOutputDescriptor_clone(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR orig); /** - * Utility method to constructs a new UpdateHTLCs-variant MessageSendEvent + * Checks if two DelayedPaymentOutputDescriptors contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -struct LDKMessageSendEvent MessageSendEvent_update_htlcs(struct LDKPublicKey node_id, struct LDKCommitmentUpdate updates); +bool DelayedPaymentOutputDescriptor_eq(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR a, const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR b); /** - * Utility method to constructs a new SendRevokeAndACK-variant MessageSendEvent + * Serialize the DelayedPaymentOutputDescriptor object into a byte array which can be read by DelayedPaymentOutputDescriptor_read */ -struct LDKMessageSendEvent MessageSendEvent_send_revoke_and_ack(struct LDKPublicKey node_id, struct LDKRevokeAndACK msg); +struct LDKCVec_u8Z DelayedPaymentOutputDescriptor_write(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR obj); /** - * Utility method to constructs a new SendClosingSigned-variant MessageSendEvent + * Read a DelayedPaymentOutputDescriptor from a byte array, created by DelayedPaymentOutputDescriptor_write */ -struct LDKMessageSendEvent MessageSendEvent_send_closing_signed(struct LDKPublicKey node_id, struct LDKClosingSigned msg); +struct LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ DelayedPaymentOutputDescriptor_read(struct LDKu8slice ser); /** - * Utility method to constructs a new SendShutdown-variant MessageSendEvent + * Frees any resources used by the StaticPaymentOutputDescriptor, if is_owned is set and inner is non-NULL. */ -struct LDKMessageSendEvent MessageSendEvent_send_shutdown(struct LDKPublicKey node_id, struct LDKShutdown msg); +void StaticPaymentOutputDescriptor_free(struct LDKStaticPaymentOutputDescriptor this_obj); /** - * Utility method to constructs a new SendChannelReestablish-variant MessageSendEvent + * The outpoint which is spendable */ -struct LDKMessageSendEvent MessageSendEvent_send_channel_reestablish(struct LDKPublicKey node_id, struct LDKChannelReestablish msg); +struct LDKOutPoint StaticPaymentOutputDescriptor_get_outpoint(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr); /** - * Utility method to constructs a new BroadcastChannelAnnouncement-variant MessageSendEvent + * The outpoint which is spendable */ -struct LDKMessageSendEvent MessageSendEvent_broadcast_channel_announcement(struct LDKChannelAnnouncement msg, struct LDKChannelUpdate update_msg); +void StaticPaymentOutputDescriptor_set_outpoint(struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKOutPoint val); /** - * Utility method to constructs a new BroadcastNodeAnnouncement-variant MessageSendEvent + * The output which is referenced by the given outpoint + * + * Returns a copy of the field. */ -struct LDKMessageSendEvent MessageSendEvent_broadcast_node_announcement(struct LDKNodeAnnouncement msg); +struct LDKTxOut StaticPaymentOutputDescriptor_get_output(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr); /** - * Utility method to constructs a new BroadcastChannelUpdate-variant MessageSendEvent + * The output which is referenced by the given outpoint */ -struct LDKMessageSendEvent MessageSendEvent_broadcast_channel_update(struct LDKChannelUpdate msg); +void StaticPaymentOutputDescriptor_set_output(struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKTxOut val); /** - * Utility method to constructs a new SendChannelUpdate-variant MessageSendEvent + * Arbitrary identification information returned by a call to + * `Sign::channel_keys_id()`. This may be useful in re-deriving keys used in + * the channel to spend the output. */ -struct LDKMessageSendEvent MessageSendEvent_send_channel_update(struct LDKPublicKey node_id, struct LDKChannelUpdate msg); +const uint8_t (*StaticPaymentOutputDescriptor_get_channel_keys_id(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr))[32]; /** - * Utility method to constructs a new HandleError-variant MessageSendEvent + * Arbitrary identification information returned by a call to + * `Sign::channel_keys_id()`. This may be useful in re-deriving keys used in + * the channel to spend the output. */ -struct LDKMessageSendEvent MessageSendEvent_handle_error(struct LDKPublicKey node_id, struct LDKErrorAction action); +void StaticPaymentOutputDescriptor_set_channel_keys_id(struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Utility method to constructs a new SendChannelRangeQuery-variant MessageSendEvent + * The value of the channel which this transactions spends. */ -struct LDKMessageSendEvent MessageSendEvent_send_channel_range_query(struct LDKPublicKey node_id, struct LDKQueryChannelRange msg); +uint64_t StaticPaymentOutputDescriptor_get_channel_value_satoshis(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr); /** - * Utility method to constructs a new SendShortIdsQuery-variant MessageSendEvent + * The value of the channel which this transactions spends. */ -struct LDKMessageSendEvent MessageSendEvent_send_short_ids_query(struct LDKPublicKey node_id, struct LDKQueryShortChannelIds msg); +void StaticPaymentOutputDescriptor_set_channel_value_satoshis(struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr, uint64_t val); /** - * Utility method to constructs a new SendReplyChannelRange-variant MessageSendEvent + * Constructs a new StaticPaymentOutputDescriptor given each field */ -struct LDKMessageSendEvent MessageSendEvent_send_reply_channel_range(struct LDKPublicKey node_id, struct LDKReplyChannelRange msg); +MUST_USE_RES struct LDKStaticPaymentOutputDescriptor StaticPaymentOutputDescriptor_new(struct LDKOutPoint outpoint_arg, struct LDKTxOut output_arg, struct LDKThirtyTwoBytes channel_keys_id_arg, uint64_t channel_value_satoshis_arg); /** - * Calls the free function if one is set + * Creates a copy of the StaticPaymentOutputDescriptor */ -void MessageSendEventsProvider_free(struct LDKMessageSendEventsProvider this_ptr); +struct LDKStaticPaymentOutputDescriptor StaticPaymentOutputDescriptor_clone(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR orig); /** - * Calls the free function if one is set + * Checks if two StaticPaymentOutputDescriptors contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void EventsProvider_free(struct LDKEventsProvider this_ptr); +bool StaticPaymentOutputDescriptor_eq(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR a, const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR b); /** - * Calls the free function if one is set + * Serialize the StaticPaymentOutputDescriptor object into a byte array which can be read by StaticPaymentOutputDescriptor_read */ -void EventHandler_free(struct LDKEventHandler this_ptr); +struct LDKCVec_u8Z StaticPaymentOutputDescriptor_write(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR obj); /** - * Frees any resources used by the APIError + * Read a StaticPaymentOutputDescriptor from a byte array, created by StaticPaymentOutputDescriptor_write */ -void APIError_free(struct LDKAPIError this_ptr); +struct LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ StaticPaymentOutputDescriptor_read(struct LDKu8slice ser); /** - * Creates a copy of the APIError + * Frees any resources used by the SpendableOutputDescriptor */ -struct LDKAPIError APIError_clone(const struct LDKAPIError *NONNULL_PTR orig); +void SpendableOutputDescriptor_free(struct LDKSpendableOutputDescriptor this_ptr); /** - * Utility method to constructs a new APIMisuseError-variant APIError + * Creates a copy of the SpendableOutputDescriptor */ -struct LDKAPIError APIError_apimisuse_error(struct LDKStr err); +struct LDKSpendableOutputDescriptor SpendableOutputDescriptor_clone(const struct LDKSpendableOutputDescriptor *NONNULL_PTR orig); /** - * Utility method to constructs a new FeeRateTooHigh-variant APIError + * Utility method to constructs a new StaticOutput-variant SpendableOutputDescriptor */ -struct LDKAPIError APIError_fee_rate_too_high(struct LDKStr err, uint32_t feerate); +struct LDKSpendableOutputDescriptor SpendableOutputDescriptor_static_output(struct LDKOutPoint outpoint, struct LDKTxOut output); /** - * Utility method to constructs a new RouteError-variant APIError + * Utility method to constructs a new DelayedPaymentOutput-variant SpendableOutputDescriptor */ -struct LDKAPIError APIError_route_error(struct LDKStr err); +struct LDKSpendableOutputDescriptor SpendableOutputDescriptor_delayed_payment_output(struct LDKDelayedPaymentOutputDescriptor a); /** - * Utility method to constructs a new ChannelUnavailable-variant APIError + * Utility method to constructs a new StaticPaymentOutput-variant SpendableOutputDescriptor */ -struct LDKAPIError APIError_channel_unavailable(struct LDKStr err); +struct LDKSpendableOutputDescriptor SpendableOutputDescriptor_static_payment_output(struct LDKStaticPaymentOutputDescriptor a); /** - * Utility method to constructs a new MonitorUpdateFailed-variant APIError + * Checks if two SpendableOutputDescriptors contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -struct LDKAPIError APIError_monitor_update_failed(void); +bool SpendableOutputDescriptor_eq(const struct LDKSpendableOutputDescriptor *NONNULL_PTR a, const struct LDKSpendableOutputDescriptor *NONNULL_PTR b); /** - * Utility method to constructs a new IncompatibleShutdownScript-variant APIError + * Serialize the SpendableOutputDescriptor object into a byte array which can be read by SpendableOutputDescriptor_read */ -struct LDKAPIError APIError_incompatible_shutdown_script(struct LDKShutdownScript script); +struct LDKCVec_u8Z SpendableOutputDescriptor_write(const struct LDKSpendableOutputDescriptor *NONNULL_PTR obj); /** - * Creates a digital signature of a message given a SecretKey, like the node's secret. - * A receiver knowing the PublicKey (e.g. the node's id) and the message can be sure that the signature was generated by the caller. - * Signatures are EC recoverable, meaning that given the message and the signature the PublicKey of the signer can be extracted. + * Read a SpendableOutputDescriptor from a byte array, created by SpendableOutputDescriptor_write */ -struct LDKCResult_StringErrorZ sign(struct LDKu8slice msg, const uint8_t (*sk)[32]); +struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ SpendableOutputDescriptor_read(struct LDKu8slice ser); /** - * Recovers the PublicKey of the signer of the message given the message and the signature. + * Calls the free function if one is set */ -struct LDKCResult_PublicKeyErrorZ recover_pk(struct LDKu8slice msg, struct LDKStr sig); +void BaseSign_free(struct LDKBaseSign this_ptr); /** - * Verifies a message was signed by a PrivateKey that derives to a given PublicKey, given a message, a signature, - * and the PublicKey. + * Creates a copy of a Sign */ -bool verify(struct LDKu8slice msg, struct LDKStr sig, struct LDKPublicKey pk); +struct LDKSign Sign_clone(const struct LDKSign *NONNULL_PTR orig); /** - * Construct the invoice's HRP and signatureless data into a preimage to be hashed. + * Calls the free function if one is set */ -struct LDKCVec_u8Z construct_invoice_preimage(struct LDKu8slice hrp_bytes, struct LDKCVec_u5Z data_without_signature); +void Sign_free(struct LDKSign this_ptr); /** - * Creates a copy of the Level + * Creates a copy of the Recipient */ -enum LDKLevel Level_clone(const enum LDKLevel *NONNULL_PTR orig); +enum LDKRecipient Recipient_clone(const enum LDKRecipient *NONNULL_PTR orig); /** - * Utility method to constructs a new Gossip-variant Level + * Utility method to constructs a new Node-variant Recipient */ -enum LDKLevel Level_gossip(void); +enum LDKRecipient Recipient_node(void); /** - * Utility method to constructs a new Trace-variant Level + * Utility method to constructs a new PhantomNode-variant Recipient */ -enum LDKLevel Level_trace(void); +enum LDKRecipient Recipient_phantom_node(void); /** - * Utility method to constructs a new Debug-variant Level + * Calls the free function if one is set */ -enum LDKLevel Level_debug(void); +void KeysInterface_free(struct LDKKeysInterface this_ptr); /** - * Utility method to constructs a new Info-variant Level + * Frees any resources used by the InMemorySigner, if is_owned is set and inner is non-NULL. */ -enum LDKLevel Level_info(void); +void InMemorySigner_free(struct LDKInMemorySigner this_obj); /** - * Utility method to constructs a new Warn-variant Level + * Private key of anchor tx */ -enum LDKLevel Level_warn(void); +const uint8_t (*InMemorySigner_get_funding_key(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; /** - * Utility method to constructs a new Error-variant Level + * Private key of anchor tx */ -enum LDKLevel Level_error(void); +void InMemorySigner_set_funding_key(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKSecretKey val); /** - * Checks if two Levels contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Holder secret key for blinded revocation pubkey */ -bool Level_eq(const enum LDKLevel *NONNULL_PTR a, const enum LDKLevel *NONNULL_PTR b); +const uint8_t (*InMemorySigner_get_revocation_base_key(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; /** - * Checks if two Levels contain equal inner contents. + * Holder secret key for blinded revocation pubkey */ -uint64_t Level_hash(const enum LDKLevel *NONNULL_PTR o); +void InMemorySigner_set_revocation_base_key(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKSecretKey val); /** - * Returns the most verbose logging level. + * Holder secret key used for our balance in counterparty-broadcasted commitment transactions */ -MUST_USE_RES enum LDKLevel Level_max(void); +const uint8_t (*InMemorySigner_get_payment_key(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; /** - * Frees any resources used by the Record, if is_owned is set and inner is non-NULL. + * Holder secret key used for our balance in counterparty-broadcasted commitment transactions */ -void Record_free(struct LDKRecord this_obj); +void InMemorySigner_set_payment_key(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKSecretKey val); /** - * The verbosity level of the message. + * Holder secret key used in HTLC tx */ -enum LDKLevel Record_get_level(const struct LDKRecord *NONNULL_PTR this_ptr); +const uint8_t (*InMemorySigner_get_delayed_payment_base_key(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; /** - * The verbosity level of the message. + * Holder secret key used in HTLC tx */ -void Record_set_level(struct LDKRecord *NONNULL_PTR this_ptr, enum LDKLevel val); +void InMemorySigner_set_delayed_payment_base_key(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKSecretKey val); /** - * The message body. + * Holder htlc secret key used in commitment tx htlc outputs */ -struct LDKStr Record_get_args(const struct LDKRecord *NONNULL_PTR this_ptr); +const uint8_t (*InMemorySigner_get_htlc_base_key(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; /** - * The message body. + * Holder htlc secret key used in commitment tx htlc outputs */ -void Record_set_args(struct LDKRecord *NONNULL_PTR this_ptr, struct LDKStr val); +void InMemorySigner_set_htlc_base_key(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKSecretKey val); /** - * The module path of the message. + * Commitment seed */ -struct LDKStr Record_get_module_path(const struct LDKRecord *NONNULL_PTR this_ptr); +const uint8_t (*InMemorySigner_get_commitment_seed(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; /** - * The module path of the message. + * Commitment seed */ -void Record_set_module_path(struct LDKRecord *NONNULL_PTR this_ptr, struct LDKStr val); +void InMemorySigner_set_commitment_seed(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * The source file containing the message. + * Creates a copy of the InMemorySigner */ -struct LDKStr Record_get_file(const struct LDKRecord *NONNULL_PTR this_ptr); +struct LDKInMemorySigner InMemorySigner_clone(const struct LDKInMemorySigner *NONNULL_PTR orig); /** - * The source file containing the message. + * Create a new InMemorySigner */ -void Record_set_file(struct LDKRecord *NONNULL_PTR this_ptr, struct LDKStr val); +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); /** - * The line containing the message. + * Counterparty pubkeys. + * Will panic if ready_channel wasn't called. */ -uint32_t Record_get_line(const struct LDKRecord *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKChannelPublicKeys InMemorySigner_counterparty_pubkeys(const struct LDKInMemorySigner *NONNULL_PTR this_arg); /** - * The line containing the message. + * The contest_delay value specified by our counterparty and applied on holder-broadcastable + * transactions, ie the amount of time that we have to wait to recover our funds if we + * broadcast a transaction. + * Will panic if ready_channel wasn't called. */ -void Record_set_line(struct LDKRecord *NONNULL_PTR this_ptr, uint32_t val); +MUST_USE_RES uint16_t InMemorySigner_counterparty_selected_contest_delay(const struct LDKInMemorySigner *NONNULL_PTR this_arg); /** - * Creates a copy of the Record + * The contest_delay value specified by us and applied on transactions broadcastable + * by our counterparty, ie the amount of time that they have to wait to recover their funds + * if they broadcast a transaction. + * Will panic if ready_channel wasn't called. */ -struct LDKRecord Record_clone(const struct LDKRecord *NONNULL_PTR orig); +MUST_USE_RES uint16_t InMemorySigner_holder_selected_contest_delay(const struct LDKInMemorySigner *NONNULL_PTR this_arg); /** - * Calls the free function if one is set + * Whether the holder is the initiator + * Will panic if ready_channel wasn't called. */ -void Logger_free(struct LDKLogger this_ptr); +MUST_USE_RES bool InMemorySigner_is_outbound(const struct LDKInMemorySigner *NONNULL_PTR this_arg); /** - * Frees any resources used by the ChannelHandshakeConfig, if is_owned is set and inner is non-NULL. + * Funding outpoint + * Will panic if ready_channel wasn't called. */ -void ChannelHandshakeConfig_free(struct LDKChannelHandshakeConfig this_obj); +MUST_USE_RES struct LDKOutPoint InMemorySigner_funding_outpoint(const struct LDKInMemorySigner *NONNULL_PTR this_arg); /** - * Confirmations we will wait for before considering the channel locked in. - * Applied only for inbound channels (see ChannelHandshakeLimits::max_minimum_depth for the - * equivalent limit applied to outbound channels). + * Obtain a ChannelTransactionParameters for this channel, to be used when verifying or + * building transactions. * - * Default value: 6. + * Will panic if ready_channel wasn't called. */ -uint32_t ChannelHandshakeConfig_get_minimum_depth(const struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKChannelTransactionParameters InMemorySigner_get_channel_parameters(const struct LDKInMemorySigner *NONNULL_PTR this_arg); /** - * Confirmations we will wait for before considering the channel locked in. - * Applied only for inbound channels (see ChannelHandshakeLimits::max_minimum_depth for the - * equivalent limit applied to outbound channels). - * - * Default value: 6. + * Whether anchors should be used. + * Will panic if ready_channel wasn't called. */ -void ChannelHandshakeConfig_set_minimum_depth(struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr, uint32_t val); +MUST_USE_RES bool InMemorySigner_opt_anchors(const struct LDKInMemorySigner *NONNULL_PTR this_arg); /** - * Set to the number of blocks we require our counterparty to wait to claim their money (ie - * the number of blocks we have to punish our counterparty if they broadcast a revoked - * transaction). - * - * This is one of the main parameters of our security model. We (or one of our watchtowers) MUST - * be online to check for revoked transactions on-chain at least once every our_to_self_delay - * blocks (minus some margin to allow us enough time to broadcast and confirm a transaction, - * possibly with time in between to RBF the spending transaction). - * - * Meanwhile, asking for a too high delay, we bother peer to freeze funds for nothing in - * case of an honest unilateral channel close, which implicitly decrease the economic value of - * our channel. + * 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. * - * Default value: [`BREAKDOWN_TIMEOUT`], we enforce it as a minimum at channel opening so you - * can tweak config to ask for more security, not less. + * 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 if an output descriptor script_pubkey does not match the one we can spend. */ -uint16_t ChannelHandshakeConfig_get_our_to_self_delay(const struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr); +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); /** - * Set to the number of blocks we require our counterparty to wait to claim their money (ie - * the number of blocks we have to punish our counterparty if they broadcast a revoked - * transaction). - * - * This is one of the main parameters of our security model. We (or one of our watchtowers) MUST - * be online to check for revoked transactions on-chain at least once every our_to_self_delay - * blocks (minus some margin to allow us enough time to broadcast and confirm a transaction, - * possibly with time in between to RBF the spending transaction). - * - * Meanwhile, asking for a too high delay, we bother peer to freeze funds for nothing in - * case of an honest unilateral channel close, which implicitly decrease the economic value of - * our channel. + * 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. * - * Default value: [`BREAKDOWN_TIMEOUT`], we enforce it as a minimum at channel opening so you - * can tweak config to ask for more security, not less. + * 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`, 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. */ -void ChannelHandshakeConfig_set_our_to_self_delay(struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr, uint16_t val); +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); /** - * Set to the smallest value HTLC we will accept to process. - * - * This value is sent to our counterparty on channel-open and we close the channel any time - * our counterparty misbehaves by sending us an HTLC with a value smaller than this. - * - * Default value: 1. If the value is less than 1, it is ignored and set to 1, as is required - * by the protocol. + * Constructs a new BaseSign which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned BaseSign must be freed before this_arg is */ -uint64_t ChannelHandshakeConfig_get_our_htlc_minimum_msat(const struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr); +struct LDKBaseSign InMemorySigner_as_BaseSign(const struct LDKInMemorySigner *NONNULL_PTR this_arg); /** - * Set to the smallest value HTLC we will accept to process. - * - * This value is sent to our counterparty on channel-open and we close the channel any time - * our counterparty misbehaves by sending us an HTLC with a value smaller than this. - * - * Default value: 1. If the value is less than 1, it is ignored and set to 1, as is required - * by the protocol. + * Constructs a new Sign which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned Sign must be freed before this_arg is */ -void ChannelHandshakeConfig_set_our_htlc_minimum_msat(struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr, uint64_t val); +struct LDKSign InMemorySigner_as_Sign(const struct LDKInMemorySigner *NONNULL_PTR this_arg); /** - * Constructs a new ChannelHandshakeConfig given each field + * Serialize the InMemorySigner object into a byte array which can be read by InMemorySigner_read */ -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); +struct LDKCVec_u8Z InMemorySigner_write(const struct LDKInMemorySigner *NONNULL_PTR obj); /** - * Creates a copy of the ChannelHandshakeConfig + * Read a InMemorySigner from a byte array, created by InMemorySigner_write */ -struct LDKChannelHandshakeConfig ChannelHandshakeConfig_clone(const struct LDKChannelHandshakeConfig *NONNULL_PTR orig); +struct LDKCResult_InMemorySignerDecodeErrorZ InMemorySigner_read(struct LDKu8slice ser, struct LDKSecretKey arg); /** - * Creates a "default" ChannelHandshakeConfig. See struct and individual field documentaiton for details on which values are used. + * Frees any resources used by the KeysManager, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKChannelHandshakeConfig ChannelHandshakeConfig_default(void); +void KeysManager_free(struct LDKKeysManager this_obj); /** - * Frees any resources used by the ChannelHandshakeLimits, if is_owned is set and inner is non-NULL. + * Constructs a KeysManager from a 32-byte seed. If the seed is in some way biased (eg your + * CSRNG is busted) this may panic (but more importantly, you will possibly lose funds). + * starting_time isn't strictly required to actually be a time, but it must absolutely, + * without a doubt, be unique to this instance. ie if you start multiple times with the same + * seed, starting_time must be unique to each run. Thus, the easiest way to achieve this is to + * simply use the current time (with very high precision). + * + * The seed MUST be backed up safely prior to use so that the keys can be re-created, however, + * obviously, starting_time should be unique every time you reload the library - it is only + * used to generate new ephemeral key data (which will be stored by the individual channel if + * necessary). + * + * Note that the seed is required to recover certain on-chain funds independent of + * ChannelMonitor data, though a current copy of ChannelMonitor data is also required for any + * channel, and some on-chain during-closing funds. + * + * Note that until the 0.1 release there is no guarantee of backward compatibility between + * versions. Once the library is more fully supported, the docs will be updated to include a + * detailed description of the guarantee. */ -void ChannelHandshakeLimits_free(struct LDKChannelHandshakeLimits this_obj); +MUST_USE_RES struct LDKKeysManager KeysManager_new(const uint8_t (*seed)[32], uint64_t starting_time_secs, uint32_t starting_time_nanos); /** - * Minimum allowed satoshis when a channel is funded, this is supplied by the sender and so - * only applies to inbound channels. + * Derive an old Sign containing per-channel secrets based on a key derivation parameters. * - * Default value: 0. + * Key derivation parameters are accessible through a per-channel secrets + * Sign::channel_keys_id and is provided inside DynamicOuputP2WSH in case of + * onchain output detection for which a corresponding delayed_payment_key must be derived. */ -uint64_t ChannelHandshakeLimits_get_min_funding_satoshis(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKInMemorySigner KeysManager_derive_channel_keys(const struct LDKKeysManager *NONNULL_PTR this_arg, uint64_t channel_value_satoshis, const uint8_t (*params)[32]); /** - * Minimum allowed satoshis when a channel is funded, this is supplied by the sender and so - * only applies to inbound channels. + * Creates a Transaction which spends the given descriptors to the given outputs, plus an + * output to the given change destination (if sufficient change value remains). The + * transaction will have a feerate, at least, of the given value. * - * Default value: 0. + * Returns `Err(())` if the output value is greater than the input value minus required fee, + * if a descriptor was duplicated, or if an output descriptor `script_pubkey` + * does not match the one we can spend. + * + * We do not enforce that outputs meet the dust limit or that any output scripts are standard. + * + * May panic if the `SpendableOutputDescriptor`s were not generated by Channels which used + * this KeysManager or one of the `InMemorySigner` created by this KeysManager. */ -void ChannelHandshakeLimits_set_min_funding_satoshis(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, uint64_t val); +MUST_USE_RES struct LDKCResult_TransactionNoneZ KeysManager_spend_spendable_outputs(const struct LDKKeysManager *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); /** - * The remote node sets a limit on the minimum size of HTLCs we can send to them. This allows - * you to limit the maximum minimum-size they can require. - * - * Default value: u64::max_value. + * 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 */ -uint64_t ChannelHandshakeLimits_get_max_htlc_minimum_msat(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); +struct LDKKeysInterface KeysManager_as_KeysInterface(const struct LDKKeysManager *NONNULL_PTR this_arg); /** - * The remote node sets a limit on the minimum size of HTLCs we can send to them. This allows - * you to limit the maximum minimum-size they can require. - * - * Default value: u64::max_value. + * Frees any resources used by the PhantomKeysManager, if is_owned is set and inner is non-NULL. */ -void ChannelHandshakeLimits_set_max_htlc_minimum_msat(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, uint64_t val); +void PhantomKeysManager_free(struct LDKPhantomKeysManager this_obj); /** - * The remote node sets a limit on the maximum value of pending HTLCs to them at any given - * time to limit their funds exposure to HTLCs. This allows you to set a minimum such value. - * - * Default value: 0. + * 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 */ -uint64_t ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); +struct LDKKeysInterface PhantomKeysManager_as_KeysInterface(const struct LDKPhantomKeysManager *NONNULL_PTR this_arg); /** - * The remote node sets a limit on the maximum value of pending HTLCs to them at any given - * time to limit their funds exposure to HTLCs. This allows you to set a minimum such value. + * 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. * - * Default value: 0. + * 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 */ -void ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, uint64_t val); +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]); /** - * The remote node will require we keep a certain amount in direct payment to ourselves at all - * time, ensuring that we are able to be punished if we broadcast an old state. This allows to - * you limit the amount which we will have to keep to ourselves (and cannot use for HTLCs). - * - * Default value: u64::max_value. + * See [`KeysManager::spend_spendable_outputs`] for documentation on this method. */ -uint64_t ChannelHandshakeLimits_get_max_channel_reserve_satoshis(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); +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); /** - * The remote node will require we keep a certain amount in direct payment to ourselves at all - * time, ensuring that we are able to be punished if we broadcast an old state. This allows to - * you limit the amount which we will have to keep to ourselves (and cannot use for HTLCs). - * - * Default value: u64::max_value. + * See [`KeysManager::derive_channel_keys`] for documentation on this method. */ -void ChannelHandshakeLimits_set_max_channel_reserve_satoshis(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, uint64_t val); +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]); /** - * The remote node sets a limit on the maximum number of pending HTLCs to them at any given - * time. This allows you to set a minimum such value. - * - * Default value: 0. + * Frees any resources used by the ChannelManager, if is_owned is set and inner is non-NULL. */ -uint16_t ChannelHandshakeLimits_get_min_max_accepted_htlcs(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); +void ChannelManager_free(struct LDKChannelManager this_obj); /** - * The remote node sets a limit on the maximum number of pending HTLCs to them at any given - * time. This allows you to set a minimum such value. - * - * Default value: 0. + * Frees any resources used by the ChainParameters, if is_owned is set and inner is non-NULL. */ -void ChannelHandshakeLimits_set_min_max_accepted_htlcs(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, uint16_t val); +void ChainParameters_free(struct LDKChainParameters this_obj); /** - * Before a channel is usable the funding transaction will need to be confirmed by at least a - * certain number of blocks, specified by the node which is not the funder (as the funder can - * assume they aren't going to double-spend themselves). - * This config allows you to set a limit on the maximum amount of time to wait. - * - * Default value: 144, or roughly one day and only applies to outbound channels. + * The network for determining the `chain_hash` in Lightning messages. */ -uint32_t ChannelHandshakeLimits_get_max_minimum_depth(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); +enum LDKNetwork ChainParameters_get_network(const struct LDKChainParameters *NONNULL_PTR this_ptr); /** - * Before a channel is usable the funding transaction will need to be confirmed by at least a - * certain number of blocks, specified by the node which is not the funder (as the funder can - * assume they aren't going to double-spend themselves). - * This config allows you to set a limit on the maximum amount of time to wait. - * - * Default value: 144, or roughly one day and only applies to outbound channels. + * The network for determining the `chain_hash` in Lightning messages. */ -void ChannelHandshakeLimits_set_max_minimum_depth(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, uint32_t val); +void ChainParameters_set_network(struct LDKChainParameters *NONNULL_PTR this_ptr, enum LDKNetwork val); /** - * Set to force an incoming channel to match our announced channel preference in - * [`ChannelConfig::announced_channel`]. - * - * For a node which is not online reliably, this should be set to true and - * [`ChannelConfig::announced_channel`] set to false, ensuring that no announced (aka public) - * channels will ever be opened. + * The hash and height of the latest block successfully connected. * - * Default value: true. + * Used to track on-chain channel funding outputs and send payments with reliable timelocks. */ -bool ChannelHandshakeLimits_get_force_announced_channel_preference(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); +struct LDKBestBlock ChainParameters_get_best_block(const struct LDKChainParameters *NONNULL_PTR this_ptr); /** - * Set to force an incoming channel to match our announced channel preference in - * [`ChannelConfig::announced_channel`]. - * - * For a node which is not online reliably, this should be set to true and - * [`ChannelConfig::announced_channel`] set to false, ensuring that no announced (aka public) - * channels will ever be opened. + * The hash and height of the latest block successfully connected. * - * Default value: true. + * Used to track on-chain channel funding outputs and send payments with reliable timelocks. */ -void ChannelHandshakeLimits_set_force_announced_channel_preference(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, bool val); +void ChainParameters_set_best_block(struct LDKChainParameters *NONNULL_PTR this_ptr, struct LDKBestBlock val); /** - * Set to the amount of time we're willing to wait to claim money back to us. - * - * Not checking this value would be a security issue, as our peer would be able to set it to - * max relative lock-time (a year) and we would \"lose\" money as it would be locked for a long time. - * - * Default value: 2016, which we also enforce as a maximum value so you can tweak config to - * reduce the loss of having useless locked funds (if your peer accepts) + * Constructs a new ChainParameters given each field */ -uint16_t ChannelHandshakeLimits_get_their_to_self_delay(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKChainParameters ChainParameters_new(enum LDKNetwork network_arg, struct LDKBestBlock best_block_arg); /** - * Set to the amount of time we're willing to wait to claim money back to us. - * - * Not checking this value would be a security issue, as our peer would be able to set it to - * max relative lock-time (a year) and we would \"lose\" money as it would be locked for a long time. - * - * Default value: 2016, which we also enforce as a maximum value so you can tweak config to - * reduce the loss of having useless locked funds (if your peer accepts) + * Creates a copy of the ChainParameters */ -void ChannelHandshakeLimits_set_their_to_self_delay(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, uint16_t val); +struct LDKChainParameters ChainParameters_clone(const struct LDKChainParameters *NONNULL_PTR orig); /** - * Constructs a new ChannelHandshakeLimits given each field + * Frees any resources used by the CounterpartyForwardingInfo, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKChannelHandshakeLimits ChannelHandshakeLimits_new(uint64_t min_funding_satoshis_arg, uint64_t max_htlc_minimum_msat_arg, uint64_t min_max_htlc_value_in_flight_msat_arg, uint64_t max_channel_reserve_satoshis_arg, uint16_t min_max_accepted_htlcs_arg, uint32_t max_minimum_depth_arg, bool force_announced_channel_preference_arg, uint16_t their_to_self_delay_arg); +void CounterpartyForwardingInfo_free(struct LDKCounterpartyForwardingInfo this_obj); /** - * Creates a copy of the ChannelHandshakeLimits + * Base routing fee in millisatoshis. */ -struct LDKChannelHandshakeLimits ChannelHandshakeLimits_clone(const struct LDKChannelHandshakeLimits *NONNULL_PTR orig); +uint32_t CounterpartyForwardingInfo_get_fee_base_msat(const struct LDKCounterpartyForwardingInfo *NONNULL_PTR this_ptr); /** - * Creates a "default" ChannelHandshakeLimits. See struct and individual field documentaiton for details on which values are used. + * Base routing fee in millisatoshis. */ -MUST_USE_RES struct LDKChannelHandshakeLimits ChannelHandshakeLimits_default(void); +void CounterpartyForwardingInfo_set_fee_base_msat(struct LDKCounterpartyForwardingInfo *NONNULL_PTR this_ptr, uint32_t val); /** - * Frees any resources used by the ChannelConfig, if is_owned is set and inner is non-NULL. + * Amount in millionths of a satoshi the channel will charge per transferred satoshi. */ -void ChannelConfig_free(struct LDKChannelConfig this_obj); +uint32_t CounterpartyForwardingInfo_get_fee_proportional_millionths(const struct LDKCounterpartyForwardingInfo *NONNULL_PTR this_ptr); /** - * Amount (in millionths of a satoshi) charged per satoshi for payments forwarded outbound - * over the channel. - * This may be allowed to change at runtime in a later update, however doing so must result in - * update messages sent to notify all nodes of our updated relay fee. - * - * Default value: 0. + * Amount in millionths of a satoshi the channel will charge per transferred satoshi. */ -uint32_t ChannelConfig_get_forwarding_fee_proportional_millionths(const struct LDKChannelConfig *NONNULL_PTR this_ptr); +void CounterpartyForwardingInfo_set_fee_proportional_millionths(struct LDKCounterpartyForwardingInfo *NONNULL_PTR this_ptr, uint32_t val); /** - * Amount (in millionths of a satoshi) charged per satoshi for payments forwarded outbound - * over the channel. - * This may be allowed to change at runtime in a later update, however doing so must result in - * update messages sent to notify all nodes of our updated relay fee. - * - * Default value: 0. + * The minimum difference in cltv_expiry between an ingoing HTLC and its outgoing counterpart, + * such that the outgoing HTLC is forwardable to this counterparty. See `msgs::ChannelUpdate`'s + * `cltv_expiry_delta` for more details. */ -void ChannelConfig_set_forwarding_fee_proportional_millionths(struct LDKChannelConfig *NONNULL_PTR this_ptr, uint32_t val); +uint16_t CounterpartyForwardingInfo_get_cltv_expiry_delta(const struct LDKCounterpartyForwardingInfo *NONNULL_PTR this_ptr); /** - * Amount (in milli-satoshi) charged for payments forwarded outbound over the channel, in - * excess of [`forwarding_fee_proportional_millionths`]. - * This may be allowed to change at runtime in a later update, however doing so must result in - * update messages sent to notify all nodes of our updated relay fee. - * - * The default value of a single satoshi roughly matches the market rate on many routing nodes - * as of July 2021. Adjusting it upwards or downwards may change whether nodes route through - * this node. - * - * Default value: 1000. - * - * [`forwarding_fee_proportional_millionths`]: ChannelConfig::forwarding_fee_proportional_millionths + * The minimum difference in cltv_expiry between an ingoing HTLC and its outgoing counterpart, + * such that the outgoing HTLC is forwardable to this counterparty. See `msgs::ChannelUpdate`'s + * `cltv_expiry_delta` for more details. */ -uint32_t ChannelConfig_get_forwarding_fee_base_msat(const struct LDKChannelConfig *NONNULL_PTR this_ptr); +void CounterpartyForwardingInfo_set_cltv_expiry_delta(struct LDKCounterpartyForwardingInfo *NONNULL_PTR this_ptr, uint16_t val); /** - * Amount (in milli-satoshi) charged for payments forwarded outbound over the channel, in - * excess of [`forwarding_fee_proportional_millionths`]. - * This may be allowed to change at runtime in a later update, however doing so must result in - * update messages sent to notify all nodes of our updated relay fee. - * - * The default value of a single satoshi roughly matches the market rate on many routing nodes - * as of July 2021. Adjusting it upwards or downwards may change whether nodes route through - * this node. - * - * Default value: 1000. - * - * [`forwarding_fee_proportional_millionths`]: ChannelConfig::forwarding_fee_proportional_millionths + * Constructs a new CounterpartyForwardingInfo given each field + */ +MUST_USE_RES struct LDKCounterpartyForwardingInfo CounterpartyForwardingInfo_new(uint32_t fee_base_msat_arg, uint32_t fee_proportional_millionths_arg, uint16_t cltv_expiry_delta_arg); + +/** + * Creates a copy of the CounterpartyForwardingInfo */ -void ChannelConfig_set_forwarding_fee_base_msat(struct LDKChannelConfig *NONNULL_PTR this_ptr, uint32_t val); +struct LDKCounterpartyForwardingInfo CounterpartyForwardingInfo_clone(const struct LDKCounterpartyForwardingInfo *NONNULL_PTR orig); /** - * The difference in the CLTV value between incoming HTLCs and an outbound HTLC forwarded over - * the channel this config applies to. - * - * This is analogous to [`ChannelHandshakeConfig::our_to_self_delay`] but applies to in-flight - * HTLC balance when a channel appears on-chain whereas - * [`ChannelHandshakeConfig::our_to_self_delay`] applies to the remaining - * (non-HTLC-encumbered) balance. - * - * Thus, for HTLC-encumbered balances to be enforced on-chain when a channel is force-closed, - * we (or one of our watchtowers) MUST be online to check for broadcast of the current - * commitment transaction at least once per this many blocks (minus some margin to allow us - * enough time to broadcast and confirm a transaction, possibly with time in between to RBF - * the spending transaction). - * - * Default value: 72 (12 hours at an average of 6 blocks/hour). - * Minimum value: [`MIN_CLTV_EXPIRY_DELTA`], any values less than this will be treated as - * [`MIN_CLTV_EXPIRY_DELTA`] instead. - * - * [`MIN_CLTV_EXPIRY_DELTA`]: crate::ln::channelmanager::MIN_CLTV_EXPIRY_DELTA + * Frees any resources used by the ChannelCounterparty, if is_owned is set and inner is non-NULL. */ -uint16_t ChannelConfig_get_cltv_expiry_delta(const struct LDKChannelConfig *NONNULL_PTR this_ptr); +void ChannelCounterparty_free(struct LDKChannelCounterparty this_obj); /** - * The difference in the CLTV value between incoming HTLCs and an outbound HTLC forwarded over - * the channel this config applies to. - * - * This is analogous to [`ChannelHandshakeConfig::our_to_self_delay`] but applies to in-flight - * HTLC balance when a channel appears on-chain whereas - * [`ChannelHandshakeConfig::our_to_self_delay`] applies to the remaining - * (non-HTLC-encumbered) balance. - * - * Thus, for HTLC-encumbered balances to be enforced on-chain when a channel is force-closed, - * we (or one of our watchtowers) MUST be online to check for broadcast of the current - * commitment transaction at least once per this many blocks (minus some margin to allow us - * enough time to broadcast and confirm a transaction, possibly with time in between to RBF - * the spending transaction). - * - * Default value: 72 (12 hours at an average of 6 blocks/hour). - * Minimum value: [`MIN_CLTV_EXPIRY_DELTA`], any values less than this will be treated as - * [`MIN_CLTV_EXPIRY_DELTA`] instead. - * - * [`MIN_CLTV_EXPIRY_DELTA`]: crate::ln::channelmanager::MIN_CLTV_EXPIRY_DELTA + * The node_id of our counterparty */ -void ChannelConfig_set_cltv_expiry_delta(struct LDKChannelConfig *NONNULL_PTR this_ptr, uint16_t val); +struct LDKPublicKey ChannelCounterparty_get_node_id(const struct LDKChannelCounterparty *NONNULL_PTR this_ptr); /** - * Set to announce the channel publicly and notify all nodes that they can route via this - * channel. - * - * This should only be set to true for nodes which expect to be online reliably. - * - * As the node which funds a channel picks this value this will only apply for new outbound - * channels unless [`ChannelHandshakeLimits::force_announced_channel_preference`] is set. - * - * This cannot be changed after the initial channel handshake. - * - * Default value: false. + * The node_id of our counterparty */ -bool ChannelConfig_get_announced_channel(const struct LDKChannelConfig *NONNULL_PTR this_ptr); +void ChannelCounterparty_set_node_id(struct LDKChannelCounterparty *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Set to announce the channel publicly and notify all nodes that they can route via this - * channel. - * - * This should only be set to true for nodes which expect to be online reliably. - * - * As the node which funds a channel picks this value this will only apply for new outbound - * channels unless [`ChannelHandshakeLimits::force_announced_channel_preference`] is set. - * - * This cannot be changed after the initial channel handshake. - * - * Default value: false. + * The Features the channel counterparty provided upon last connection. + * Useful for routing as it is the most up-to-date copy of the counterparty's features and + * many routing-relevant features are present in the init context. */ -void ChannelConfig_set_announced_channel(struct LDKChannelConfig *NONNULL_PTR this_ptr, bool val); +struct LDKInitFeatures ChannelCounterparty_get_features(const struct LDKChannelCounterparty *NONNULL_PTR this_ptr); /** - * When set, we commit to an upfront shutdown_pubkey at channel open. If our counterparty - * supports it, they will then enforce the mutual-close output to us matches what we provided - * at intialization, preventing us from closing to an alternate pubkey. - * - * This is set to true by default to provide a slight increase in security, though ultimately - * any attacker who is able to take control of a channel can just as easily send the funds via - * lightning payments, so we never require that our counterparties support this option. - * - * This cannot be changed after a channel has been initialized. - * - * Default value: true. + * The Features the channel counterparty provided upon last connection. + * Useful for routing as it is the most up-to-date copy of the counterparty's features and + * many routing-relevant features are present in the init context. */ -bool ChannelConfig_get_commit_upfront_shutdown_pubkey(const struct LDKChannelConfig *NONNULL_PTR this_ptr); +void ChannelCounterparty_set_features(struct LDKChannelCounterparty *NONNULL_PTR this_ptr, struct LDKInitFeatures val); /** - * When set, we commit to an upfront shutdown_pubkey at channel open. If our counterparty - * supports it, they will then enforce the mutual-close output to us matches what we provided - * at intialization, preventing us from closing to an alternate pubkey. - * - * This is set to true by default to provide a slight increase in security, though ultimately - * any attacker who is able to take control of a channel can just as easily send the funds via - * lightning payments, so we never require that our counterparties support this option. + * The value, in satoshis, that must always be held in the channel for our counterparty. This + * value ensures that if our counterparty broadcasts a revoked state, we can punish them by + * claiming at least this value on chain. * - * This cannot be changed after a channel has been initialized. + * This value is not included in [`inbound_capacity_msat`] as it can never be spent. * - * Default value: true. + * [`inbound_capacity_msat`]: ChannelDetails::inbound_capacity_msat */ -void ChannelConfig_set_commit_upfront_shutdown_pubkey(struct LDKChannelConfig *NONNULL_PTR this_ptr, bool val); +uint64_t ChannelCounterparty_get_unspendable_punishment_reserve(const struct LDKChannelCounterparty *NONNULL_PTR this_ptr); /** - * Limit our total exposure to in-flight HTLCs which are burned to fees as they are too - * small to claim on-chain. - * - * When an HTLC present in one of our channels is below a \"dust\" threshold, the HTLC will - * not be claimable on-chain, instead being turned into additional miner fees if either - * party force-closes the channel. Because the threshold is per-HTLC, our total exposure - * to such payments may be sustantial if there are many dust HTLCs present when the - * channel is force-closed. + * The value, in satoshis, that must always be held in the channel for our counterparty. This + * value ensures that if our counterparty broadcasts a revoked state, we can punish them by + * claiming at least this value on chain. * - * This limit is applied for sent, forwarded, and received HTLCs and limits the total - * exposure across all three types per-channel. Setting this too low may prevent the - * sending or receipt of low-value HTLCs on high-traffic nodes, and this limit is very - * important to prevent stealing of dust HTLCs by miners. + * This value is not included in [`inbound_capacity_msat`] as it can never be spent. * - * Default value: 5_000_000 msat. + * [`inbound_capacity_msat`]: ChannelDetails::inbound_capacity_msat */ -uint64_t ChannelConfig_get_max_dust_htlc_exposure_msat(const struct LDKChannelConfig *NONNULL_PTR this_ptr); +void ChannelCounterparty_set_unspendable_punishment_reserve(struct LDKChannelCounterparty *NONNULL_PTR this_ptr, uint64_t val); /** - * Limit our total exposure to in-flight HTLCs which are burned to fees as they are too - * small to claim on-chain. - * - * When an HTLC present in one of our channels is below a \"dust\" threshold, the HTLC will - * not be claimable on-chain, instead being turned into additional miner fees if either - * party force-closes the channel. Because the threshold is per-HTLC, our total exposure - * to such payments may be sustantial if there are many dust HTLCs present when the - * channel is force-closed. - * - * This limit is applied for sent, forwarded, and received HTLCs and limits the total - * exposure across all three types per-channel. Setting this too low may prevent the - * sending or receipt of low-value HTLCs on high-traffic nodes, and this limit is very - * important to prevent stealing of dust HTLCs by miners. + * Information on the fees and requirements that the counterparty requires when forwarding + * payments to us through this channel. * - * Default value: 5_000_000 msat. + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void ChannelConfig_set_max_dust_htlc_exposure_msat(struct LDKChannelConfig *NONNULL_PTR this_ptr, uint64_t val); +struct LDKCounterpartyForwardingInfo ChannelCounterparty_get_forwarding_info(const struct LDKChannelCounterparty *NONNULL_PTR this_ptr); /** - * The additional fee we're willing to pay to avoid waiting for the counterparty's - * `to_self_delay` to reclaim funds. - * - * When we close a channel cooperatively with our counterparty, we negotiate a fee for the - * closing transaction which both sides find acceptable, ultimately paid by the channel - * funder/initiator. - * - * When we are the funder, because we have to pay the channel closing fee, we bound the - * acceptable fee by our [`Background`] and [`Normal`] fees, with the upper bound increased by - * this value. Because the on-chain fee we'd pay to force-close the channel is kept near our - * [`Normal`] feerate during normal operation, this value represents the additional fee we're - * willing to pay in order to avoid waiting for our counterparty's to_self_delay to reclaim our - * funds. - * - * When we are not the funder, we require the closing transaction fee pay at least our - * [`Background`] fee estimate, but allow our counterparty to pay as much fee as they like. - * Thus, this value is ignored when we are not the funder. - * - * Default value: 1000 satoshis. + * Information on the fees and requirements that the counterparty requires when forwarding + * payments to us through this channel. * - * [`Normal`]: crate::chain::chaininterface::ConfirmationTarget::Normal - * [`Background`]: crate::chain::chaininterface::ConfirmationTarget::Background + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -uint64_t ChannelConfig_get_force_close_avoidance_max_fee_satoshis(const struct LDKChannelConfig *NONNULL_PTR this_ptr); +void ChannelCounterparty_set_forwarding_info(struct LDKChannelCounterparty *NONNULL_PTR this_ptr, struct LDKCounterpartyForwardingInfo val); /** - * The additional fee we're willing to pay to avoid waiting for the counterparty's - * `to_self_delay` to reclaim funds. - * - * When we close a channel cooperatively with our counterparty, we negotiate a fee for the - * closing transaction which both sides find acceptable, ultimately paid by the channel - * funder/initiator. - * - * When we are the funder, because we have to pay the channel closing fee, we bound the - * acceptable fee by our [`Background`] and [`Normal`] fees, with the upper bound increased by - * this value. Because the on-chain fee we'd pay to force-close the channel is kept near our - * [`Normal`] feerate during normal operation, this value represents the additional fee we're - * willing to pay in order to avoid waiting for our counterparty's to_self_delay to reclaim our - * funds. - * - * When we are not the funder, we require the closing transaction fee pay at least our - * [`Background`] fee estimate, but allow our counterparty to pay as much fee as they like. - * Thus, this value is ignored when we are not the funder. - * - * Default value: 1000 satoshis. - * - * [`Normal`]: crate::chain::chaininterface::ConfirmationTarget::Normal - * [`Background`]: crate::chain::chaininterface::ConfirmationTarget::Background + * The smallest value HTLC (in msat) the remote peer will accept, for this channel. This field + * is only `None` before we have received either the `OpenChannel` or `AcceptChannel` message + * from the remote peer, or for `ChannelCounterparty` objects serialized prior to LDK 0.0.107. */ -void ChannelConfig_set_force_close_avoidance_max_fee_satoshis(struct LDKChannelConfig *NONNULL_PTR this_ptr, uint64_t val); +struct LDKCOption_u64Z ChannelCounterparty_get_outbound_htlc_minimum_msat(const struct LDKChannelCounterparty *NONNULL_PTR this_ptr); /** - * Constructs a new ChannelConfig given each field + * The smallest value HTLC (in msat) the remote peer will accept, for this channel. This field + * is only `None` before we have received either the `OpenChannel` or `AcceptChannel` message + * from the remote peer, or for `ChannelCounterparty` objects serialized prior to LDK 0.0.107. */ -MUST_USE_RES struct LDKChannelConfig ChannelConfig_new(uint32_t forwarding_fee_proportional_millionths_arg, uint32_t forwarding_fee_base_msat_arg, uint16_t cltv_expiry_delta_arg, bool announced_channel_arg, bool commit_upfront_shutdown_pubkey_arg, uint64_t max_dust_htlc_exposure_msat_arg, uint64_t force_close_avoidance_max_fee_satoshis_arg); +void ChannelCounterparty_set_outbound_htlc_minimum_msat(struct LDKChannelCounterparty *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); /** - * Creates a copy of the ChannelConfig + * The largest value HTLC (in msat) the remote peer currently will accept, for this channel. */ -struct LDKChannelConfig ChannelConfig_clone(const struct LDKChannelConfig *NONNULL_PTR orig); +struct LDKCOption_u64Z ChannelCounterparty_get_outbound_htlc_maximum_msat(const struct LDKChannelCounterparty *NONNULL_PTR this_ptr); /** - * Creates a "default" ChannelConfig. See struct and individual field documentaiton for details on which values are used. + * The largest value HTLC (in msat) the remote peer currently will accept, for this channel. */ -MUST_USE_RES struct LDKChannelConfig ChannelConfig_default(void); +void ChannelCounterparty_set_outbound_htlc_maximum_msat(struct LDKChannelCounterparty *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); /** - * Serialize the ChannelConfig object into a byte array which can be read by ChannelConfig_read + * Constructs a new ChannelCounterparty given each field */ -struct LDKCVec_u8Z ChannelConfig_write(const struct LDKChannelConfig *NONNULL_PTR obj); +MUST_USE_RES struct LDKChannelCounterparty ChannelCounterparty_new(struct LDKPublicKey node_id_arg, struct LDKInitFeatures features_arg, uint64_t unspendable_punishment_reserve_arg, struct LDKCounterpartyForwardingInfo forwarding_info_arg, struct LDKCOption_u64Z outbound_htlc_minimum_msat_arg, struct LDKCOption_u64Z outbound_htlc_maximum_msat_arg); /** - * Read a ChannelConfig from a byte array, created by ChannelConfig_write + * Creates a copy of the ChannelCounterparty */ -struct LDKCResult_ChannelConfigDecodeErrorZ ChannelConfig_read(struct LDKu8slice ser); +struct LDKChannelCounterparty ChannelCounterparty_clone(const struct LDKChannelCounterparty *NONNULL_PTR orig); /** - * Frees any resources used by the UserConfig, if is_owned is set and inner is non-NULL. + * Frees any resources used by the ChannelDetails, if is_owned is set and inner is non-NULL. */ -void UserConfig_free(struct LDKUserConfig this_obj); +void ChannelDetails_free(struct LDKChannelDetails this_obj); /** - * Channel config that we propose to our counterparty. + * The channel's ID (prior to funding transaction generation, this is a random 32 bytes, + * thereafter this is the txid of the funding transaction xor the funding transaction output). + * Note that this means this value is *not* persistent - it can change once during the + * lifetime of the channel. */ -struct LDKChannelHandshakeConfig UserConfig_get_own_channel_config(const struct LDKUserConfig *NONNULL_PTR this_ptr); +const uint8_t (*ChannelDetails_get_channel_id(const struct LDKChannelDetails *NONNULL_PTR this_ptr))[32]; /** - * Channel config that we propose to our counterparty. + * The channel's ID (prior to funding transaction generation, this is a random 32 bytes, + * thereafter this is the txid of the funding transaction xor the funding transaction output). + * Note that this means this value is *not* persistent - it can change once during the + * lifetime of the channel. */ -void UserConfig_set_own_channel_config(struct LDKUserConfig *NONNULL_PTR this_ptr, struct LDKChannelHandshakeConfig val); +void ChannelDetails_set_channel_id(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Limits applied to our counterparty's proposed channel config settings. + * Parameters which apply to our counterparty. See individual fields for more information. */ -struct LDKChannelHandshakeLimits UserConfig_get_peer_channel_config_limits(const struct LDKUserConfig *NONNULL_PTR this_ptr); +struct LDKChannelCounterparty ChannelDetails_get_counterparty(const struct LDKChannelDetails *NONNULL_PTR this_ptr); /** - * Limits applied to our counterparty's proposed channel config settings. + * Parameters which apply to our counterparty. See individual fields for more information. */ -void UserConfig_set_peer_channel_config_limits(struct LDKUserConfig *NONNULL_PTR this_ptr, struct LDKChannelHandshakeLimits val); +void ChannelDetails_set_counterparty(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKChannelCounterparty val); /** - * Channel config which affects behavior during channel lifetime. + * The Channel's funding transaction output, if we've negotiated the funding transaction with + * our counterparty already. + * + * Note that, if this has been set, `channel_id` will be equivalent to + * `funding_txo.unwrap().to_channel_id()`. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKChannelConfig UserConfig_get_channel_options(const struct LDKUserConfig *NONNULL_PTR this_ptr); +struct LDKOutPoint ChannelDetails_get_funding_txo(const struct LDKChannelDetails *NONNULL_PTR this_ptr); /** - * Channel config which affects behavior during channel lifetime. + * The Channel's funding transaction output, if we've negotiated the funding transaction with + * our counterparty already. + * + * Note that, if this has been set, `channel_id` will be equivalent to + * `funding_txo.unwrap().to_channel_id()`. + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void UserConfig_set_channel_options(struct LDKUserConfig *NONNULL_PTR this_ptr, struct LDKChannelConfig val); +void ChannelDetails_set_funding_txo(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKOutPoint val); /** - * If this is set to false, we will reject any HTLCs which were to be forwarded over private - * channels. This prevents us from taking on HTLC-forwarding risk when we intend to run as a - * node which is not online reliably. + * The features which this channel operates with. See individual features for more info. * - * For nodes which are not online reliably, you should set all channels to *not* be announced - * (using [`ChannelConfig::announced_channel`] and - * [`ChannelHandshakeLimits::force_announced_channel_preference`]) and set this to false to - * ensure you are not exposed to any forwarding risk. + * `None` until negotiation completes and the channel type is finalized. * - * Note that because you cannot change a channel's announced state after creation, there is no - * way to disable forwarding on public channels retroactively. Thus, in order to change a node - * from a publicly-announced forwarding node to a private non-forwarding node you must close - * all your channels and open new ones. For privacy, you should also change your node_id - * (swapping all private and public key material for new ones) at that time. + * 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. * - * Default value: false. + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -bool UserConfig_get_accept_forwards_to_priv_channels(const struct LDKUserConfig *NONNULL_PTR this_ptr); +void ChannelDetails_set_channel_type(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKChannelTypeFeatures val); /** - * If this is set to false, we will reject any HTLCs which were to be forwarded over private - * channels. This prevents us from taking on HTLC-forwarding risk when we intend to run as a - * node which is not online reliably. + * The position of the funding transaction in the chain. None if the funding transaction has + * not yet been confirmed and the channel fully opened. * - * For nodes which are not online reliably, you should set all channels to *not* be announced - * (using [`ChannelConfig::announced_channel`] and - * [`ChannelHandshakeLimits::force_announced_channel_preference`]) and set this to false to - * ensure you are not exposed to any forwarding risk. + * 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`]. * - * Note that because you cannot change a channel's announced state after creation, there is no - * way to disable forwarding on public channels retroactively. Thus, in order to change a node - * from a publicly-announced forwarding node to a private non-forwarding node you must close - * all your channels and open new ones. For privacy, you should also change your node_id - * (swapping all private and public key material for new ones) at that time. + * For channels with [`confirmations_required`] set to `Some(0)`, [`outbound_scid_alias`] may + * be used in place of this in outbound routes. See [`get_outbound_payment_scid`]. * - * Default value: false. + * [`inbound_scid_alias`]: Self::inbound_scid_alias + * [`outbound_scid_alias`]: Self::outbound_scid_alias + * [`get_inbound_payment_scid`]: Self::get_inbound_payment_scid + * [`get_outbound_payment_scid`]: Self::get_outbound_payment_scid + * [`confirmations_required`]: Self::confirmations_required */ -void UserConfig_set_accept_forwards_to_priv_channels(struct LDKUserConfig *NONNULL_PTR this_ptr, bool val); +struct LDKCOption_u64Z ChannelDetails_get_short_channel_id(const struct LDKChannelDetails *NONNULL_PTR this_ptr); /** - * If this is set to false, we do not accept inbound requests to open a new channel. - * Default value: true. + * 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`]. + * + * For channels with [`confirmations_required`] set to `Some(0)`, [`outbound_scid_alias`] may + * be used in place of this in outbound routes. See [`get_outbound_payment_scid`]. + * + * [`inbound_scid_alias`]: Self::inbound_scid_alias + * [`outbound_scid_alias`]: Self::outbound_scid_alias + * [`get_inbound_payment_scid`]: Self::get_inbound_payment_scid + * [`get_outbound_payment_scid`]: Self::get_outbound_payment_scid + * [`confirmations_required`]: Self::confirmations_required */ -bool UserConfig_get_accept_inbound_channels(const struct LDKUserConfig *NONNULL_PTR this_ptr); +void ChannelDetails_set_short_channel_id(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); /** - * If this is set to false, we do not accept inbound requests to open a new channel. - * Default value: true. + * An optional [`short_channel_id`] alias for this channel, randomly generated by us and + * usable in place of [`short_channel_id`] to reference the channel in outbound routes when + * the channel has not yet been confirmed (as long as [`confirmations_required`] is + * `Some(0)`). + * + * This will be `None` as long as the channel is not available for routing outbound payments. + * + * [`short_channel_id`]: Self::short_channel_id + * [`confirmations_required`]: Self::confirmations_required */ -void UserConfig_set_accept_inbound_channels(struct LDKUserConfig *NONNULL_PTR this_ptr, bool val); +struct LDKCOption_u64Z ChannelDetails_get_outbound_scid_alias(const struct LDKChannelDetails *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. + * An optional [`short_channel_id`] alias for this channel, randomly generated by us and + * usable in place of [`short_channel_id`] to reference the channel in outbound routes when + * the channel has not yet been confirmed (as long as [`confirmations_required`] is + * `Some(0)`). * - * Default value: false. + * This will be `None` as long as the channel is not available for routing outbound payments. * - * [`Event::OpenChannelRequest`]: crate::util::events::Event::OpenChannelRequest - * [`msgs::OpenChannel`]: crate::ln::msgs::OpenChannel - * [`msgs::AcceptChannel`]: crate::ln::msgs::AcceptChannel + * [`short_channel_id`]: Self::short_channel_id + * [`confirmations_required`]: Self::confirmations_required */ -bool UserConfig_get_manually_accept_inbound_channels(const struct LDKUserConfig *NONNULL_PTR this_ptr); +void ChannelDetails_set_outbound_scid_alias(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u64Z 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. + * 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. * - * Default value: false. + * Our counterparty may choose to rotate this value at any time, though will always recognize + * previous values for inbound payment forwarding. * - * [`Event::OpenChannelRequest`]: crate::util::events::Event::OpenChannelRequest - * [`msgs::OpenChannel`]: crate::ln::msgs::OpenChannel - * [`msgs::AcceptChannel`]: crate::ln::msgs::AcceptChannel + * [`short_channel_id`]: Self::short_channel_id */ -void UserConfig_set_manually_accept_inbound_channels(struct LDKUserConfig *NONNULL_PTR this_ptr, bool val); +struct LDKCOption_u64Z ChannelDetails_get_inbound_scid_alias(const struct LDKChannelDetails *NONNULL_PTR this_ptr); /** - * Constructs a new UserConfig given each field + * 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 */ -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); +void ChannelDetails_set_inbound_scid_alias(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); /** - * Creates a copy of the UserConfig + * The value, in satoshis, of this channel as appears in the funding output */ -struct LDKUserConfig UserConfig_clone(const struct LDKUserConfig *NONNULL_PTR orig); +uint64_t ChannelDetails_get_channel_value_satoshis(const struct LDKChannelDetails *NONNULL_PTR this_ptr); /** - * Creates a "default" UserConfig. See struct and individual field documentaiton for details on which values are used. + * The value, in satoshis, of this channel as appears in the funding output */ -MUST_USE_RES struct LDKUserConfig UserConfig_default(void); +void ChannelDetails_set_channel_value_satoshis(struct LDKChannelDetails *NONNULL_PTR this_ptr, uint64_t val); /** - * Frees any resources used by the BestBlock, if is_owned is set and inner is non-NULL. + * The value, in satoshis, that must always be held in the channel for us. This value ensures + * that if we broadcast a revoked state, our counterparty can punish us by claiming at least + * this value on chain. + * + * This value is not included in [`outbound_capacity_msat`] as it can never be spent. + * + * This value will be `None` for outbound channels until the counterparty accepts the channel. + * + * [`outbound_capacity_msat`]: ChannelDetails::outbound_capacity_msat */ -void BestBlock_free(struct LDKBestBlock this_obj); +struct LDKCOption_u64Z ChannelDetails_get_unspendable_punishment_reserve(const struct LDKChannelDetails *NONNULL_PTR this_ptr); /** - * Creates a copy of the BestBlock + * The value, in satoshis, that must always be held in the channel for us. This value ensures + * that if we broadcast a revoked state, our counterparty can punish us by claiming at least + * this value on chain. + * + * This value is not included in [`outbound_capacity_msat`] as it can never be spent. + * + * This value will be `None` for outbound channels until the counterparty accepts the channel. + * + * [`outbound_capacity_msat`]: ChannelDetails::outbound_capacity_msat */ -struct LDKBestBlock BestBlock_clone(const struct LDKBestBlock *NONNULL_PTR orig); +void ChannelDetails_set_unspendable_punishment_reserve(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); /** - * Constructs a `BestBlock` that represents the genesis block at height 0 of the given - * network. + * The `user_channel_id` passed in to create_channel, or 0 if the channel was inbound. */ -MUST_USE_RES struct LDKBestBlock BestBlock_from_genesis(enum LDKNetwork network); +uint64_t ChannelDetails_get_user_channel_id(const struct LDKChannelDetails *NONNULL_PTR this_ptr); /** - * Returns a `BestBlock` as identified by the given block hash and height. + * The `user_channel_id` passed in to create_channel, or 0 if the channel was inbound. */ -MUST_USE_RES struct LDKBestBlock BestBlock_new(struct LDKThirtyTwoBytes block_hash, uint32_t height); +void ChannelDetails_set_user_channel_id(struct LDKChannelDetails *NONNULL_PTR this_ptr, uint64_t val); /** - * Returns the best block hash. + * 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`] */ -MUST_USE_RES struct LDKThirtyTwoBytes BestBlock_block_hash(const struct LDKBestBlock *NONNULL_PTR this_arg); +uint64_t ChannelDetails_get_balance_msat(const struct LDKChannelDetails *NONNULL_PTR this_ptr); /** - * Returns the best block height. + * 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`] */ -MUST_USE_RES uint32_t BestBlock_height(const struct LDKBestBlock *NONNULL_PTR this_arg); +void ChannelDetails_set_balance_msat(struct LDKChannelDetails *NONNULL_PTR this_ptr, uint64_t val); /** - * Creates a copy of the AccessError + * 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, 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. */ -enum LDKAccessError AccessError_clone(const enum LDKAccessError *NONNULL_PTR orig); +uint64_t ChannelDetails_get_outbound_capacity_msat(const struct LDKChannelDetails *NONNULL_PTR this_ptr); /** - * Utility method to constructs a new UnknownChain-variant AccessError + * 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, 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. */ -enum LDKAccessError AccessError_unknown_chain(void); +void ChannelDetails_set_outbound_capacity_msat(struct LDKChannelDetails *NONNULL_PTR this_ptr, uint64_t val); /** - * Utility method to constructs a new UnknownTx-variant AccessError + * The available outbound capacity for sending a single HTLC to the remote peer. This is + * similar to [`ChannelDetails::outbound_capacity_msat`] but it may be further restricted by + * the current state and per-HTLC limit(s). This is intended for use when routing, allowing us + * to use a limit as close as possible to the HTLC limit we can currently send. + * + * See also [`ChannelDetails::balance_msat`] and [`ChannelDetails::outbound_capacity_msat`]. */ -enum LDKAccessError AccessError_unknown_tx(void); +uint64_t ChannelDetails_get_next_outbound_htlc_limit_msat(const struct LDKChannelDetails *NONNULL_PTR this_ptr); /** - * Calls the free function if one is set + * The available outbound capacity for sending a single HTLC to the remote peer. This is + * similar to [`ChannelDetails::outbound_capacity_msat`] but it may be further restricted by + * the current state and per-HTLC limit(s). This is intended for use when routing, allowing us + * to use a limit as close as possible to the HTLC limit we can currently send. + * + * See also [`ChannelDetails::balance_msat`] and [`ChannelDetails::outbound_capacity_msat`]. */ -void Access_free(struct LDKAccess this_ptr); +void ChannelDetails_set_next_outbound_htlc_limit_msat(struct LDKChannelDetails *NONNULL_PTR this_ptr, uint64_t val); /** - * Calls the free function if one is set + * The available inbound capacity for the remote peer to send HTLCs to us. This does not + * include any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not + * available for inclusion in new inbound HTLCs). + * Note that there are some corner cases not fully handled here, so the actual available + * inbound capacity may be slightly higher than this. + * + * This value is not exact. Due to various in-flight changes, feerate changes, and our + * counterparty's conflict-avoidance policy, exactly this amount is not likely to be spendable. + * However, our counterparty should be able to spend nearly this amount. */ -void Listen_free(struct LDKListen this_ptr); +uint64_t ChannelDetails_get_inbound_capacity_msat(const struct LDKChannelDetails *NONNULL_PTR this_ptr); /** - * Calls the free function if one is set + * The available inbound capacity for the remote peer to send HTLCs to us. This does not + * include any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not + * available for inclusion in new inbound HTLCs). + * Note that there are some corner cases not fully handled here, so the actual available + * inbound capacity may be slightly higher than this. + * + * This value is not exact. Due to various in-flight changes, feerate changes, and our + * counterparty's conflict-avoidance policy, exactly this amount is not likely to be spendable. + * However, our counterparty should be able to spend nearly this amount. */ -void Confirm_free(struct LDKConfirm this_ptr); +void ChannelDetails_set_inbound_capacity_msat(struct LDKChannelDetails *NONNULL_PTR this_ptr, uint64_t val); /** - * Creates a copy of the ChannelMonitorUpdateErr + * The number of required confirmations on the funding transaction before the funding will be + * considered \"locked\". This number is selected by the channel fundee (i.e. us if + * [`is_outbound`] is *not* set), and can be selected for inbound channels with + * [`ChannelHandshakeConfig::minimum_depth`] or limited for outbound channels with + * [`ChannelHandshakeLimits::max_minimum_depth`]. + * + * This value will be `None` for outbound channels until the counterparty accepts the channel. + * + * [`is_outbound`]: ChannelDetails::is_outbound + * [`ChannelHandshakeConfig::minimum_depth`]: crate::util::config::ChannelHandshakeConfig::minimum_depth + * [`ChannelHandshakeLimits::max_minimum_depth`]: crate::util::config::ChannelHandshakeLimits::max_minimum_depth */ -enum LDKChannelMonitorUpdateErr ChannelMonitorUpdateErr_clone(const enum LDKChannelMonitorUpdateErr *NONNULL_PTR orig); +struct LDKCOption_u32Z ChannelDetails_get_confirmations_required(const struct LDKChannelDetails *NONNULL_PTR this_ptr); /** - * Utility method to constructs a new TemporaryFailure-variant ChannelMonitorUpdateErr + * The number of required confirmations on the funding transaction before the funding will be + * considered \"locked\". This number is selected by the channel fundee (i.e. us if + * [`is_outbound`] is *not* set), and can be selected for inbound channels with + * [`ChannelHandshakeConfig::minimum_depth`] or limited for outbound channels with + * [`ChannelHandshakeLimits::max_minimum_depth`]. + * + * This value will be `None` for outbound channels until the counterparty accepts the channel. + * + * [`is_outbound`]: ChannelDetails::is_outbound + * [`ChannelHandshakeConfig::minimum_depth`]: crate::util::config::ChannelHandshakeConfig::minimum_depth + * [`ChannelHandshakeLimits::max_minimum_depth`]: crate::util::config::ChannelHandshakeLimits::max_minimum_depth */ -enum LDKChannelMonitorUpdateErr ChannelMonitorUpdateErr_temporary_failure(void); +void ChannelDetails_set_confirmations_required(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u32Z val); /** - * Utility method to constructs a new PermanentFailure-variant ChannelMonitorUpdateErr + * The number of blocks (after our commitment transaction confirms) that we will need to wait + * until we can claim our funds after we force-close the channel. During this time our + * counterparty is allowed to punish us if we broadcasted a stale state. If our counterparty + * force-closes the channel and broadcasts a commitment transaction we do not have to wait any + * time to claim our non-HTLC-encumbered funds. + * + * This value will be `None` for outbound channels until the counterparty accepts the channel. */ -enum LDKChannelMonitorUpdateErr ChannelMonitorUpdateErr_permanent_failure(void); +struct LDKCOption_u16Z ChannelDetails_get_force_close_spend_delay(const struct LDKChannelDetails *NONNULL_PTR this_ptr); /** - * Calls the free function if one is set + * The number of blocks (after our commitment transaction confirms) that we will need to wait + * until we can claim our funds after we force-close the channel. During this time our + * counterparty is allowed to punish us if we broadcasted a stale state. If our counterparty + * force-closes the channel and broadcasts a commitment transaction we do not have to wait any + * time to claim our non-HTLC-encumbered funds. + * + * This value will be `None` for outbound channels until the counterparty accepts the channel. */ -void Watch_free(struct LDKWatch this_ptr); +void ChannelDetails_set_force_close_spend_delay(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u16Z val); /** - * Calls the free function if one is set + * True if the channel was initiated (and thus funded) by us. */ -void Filter_free(struct LDKFilter this_ptr); +bool ChannelDetails_get_is_outbound(const struct LDKChannelDetails *NONNULL_PTR this_ptr); /** - * Frees any resources used by the WatchedOutput, if is_owned is set and inner is non-NULL. + * True if the channel was initiated (and thus funded) by us. */ -void WatchedOutput_free(struct LDKWatchedOutput this_obj); +void ChannelDetails_set_is_outbound(struct LDKChannelDetails *NONNULL_PTR this_ptr, bool val); /** - * First block where the transaction output may have been spent. + * True if the channel is confirmed, channel_ready messages have been exchanged, and the + * channel is not currently being shut down. `channel_ready` message exchange implies the + * required confirmation count has been reached (and we were connected to the peer at some + * point after the funding transaction received enough confirmations). The required + * confirmation count is provided in [`confirmations_required`]. * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * [`confirmations_required`]: ChannelDetails::confirmations_required */ -struct LDKThirtyTwoBytes WatchedOutput_get_block_hash(const struct LDKWatchedOutput *NONNULL_PTR this_ptr); +bool ChannelDetails_get_is_channel_ready(const struct LDKChannelDetails *NONNULL_PTR this_ptr); /** - * First block where the transaction output may have been spent. + * True if the channel is confirmed, channel_ready messages have been exchanged, and the + * channel is not currently being shut down. `channel_ready` message exchange implies the + * required confirmation count has been reached (and we were connected to the peer at some + * point after the funding transaction received enough confirmations). The required + * confirmation count is provided in [`confirmations_required`]. * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + * [`confirmations_required`]: ChannelDetails::confirmations_required */ -void WatchedOutput_set_block_hash(struct LDKWatchedOutput *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void ChannelDetails_set_is_channel_ready(struct LDKChannelDetails *NONNULL_PTR this_ptr, bool val); /** - * Outpoint identifying the transaction output. + * True if the channel is (a) confirmed and channel_ready messages have been exchanged, (b) + * the peer is connected, and (c) the channel is not currently negotiating a shutdown. + * + * This is a strict superset of `is_channel_ready`. */ -struct LDKOutPoint WatchedOutput_get_outpoint(const struct LDKWatchedOutput *NONNULL_PTR this_ptr); +bool ChannelDetails_get_is_usable(const struct LDKChannelDetails *NONNULL_PTR this_ptr); /** - * Outpoint identifying the transaction output. + * True if the channel is (a) confirmed and channel_ready messages have been exchanged, (b) + * the peer is connected, and (c) the channel is not currently negotiating a shutdown. + * + * This is a strict superset of `is_channel_ready`. */ -void WatchedOutput_set_outpoint(struct LDKWatchedOutput *NONNULL_PTR this_ptr, struct LDKOutPoint val); +void ChannelDetails_set_is_usable(struct LDKChannelDetails *NONNULL_PTR this_ptr, bool val); /** - * Spending condition of the transaction output. + * True if this channel is (or will be) publicly-announced. */ -struct LDKu8slice WatchedOutput_get_script_pubkey(const struct LDKWatchedOutput *NONNULL_PTR this_ptr); +bool ChannelDetails_get_is_public(const struct LDKChannelDetails *NONNULL_PTR this_ptr); /** - * Spending condition of the transaction output. + * True if this channel is (or will be) publicly-announced. */ -void WatchedOutput_set_script_pubkey(struct LDKWatchedOutput *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val); +void ChannelDetails_set_is_public(struct LDKChannelDetails *NONNULL_PTR this_ptr, bool val); /** - * Constructs a new WatchedOutput given each field + * The smallest value HTLC (in msat) we will accept, for this channel. This field + * is only `None` for `ChannelDetails` objects serialized prior to LDK 0.0.107 */ -MUST_USE_RES struct LDKWatchedOutput WatchedOutput_new(struct LDKThirtyTwoBytes block_hash_arg, struct LDKOutPoint outpoint_arg, struct LDKCVec_u8Z script_pubkey_arg); +struct LDKCOption_u64Z ChannelDetails_get_inbound_htlc_minimum_msat(const struct LDKChannelDetails *NONNULL_PTR this_ptr); /** - * Creates a copy of the WatchedOutput + * The smallest value HTLC (in msat) we will accept, for this channel. This field + * is only `None` for `ChannelDetails` objects serialized prior to LDK 0.0.107 */ -struct LDKWatchedOutput WatchedOutput_clone(const struct LDKWatchedOutput *NONNULL_PTR orig); +void ChannelDetails_set_inbound_htlc_minimum_msat(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); /** - * Checks if two WatchedOutputs contain equal inner contents. + * The largest value HTLC (in msat) we currently will accept, for this channel. */ -uint64_t WatchedOutput_hash(const struct LDKWatchedOutput *NONNULL_PTR o); +struct LDKCOption_u64Z ChannelDetails_get_inbound_htlc_maximum_msat(const struct LDKChannelDetails *NONNULL_PTR this_ptr); /** - * Calls the free function if one is set + * The largest value HTLC (in msat) we currently will accept, for this channel. */ -void BroadcasterInterface_free(struct LDKBroadcasterInterface this_ptr); +void ChannelDetails_set_inbound_htlc_maximum_msat(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); /** - * Creates a copy of the ConfirmationTarget + * Set of configurable parameters that affect channel operation. + * + * This field is only `None` for `ChannelDetails` objects serialized prior to LDK 0.0.109. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -enum LDKConfirmationTarget ConfirmationTarget_clone(const enum LDKConfirmationTarget *NONNULL_PTR orig); +struct LDKChannelConfig ChannelDetails_get_config(const struct LDKChannelDetails *NONNULL_PTR this_ptr); /** - * Utility method to constructs a new Background-variant ConfirmationTarget + * Set of configurable parameters that affect channel operation. + * + * This field is only `None` for `ChannelDetails` objects serialized prior to LDK 0.0.109. + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -enum LDKConfirmationTarget ConfirmationTarget_background(void); +void ChannelDetails_set_config(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKChannelConfig val); /** - * Utility method to constructs a new Normal-variant ConfirmationTarget + * Constructs a new ChannelDetails given each field */ -enum LDKConfirmationTarget ConfirmationTarget_normal(void); +MUST_USE_RES struct LDKChannelDetails ChannelDetails_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKChannelCounterparty counterparty_arg, struct LDKOutPoint funding_txo_arg, struct LDKChannelTypeFeatures channel_type_arg, struct LDKCOption_u64Z short_channel_id_arg, struct LDKCOption_u64Z outbound_scid_alias_arg, struct LDKCOption_u64Z inbound_scid_alias_arg, uint64_t channel_value_satoshis_arg, struct LDKCOption_u64Z unspendable_punishment_reserve_arg, uint64_t user_channel_id_arg, uint64_t balance_msat_arg, uint64_t outbound_capacity_msat_arg, uint64_t next_outbound_htlc_limit_msat_arg, uint64_t inbound_capacity_msat_arg, struct LDKCOption_u32Z confirmations_required_arg, struct LDKCOption_u16Z force_close_spend_delay_arg, bool is_outbound_arg, bool is_channel_ready_arg, bool is_usable_arg, bool is_public_arg, struct LDKCOption_u64Z inbound_htlc_minimum_msat_arg, struct LDKCOption_u64Z inbound_htlc_maximum_msat_arg, struct LDKChannelConfig config_arg); /** - * Utility method to constructs a new HighPriority-variant ConfirmationTarget + * Creates a copy of the ChannelDetails */ -enum LDKConfirmationTarget ConfirmationTarget_high_priority(void); +struct LDKChannelDetails ChannelDetails_clone(const struct LDKChannelDetails *NONNULL_PTR orig); /** - * Checks if two ConfirmationTargets contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * 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. */ -bool ConfirmationTarget_eq(const enum LDKConfirmationTarget *NONNULL_PTR a, const enum LDKConfirmationTarget *NONNULL_PTR b); +MUST_USE_RES struct LDKCOption_u64Z ChannelDetails_get_inbound_payment_scid(const struct LDKChannelDetails *NONNULL_PTR this_arg); /** - * Calls the free function if one is set + * Gets the current SCID which should be used to identify this channel for outbound payments. + * This should be used in [`Route`]s to describe the first hop or in other contexts where + * we're sending or forwarding a payment outbound over this channel. + * + * This is either the [`ChannelDetails::short_channel_id`], if set, or the + * [`ChannelDetails::outbound_scid_alias`]. See those for more information. */ -void FeeEstimator_free(struct LDKFeeEstimator this_ptr); +MUST_USE_RES struct LDKCOption_u64Z ChannelDetails_get_outbound_payment_scid(const struct LDKChannelDetails *NONNULL_PTR this_arg); /** - * Frees any resources used by the MonitorUpdateId, if is_owned is set and inner is non-NULL. + * Frees any resources used by the PaymentSendFailure */ -void MonitorUpdateId_free(struct LDKMonitorUpdateId this_obj); +void PaymentSendFailure_free(struct LDKPaymentSendFailure this_ptr); /** - * Creates a copy of the MonitorUpdateId + * Creates a copy of the PaymentSendFailure */ -struct LDKMonitorUpdateId MonitorUpdateId_clone(const struct LDKMonitorUpdateId *NONNULL_PTR orig); +struct LDKPaymentSendFailure PaymentSendFailure_clone(const struct LDKPaymentSendFailure *NONNULL_PTR orig); /** - * Checks if two MonitorUpdateIds contain equal inner contents. + * Utility method to constructs a new ParameterError-variant PaymentSendFailure */ -uint64_t MonitorUpdateId_hash(const struct LDKMonitorUpdateId *NONNULL_PTR o); +struct LDKPaymentSendFailure PaymentSendFailure_parameter_error(struct LDKAPIError a); /** - * Checks if two MonitorUpdateIds contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Utility method to constructs a new PathParameterError-variant PaymentSendFailure */ -bool MonitorUpdateId_eq(const struct LDKMonitorUpdateId *NONNULL_PTR a, const struct LDKMonitorUpdateId *NONNULL_PTR b); +struct LDKPaymentSendFailure PaymentSendFailure_path_parameter_error(struct LDKCVec_CResult_NoneAPIErrorZZ a); /** - * Calls the free function if one is set + * Utility method to constructs a new AllFailedRetrySafe-variant PaymentSendFailure */ -void Persist_free(struct LDKPersist this_ptr); +struct LDKPaymentSendFailure PaymentSendFailure_all_failed_retry_safe(struct LDKCVec_APIErrorZ a); /** - * Frees any resources used by the LockedChannelMonitor, if is_owned is set and inner is non-NULL. + * Utility method to constructs a new PartialFailure-variant PaymentSendFailure */ -void LockedChannelMonitor_free(struct LDKLockedChannelMonitor this_obj); +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 ChainMonitor, if is_owned is set and inner is non-NULL. + * Frees any resources used by the PhantomRouteHints, if is_owned is set and inner is non-NULL. */ -void ChainMonitor_free(struct LDKChainMonitor this_obj); +void PhantomRouteHints_free(struct LDKPhantomRouteHints this_obj); /** - * Creates a new `ChainMonitor` used to watch on-chain activity pertaining to channels. - * - * When an optional chain source implementing [`chain::Filter`] is provided, the chain monitor - * will call back to it indicating transactions and outputs of interest. This allows clients to - * pre-filter blocks or only fetch blocks matching a compact filter. Otherwise, clients may - * always need to fetch full blocks absent another means for determining which blocks contain - * transactions relevant to the watched channels. + * The list of channels to be included in the invoice route hints. */ -MUST_USE_RES struct LDKChainMonitor ChainMonitor_new(struct LDKCOption_FilterZ chain_source, struct LDKBroadcasterInterface broadcaster, struct LDKLogger logger, struct LDKFeeEstimator feeest, struct LDKPersist persister); +struct LDKCVec_ChannelDetailsZ PhantomRouteHints_get_channels(const struct LDKPhantomRouteHints *NONNULL_PTR this_ptr); /** - * Gets the balances in the contained [`ChannelMonitor`]s which are claimable on-chain or - * claims which are awaiting confirmation. - * - * Includes the balances from each [`ChannelMonitor`] *except* those included in - * `ignored_channels`, allowing you to filter out balances from channels which are still open - * (and whose balance should likely be pulled from the [`ChannelDetails`]). - * - * See [`ChannelMonitor::get_claimable_balances`] for more details on the exact criteria for - * inclusion in the return value. + * The list of channels to be included in the invoice route hints. */ -MUST_USE_RES struct LDKCVec_BalanceZ ChainMonitor_get_claimable_balances(const struct LDKChainMonitor *NONNULL_PTR this_arg, struct LDKCVec_ChannelDetailsZ ignored_channels); +void PhantomRouteHints_set_channels(struct LDKPhantomRouteHints *NONNULL_PTR this_ptr, struct LDKCVec_ChannelDetailsZ val); /** - * Gets the [`LockedChannelMonitor`] for a given funding outpoint, returning an `Err` if no - * such [`ChannelMonitor`] is currently being monitored for. - * - * Note that the result holds a mutex over our monitor set, and should not be held - * indefinitely. + * A fake scid used for representing the phantom node's fake channel in generating the invoice + * route hints. */ -MUST_USE_RES struct LDKCResult_LockedChannelMonitorNoneZ ChainMonitor_get_monitor(const struct LDKChainMonitor *NONNULL_PTR this_arg, struct LDKOutPoint funding_txo); +uint64_t PhantomRouteHints_get_phantom_scid(const struct LDKPhantomRouteHints *NONNULL_PTR this_ptr); /** - * Lists the funding outpoint of each [`ChannelMonitor`] being monitored. - * - * Note that [`ChannelMonitor`]s are not removed when a channel is closed as they are always - * monitoring for on-chain state resolutions. + * A fake scid used for representing the phantom node's fake channel in generating the invoice + * route hints. */ -MUST_USE_RES struct LDKCVec_OutPointZ ChainMonitor_list_monitors(const struct LDKChainMonitor *NONNULL_PTR this_arg); +void PhantomRouteHints_set_phantom_scid(struct LDKPhantomRouteHints *NONNULL_PTR this_ptr, uint64_t val); /** - * Indicates the persistence of a [`ChannelMonitor`] has completed after - * [`ChannelMonitorUpdateErr::TemporaryFailure`] was returned from an update operation. - * - * Thus, the anticipated use is, at a high level: - * 1) This [`ChainMonitor`] calls [`Persist::update_persisted_channel`] which stores the - * update to disk and begins updating any remote (e.g. watchtower/backup) copies, - * returning [`ChannelMonitorUpdateErr::TemporaryFailure`], - * 2) once all remote copies are updated, you call this function with the - * `completed_update_id` that completed, and once all pending updates have completed the - * channel will be re-enabled. - * - * Returns an [`APIError::APIMisuseError`] if `funding_txo` does not match any currently - * registered [`ChannelMonitor`]s. + * The pubkey of the real backing node that would ultimately receive the payment. */ -MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChainMonitor_channel_monitor_updated(const struct LDKChainMonitor *NONNULL_PTR this_arg, struct LDKOutPoint funding_txo, struct LDKMonitorUpdateId completed_update_id); +struct LDKPublicKey PhantomRouteHints_get_real_node_pubkey(const struct LDKPhantomRouteHints *NONNULL_PTR this_ptr); /** - * Constructs a new Listen which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned Listen must be freed before this_arg is + * The pubkey of the real backing node that would ultimately receive the payment. */ -struct LDKListen ChainMonitor_as_Listen(const struct LDKChainMonitor *NONNULL_PTR this_arg); +void PhantomRouteHints_set_real_node_pubkey(struct LDKPhantomRouteHints *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Constructs a new Confirm which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned Confirm must be freed before this_arg is + * Constructs a new PhantomRouteHints given each field */ -struct LDKConfirm ChainMonitor_as_Confirm(const struct LDKChainMonitor *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKPhantomRouteHints PhantomRouteHints_new(struct LDKCVec_ChannelDetailsZ channels_arg, uint64_t phantom_scid_arg, struct LDKPublicKey real_node_pubkey_arg); /** - * Constructs a new Watch which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned Watch must be freed before this_arg is + * Creates a copy of the PhantomRouteHints */ -struct LDKWatch ChainMonitor_as_Watch(const struct LDKChainMonitor *NONNULL_PTR this_arg); +struct LDKPhantomRouteHints PhantomRouteHints_clone(const struct LDKPhantomRouteHints *NONNULL_PTR orig); /** - * Constructs a new EventsProvider which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned EventsProvider must be freed before this_arg is + * Constructs a new ChannelManager to hold several channels and route between them. + * + * This is the main \"logic hub\" for all channel-related actions, and implements + * ChannelMessageHandler. + * + * Non-proportional fees are fixed according to our risk using the provided fee estimator. + * + * Users need to notify the new ChannelManager when a new block is connected or + * disconnected using its `block_connected` and `block_disconnected` methods, starting + * from after `params.latest_hash`. */ -struct LDKEventsProvider ChainMonitor_as_EventsProvider(const struct LDKChainMonitor *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKChannelManager ChannelManager_new(struct LDKFeeEstimator fee_est, struct LDKWatch chain_monitor, struct LDKBroadcasterInterface tx_broadcaster, struct LDKLogger logger, struct LDKKeysInterface keys_manager, struct LDKUserConfig config, struct LDKChainParameters params); /** - * Frees any resources used by the ChannelMonitorUpdate, if is_owned is set and inner is non-NULL. + * Gets the current configuration applied to all new channels. */ -void ChannelMonitorUpdate_free(struct LDKChannelMonitorUpdate this_obj); +MUST_USE_RES struct LDKUserConfig ChannelManager_get_current_default_configuration(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * The sequence number of this update. Updates *must* be replayed in-order according to this - * sequence number (and updates may panic if they are not). The update_id values are strictly - * increasing and increase by one for each new update, with one exception specified below. + * Creates a new outbound channel to the given remote node and with the given value. * - * This sequence number is also used to track up to which points updates which returned - * ChannelMonitorUpdateErr::TemporaryFailure have been applied to all copies of a given - * ChannelMonitor when ChannelManager::channel_monitor_updated is called. + * `user_channel_id` will be provided back as in + * [`Event::FundingGenerationReady::user_channel_id`] to allow tracking of which events + * correspond with which `create_channel` call. Note that the `user_channel_id` defaults to 0 + * for inbound channels, so you may wish to avoid using 0 for `user_channel_id` here. + * `user_channel_id` has no meaning inside of LDK, it is simply copied to events and otherwise + * ignored. * - * The only instance where update_id values are not strictly increasing is the case where we - * allow post-force-close updates with a special update ID of [`CLOSED_CHANNEL_UPDATE_ID`]. See - * its docs for more details. + * Raises [`APIError::APIMisuseError`] when `channel_value_satoshis` > 2**24 or `push_msat` is + * greater than `channel_value_satoshis * 1k` or `channel_value_satoshis < 1000`. + * + * Note that we do not check if you are currently connected to the given peer. If no + * connection is available, the outbound `open_channel` message may fail to send, resulting in + * the channel eventually being silently forgotten (dropped on reload). + * + * Returns the new Channel's temporary `channel_id`. This ID will appear as + * [`Event::FundingGenerationReady::temporary_channel_id`] and in + * [`ChannelDetails::channel_id`] until after + * [`ChannelManager::funding_transaction_generated`] is called, swapping the Channel's ID for + * one derived from the funding transaction's TXID. If the counterparty rejects the channel + * immediately, this temporary ID will appear in [`Event::ChannelClosed::channel_id`]. + * + * [`Event::FundingGenerationReady::user_channel_id`]: events::Event::FundingGenerationReady::user_channel_id + * [`Event::FundingGenerationReady::temporary_channel_id`]: events::Event::FundingGenerationReady::temporary_channel_id + * [`Event::ChannelClosed::channel_id`]: events::Event::ChannelClosed::channel_id + * + * Note that override_config (or a relevant inner pointer) may be NULL or all-0s to represent None */ -uint64_t ChannelMonitorUpdate_get_update_id(const struct LDKChannelMonitorUpdate *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCResult__u832APIErrorZ ChannelManager_create_channel(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKPublicKey their_network_key, uint64_t channel_value_satoshis, uint64_t push_msat, uint64_t user_channel_id, struct LDKUserConfig override_config); /** - * The sequence number of this update. Updates *must* be replayed in-order according to this - * sequence number (and updates may panic if they are not). The update_id values are strictly - * increasing and increase by one for each new update, with one exception specified below. - * - * This sequence number is also used to track up to which points updates which returned - * ChannelMonitorUpdateErr::TemporaryFailure have been applied to all copies of a given - * ChannelMonitor when ChannelManager::channel_monitor_updated is called. - * - * The only instance where update_id values are not strictly increasing is the case where we - * allow post-force-close updates with a special update ID of [`CLOSED_CHANNEL_UPDATE_ID`]. See - * its docs for more details. + * Gets the list of open channels, in random order. See ChannelDetail field documentation for + * more information. */ -void ChannelMonitorUpdate_set_update_id(struct LDKChannelMonitorUpdate *NONNULL_PTR this_ptr, uint64_t val); +MUST_USE_RES struct LDKCVec_ChannelDetailsZ ChannelManager_list_channels(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * Creates a copy of the ChannelMonitorUpdate + * Gets the list of usable channels, in random order. Useful as an argument to [`find_route`] + * to ensure non-announced channels are used. + * + * These are guaranteed to have their [`ChannelDetails::is_usable`] value set to true, see the + * documentation for [`ChannelDetails::is_usable`] for more info on exactly what the criteria + * are. + * + * [`find_route`]: crate::routing::router::find_route */ -struct LDKChannelMonitorUpdate ChannelMonitorUpdate_clone(const struct LDKChannelMonitorUpdate *NONNULL_PTR orig); +MUST_USE_RES struct LDKCVec_ChannelDetailsZ ChannelManager_list_usable_channels(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * Serialize the ChannelMonitorUpdate object into a byte array which can be read by ChannelMonitorUpdate_read + * Begins the process of closing a channel. After this call (plus some timeout), no new HTLCs + * will be accepted on the given channel, and after additional timeout/the closing of all + * pending HTLCs, the channel will be closed on chain. + * + * * If we are the channel initiator, we will pay between our [`Background`] and + * [`ChannelConfig::force_close_avoidance_max_fee_satoshis`] plus our [`Normal`] fee + * estimate. + * * If our counterparty is the channel initiator, we will require a channel closing + * transaction feerate of at least our [`Background`] feerate or the feerate which + * would appear on a force-closure transaction, whichever is lower. We will allow our + * counterparty to pay as much fee as they'd like, however. + * + * May generate a SendShutdown message event on success, which should be relayed. + * + * [`ChannelConfig::force_close_avoidance_max_fee_satoshis`]: crate::util::config::ChannelConfig::force_close_avoidance_max_fee_satoshis + * [`Background`]: crate::chain::chaininterface::ConfirmationTarget::Background + * [`Normal`]: crate::chain::chaininterface::ConfirmationTarget::Normal */ -struct LDKCVec_u8Z ChannelMonitorUpdate_write(const struct LDKChannelMonitorUpdate *NONNULL_PTR obj); +MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_close_channel(const struct LDKChannelManager *NONNULL_PTR this_arg, const uint8_t (*channel_id)[32], struct LDKPublicKey counterparty_node_id); /** - * Read a ChannelMonitorUpdate from a byte array, created by ChannelMonitorUpdate_write + * Begins the process of closing a channel. After this call (plus some timeout), no new HTLCs + * will be accepted on the given channel, and after additional timeout/the closing of all + * pending HTLCs, the channel will be closed on chain. + * + * `target_feerate_sat_per_1000_weight` has different meanings depending on if we initiated + * the channel being closed or not: + * * If we are the channel initiator, we will pay at least this feerate on the closing + * transaction. The upper-bound is set by + * [`ChannelConfig::force_close_avoidance_max_fee_satoshis`] plus our [`Normal`] fee + * estimate (or `target_feerate_sat_per_1000_weight`, if it is greater). + * * If our counterparty is the channel initiator, we will refuse to accept a channel closure + * transaction feerate below `target_feerate_sat_per_1000_weight` (or the feerate which + * will appear on a force-closure transaction, whichever is lower). + * + * May generate a SendShutdown message event on success, which should be relayed. + * + * [`ChannelConfig::force_close_avoidance_max_fee_satoshis`]: crate::util::config::ChannelConfig::force_close_avoidance_max_fee_satoshis + * [`Background`]: crate::chain::chaininterface::ConfirmationTarget::Background + * [`Normal`]: crate::chain::chaininterface::ConfirmationTarget::Normal */ -struct LDKCResult_ChannelMonitorUpdateDecodeErrorZ ChannelMonitorUpdate_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_close_channel_with_target_feerate(const struct LDKChannelManager *NONNULL_PTR this_arg, const uint8_t (*channel_id)[32], struct LDKPublicKey counterparty_node_id, uint32_t target_feerate_sats_per_1000_weight); /** - * Frees any resources used by the MonitorEvent + * Force closes a channel, immediately broadcasting the latest local transaction(s) and + * rejecting new HTLCs on the given channel. Fails if `channel_id` is unknown to + * the manager, or if the `counterparty_node_id` isn't the counterparty of the corresponding + * channel. */ -void MonitorEvent_free(struct LDKMonitorEvent this_ptr); +MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_force_close_broadcasting_latest_txn(const struct LDKChannelManager *NONNULL_PTR this_arg, const uint8_t (*channel_id)[32], struct LDKPublicKey counterparty_node_id); /** - * Creates a copy of the MonitorEvent + * Force closes a channel, rejecting new HTLCs on the given channel but skips broadcasting + * the latest local transaction(s). Fails if `channel_id` is unknown to the manager, or if the + * `counterparty_node_id` isn't the counterparty of the corresponding channel. + * + * You can always get the latest local transaction(s) to broadcast from + * [`ChannelMonitor::get_latest_holder_commitment_txn`]. */ -struct LDKMonitorEvent MonitorEvent_clone(const struct LDKMonitorEvent *NONNULL_PTR orig); +MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_force_close_without_broadcasting_txn(const struct LDKChannelManager *NONNULL_PTR this_arg, const uint8_t (*channel_id)[32], struct LDKPublicKey counterparty_node_id); /** - * Utility method to constructs a new HTLCEvent-variant MonitorEvent + * Force close all channels, immediately broadcasting the latest local commitment transaction + * for each to the chain and rejecting new HTLCs on each. */ -struct LDKMonitorEvent MonitorEvent_htlcevent(struct LDKHTLCUpdate a); +void ChannelManager_force_close_all_channels_broadcasting_latest_txn(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * Utility method to constructs a new CommitmentTxConfirmed-variant MonitorEvent + * Force close all channels rejecting new HTLCs on each but without broadcasting the latest + * local transaction(s). */ -struct LDKMonitorEvent MonitorEvent_commitment_tx_confirmed(struct LDKOutPoint a); +void ChannelManager_force_close_all_channels_without_broadcasting_txn(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * Utility method to constructs a new UpdateCompleted-variant MonitorEvent + * Sends a payment along a given route. + * + * Value parameters are provided via the last hop in route, see documentation for RouteHop + * fields for more info. + * + * Note that if the payment_hash already exists elsewhere (eg you're sending a duplicative + * payment), we don't do anything to stop you! We always try to ensure that if the provided + * next hop knows the preimage to payment_hash they can claim an additional amount as + * specified in the last hop in the route! Thus, you should probably do your own + * payment_preimage tracking (which you should already be doing as they represent \"proof of + * payment\") and prevent double-sends yourself. + * + * May generate SendHTLCs message(s) event on success, which should be relayed. + * + * Each path may have a different return value, and PaymentSendValue may return a Vec with + * each entry matching the corresponding-index entry in the route paths, see + * PaymentSendFailure for more info. + * + * In general, a path may raise: + * * [`APIError::RouteError`] when an invalid route or forwarding parameter (cltv_delta, fee, + * node public key) is specified. + * * [`APIError::ChannelUnavailable`] if the next-hop channel is not available for updates + * (including due to previous monitor update failure or new permanent monitor update + * failure). + * * [`APIError::MonitorUpdateInProgress`] if a new monitor update failure prevented sending the + * relevant updates. + * + * Note that depending on the type of the PaymentSendFailure the HTLC may have been + * irrevocably committed to on our end. In such a case, do NOT retry the payment with a + * different route unless you intend to pay twice! + * + * payment_secret is unrelated to payment_hash (or PaymentPreimage) and exists to authenticate + * the sender to the recipient and prevent payment-probing (deanonymization) attacks. For + * newer nodes, it will be provided to you in the invoice. If you do not have one, the Route + * must not contain multiple paths as multi-path payments require a recipient-provided + * payment_secret. + * If a payment_secret *is* provided, we assume that the invoice had the payment_secret feature + * bit set (either as required or as available). If multiple paths are present in the Route, + * we assume the invoice had the basic_mpp feature set. + * + * Note that payment_secret (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKMonitorEvent MonitorEvent_update_completed(struct LDKOutPoint funding_txo, uint64_t monitor_update_id); +MUST_USE_RES struct LDKCResult_PaymentIdPaymentSendFailureZ ChannelManager_send_payment(const struct LDKChannelManager *NONNULL_PTR this_arg, const struct LDKRoute *NONNULL_PTR route, struct LDKThirtyTwoBytes payment_hash, struct LDKThirtyTwoBytes payment_secret); /** - * Utility method to constructs a new UpdateFailed-variant MonitorEvent + * Retries a payment along the given [`Route`]. + * + * 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, 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`] */ -struct LDKMonitorEvent MonitorEvent_update_failed(struct LDKOutPoint a); +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); /** - * Serialize the MonitorEvent object into a byte array which can be read by MonitorEvent_read + * 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 */ -struct LDKCVec_u8Z MonitorEvent_write(const struct LDKMonitorEvent *NONNULL_PTR obj); +void ChannelManager_abandon_payment(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes payment_id); /** - * Read a MonitorEvent from a byte array, created by MonitorEvent_write + * 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 + * the preimage, it must be a cryptographically secure random value that no intermediate node + * would be able to guess -- otherwise, an intermediate node may claim the payment and it will + * never reach the recipient. + * + * See [`send_payment`] documentation for more details on the return value of this function. + * + * Similar to regular payments, you MUST NOT reuse a `payment_preimage` value. See + * [`send_payment`] for more information about the risks of duplicate preimage usage. + * + * Note that `route` must have exactly one path. + * + * [`send_payment`]: Self::send_payment + * + * Note that payment_preimage (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKCResult_COption_MonitorEventZDecodeErrorZ MonitorEvent_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ ChannelManager_send_spontaneous_payment(const struct LDKChannelManager *NONNULL_PTR this_arg, const struct LDKRoute *NONNULL_PTR route, struct LDKThirtyTwoBytes payment_preimage); /** - * Frees any resources used by the HTLCUpdate, if is_owned is set and inner is non-NULL. + * Send a payment that is probing the given route for liquidity. We calculate the + * [`PaymentHash`] of probes based on a static secret and a random [`PaymentId`], which allows + * us to easily discern them from real payments. */ -void HTLCUpdate_free(struct LDKHTLCUpdate this_obj); +MUST_USE_RES struct LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ ChannelManager_send_probe(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKCVec_RouteHopZ hops); /** - * Creates a copy of the HTLCUpdate + * Call this upon creation of a funding transaction for the given channel. + * + * 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`]. + * + * Returns [`APIError::APIMisuseError`] if the funding transaction is not final for propagation + * across the p2p network. + * + * 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 + * keys per-channel). + * + * Do NOT broadcast the funding transaction yourself. When we have safely received our + * counterparty's signature the funding transaction will automatically be broadcast via the + * [`BroadcasterInterface`] provided when this `ChannelManager` was constructed. + * + * Note that this includes RBF or similar transaction replacement strategies - lightning does + * not currently support replacing a funding transaction on an existing channel. Instead, + * create a new channel with a conflicting funding transaction. + * + * Note to keep the miner incentives aligned in moving the blockchain forward, we recommend + * the wallet software generating the funding transaction to apply anti-fee sniping as + * implemented by Bitcoin Core wallet. See + * for more details. + * + * [`Event::FundingGenerationReady`]: crate::util::events::Event::FundingGenerationReady + * [`Event::ChannelClosed`]: crate::util::events::Event::ChannelClosed */ -struct LDKHTLCUpdate HTLCUpdate_clone(const struct LDKHTLCUpdate *NONNULL_PTR orig); +MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_funding_transaction_generated(const struct LDKChannelManager *NONNULL_PTR this_arg, const uint8_t (*temporary_channel_id)[32], struct LDKPublicKey counterparty_node_id, struct LDKTransaction funding_transaction); /** - * Serialize the HTLCUpdate object into a byte array which can be read by HTLCUpdate_read + * Atomically updates the [`ChannelConfig`] for the given channels. + * + * Once the updates are applied, each eligible channel (advertised with a known short channel + * ID and a change in [`forwarding_fee_proportional_millionths`], [`forwarding_fee_base_msat`], + * or [`cltv_expiry_delta`]) has a [`BroadcastChannelUpdate`] event message generated + * containing the new [`ChannelUpdate`] message which should be broadcast to the network. + * + * Returns [`ChannelUnavailable`] when a channel is not found or an incorrect + * `counterparty_node_id` is provided. + * + * Returns [`APIMisuseError`] when a [`cltv_expiry_delta`] update is to be applied with a value + * below [`MIN_CLTV_EXPIRY_DELTA`]. + * + * If an error is returned, none of the updates should be considered applied. + * + * [`forwarding_fee_proportional_millionths`]: ChannelConfig::forwarding_fee_proportional_millionths + * [`forwarding_fee_base_msat`]: ChannelConfig::forwarding_fee_base_msat + * [`cltv_expiry_delta`]: ChannelConfig::cltv_expiry_delta + * [`BroadcastChannelUpdate`]: events::MessageSendEvent::BroadcastChannelUpdate + * [`ChannelUpdate`]: msgs::ChannelUpdate + * [`ChannelUnavailable`]: APIError::ChannelUnavailable + * [`APIMisuseError`]: APIError::APIMisuseError */ -struct LDKCVec_u8Z HTLCUpdate_write(const struct LDKHTLCUpdate *NONNULL_PTR obj); +MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_update_channel_config(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKPublicKey counterparty_node_id, struct LDKCVec_ThirtyTwoBytesZ channel_ids, const struct LDKChannelConfig *NONNULL_PTR config); /** - * Read a HTLCUpdate from a byte array, created by HTLCUpdate_write + * Processes HTLCs which are pending waiting on random forward delay. + * + * Should only really ever be called in response to a PendingHTLCsForwardable event. + * Will likely generate further events. */ -struct LDKCResult_HTLCUpdateDecodeErrorZ HTLCUpdate_read(struct LDKu8slice ser); +void ChannelManager_process_pending_htlc_forwards(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * Frees any resources used by the Balance + * Performs actions which should happen on startup and roughly once per minute thereafter. + * + * This currently includes: + * * Increasing or decreasing the on-chain feerate estimates for our outbound channels, + * * Broadcasting `ChannelUpdate` messages if we've been disconnected from our peer for more + * than a minute, informing the network that they should no longer attempt to route over + * the channel. + * * Expiring a channel's previous `ChannelConfig` if necessary to only allow forwarding HTLCs + * with the current `ChannelConfig`. + * + * Note that this may cause reentrancy through `chain::Watch::update_channel` calls or feerate + * estimate fetches. */ -void Balance_free(struct LDKBalance this_ptr); +void ChannelManager_timer_tick_occurred(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * Creates a copy of the Balance + * Indicates that the preimage for payment_hash is unknown or the received amount is incorrect + * after a PaymentReceived event, failing the HTLC back to its origin and freeing resources + * along the path (including in our own channel on which we received it). + * + * Note that in some cases around unclean shutdown, it is possible the payment may have + * already been claimed by you via [`ChannelManager::claim_funds`] prior to you seeing (a + * second copy of) the [`events::Event::PaymentReceived`] event. Alternatively, the payment + * may have already been failed automatically by LDK if it was nearing its expiration time. + * + * While LDK will never claim a payment automatically on your behalf (i.e. without you calling + * [`ChannelManager::claim_funds`]), you should still monitor for + * [`events::Event::PaymentClaimed`] events even for payments you intend to fail, especially on + * startup during which time claims that were in-progress at shutdown may be replayed. */ -struct LDKBalance Balance_clone(const struct LDKBalance *NONNULL_PTR orig); +void ChannelManager_fail_htlc_backwards(const struct LDKChannelManager *NONNULL_PTR this_arg, const uint8_t (*payment_hash)[32]); /** - * Utility method to constructs a new ClaimableOnChannelClose-variant Balance + * Provides a payment preimage in response to [`Event::PaymentReceived`], generating any + * [`MessageSendEvent`]s needed to claim the payment. + * + * Note that calling this method does *not* guarantee that the payment has been claimed. You + * *must* wait for an [`Event::PaymentClaimed`] event which upon a successful claim will be + * provided to your [`EventHandler`] when [`process_pending_events`] is next called. + * + * 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. + * + * [`Event::PaymentReceived`]: crate::util::events::Event::PaymentReceived + * [`Event::PaymentClaimed`]: crate::util::events::Event::PaymentClaimed + * [`process_pending_events`]: EventsProvider::process_pending_events + * [`create_inbound_payment`]: Self::create_inbound_payment + * [`create_inbound_payment_for_hash`]: Self::create_inbound_payment_for_hash + * [`get_and_clear_pending_msg_events`]: MessageSendEventsProvider::get_and_clear_pending_msg_events */ -struct LDKBalance Balance_claimable_on_channel_close(uint64_t claimable_amount_satoshis); +void ChannelManager_claim_funds(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes payment_preimage); /** - * Utility method to constructs a new ClaimableAwaitingConfirmations-variant Balance + * Gets the node_id held by this ChannelManager */ -struct LDKBalance Balance_claimable_awaiting_confirmations(uint64_t claimable_amount_satoshis, uint32_t confirmation_height); +MUST_USE_RES struct LDKPublicKey ChannelManager_get_our_node_id(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * Utility method to constructs a new ContentiousClaimable-variant Balance + * Accepts a request to open a channel after a [`Event::OpenChannelRequest`]. + * + * The `temporary_channel_id` parameter indicates which inbound channel should be accepted, + * and the `counterparty_node_id` parameter is the id of the peer which has requested to open + * the channel. + * + * 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`/`accept_inbound_channel_from_trusted_peer_0conf` call. + * + * Note that this method will return an error and reject the channel, if it requires support + * for zero confirmations. Instead, `accept_inbound_channel_from_trusted_peer_0conf` must be + * used to accept such channels. + * + * [`Event::OpenChannelRequest`]: events::Event::OpenChannelRequest + * [`Event::ChannelClosed::user_channel_id`]: events::Event::ChannelClosed::user_channel_id */ -struct LDKBalance Balance_contentious_claimable(uint64_t claimable_amount_satoshis, uint32_t timeout_height); +MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_accept_inbound_channel(const struct LDKChannelManager *NONNULL_PTR this_arg, const uint8_t (*temporary_channel_id)[32], struct LDKPublicKey counterparty_node_id, uint64_t user_channel_id); /** - * Utility method to constructs a new MaybeClaimableHTLCAwaitingTimeout-variant Balance + * Accepts a request to open a channel after a [`events::Event::OpenChannelRequest`], treating + * it as confirmed immediately. + * + * 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`/`accept_inbound_channel_from_trusted_peer_0conf` call. + * + * Unlike [`ChannelManager::accept_inbound_channel`], this method accepts the incoming channel + * and (if the counterparty agrees), enables forwarding of payments immediately. + * + * This fully trusts that the counterparty has honestly and correctly constructed the funding + * transaction and blindly assumes that it will eventually confirm. + * + * If it does not confirm before we decide to close the channel, or if the funding transaction + * does not pay to the correct script the correct amount, *you will lose funds*. + * + * [`Event::OpenChannelRequest`]: events::Event::OpenChannelRequest + * [`Event::ChannelClosed::user_channel_id`]: events::Event::ChannelClosed::user_channel_id */ -struct LDKBalance Balance_maybe_claimable_htlcawaiting_timeout(uint64_t claimable_amount_satoshis, uint32_t claimable_height); +MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_accept_inbound_channel_from_trusted_peer_0conf(const struct LDKChannelManager *NONNULL_PTR this_arg, const uint8_t (*temporary_channel_id)[32], struct LDKPublicKey counterparty_node_id, uint64_t user_channel_id); /** - * Checks if two Balances contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * 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. + * + * 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 + * passed directly to [`claim_funds`]. + * + * 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 */ -bool Balance_eq(const struct LDKBalance *NONNULL_PTR a, const struct LDKBalance *NONNULL_PTR b); +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); /** - * Frees any resources used by the ChannelMonitor, if is_owned is set and inner is non-NULL. + * 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 */ -void ChannelMonitor_free(struct LDKChannelMonitor this_obj); +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); /** - * Serialize the ChannelMonitor object into a byte array which can be read by ChannelMonitor_read + * Gets a [`PaymentSecret`] for a given [`PaymentHash`], for which the payment preimage is + * stored external to LDK. + * + * A [`PaymentReceived`] event will only be generated if the [`PaymentSecret`] matches a + * 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`]) 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` + * before a [`PaymentReceived`] event will be generated, ensuring that we do not provide the + * sender \"proof-of-payment\" unless they have paid the required amount. + * + * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for + * in excess of the current time. This should roughly match the expiry time set in the invoice. + * After this many seconds, we will remove the inbound payment, resulting in any attempts to + * pay the invoice failing. The BOLT spec suggests 3,600 secs as a default validity time for + * invoices when no timeout is set. + * + * Note that we use block header time to time-out pending inbound payments (with some margin + * to compensate for the inaccuracy of block header timestamps). Thus, in practice we will + * accept a payment and generate a [`PaymentReceived`] event for some time after the expiry. + * If you need exact expiry semantics, you should enforce them upon receipt of + * [`PaymentReceived`]. + * + * 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 */ -struct LDKCVec_u8Z ChannelMonitor_write(const struct LDKChannelMonitor *NONNULL_PTR obj); +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); /** - * Updates a ChannelMonitor on the basis of some new information provided by the Channel - * itself. + * 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. * - * panics if the given update is not the next update by update_id. + * 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_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); +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 the update_id from the latest ChannelMonitorUpdate which was applied to this - * ChannelMonitor. + * 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 uint64_t ChannelMonitor_get_latest_update_id(const struct LDKChannelMonitor *NONNULL_PTR this_arg); +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 the funding transaction outpoint of the channel this ChannelMonitor is monitoring for. + * 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 struct LDKC2Tuple_OutPointScriptZ ChannelMonitor_get_funding_txo(const struct LDKChannelMonitor *NONNULL_PTR this_arg); +MUST_USE_RES uint64_t ChannelManager_get_phantom_scid(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * Gets a list of txids, with their output scripts (in the order they appear in the - * transaction), which we must learn about spends of via block_connected(). + * Gets route hints for use in receiving [phantom node payments]. + * + * [phantom node payments]: crate::chain::keysinterface::PhantomKeysManager */ -MUST_USE_RES struct LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ChannelMonitor_get_outputs_to_watch(const struct LDKChannelMonitor *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKPhantomRouteHints ChannelManager_get_phantom_route_hints(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * Loads the funding txo and outputs to watch into the given `chain::Filter` by repeatedly - * calling `chain::Filter::register_output` and `chain::Filter::register_tx` until all outputs - * have been registered. + * Constructs a new MessageSendEventsProvider which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned MessageSendEventsProvider must be freed before this_arg is */ -void ChannelMonitor_load_outputs_to_watch(const struct LDKChannelMonitor *NONNULL_PTR this_arg, const struct LDKFilter *NONNULL_PTR filter); +struct LDKMessageSendEventsProvider ChannelManager_as_MessageSendEventsProvider(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * Get the list of HTLCs who's status has been updated on chain. This should be called by - * ChannelManager via [`chain::Watch::release_pending_monitor_events`]. + * Constructs a new EventsProvider which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned EventsProvider must be freed before this_arg is */ -MUST_USE_RES struct LDKCVec_MonitorEventZ ChannelMonitor_get_and_clear_pending_monitor_events(const struct LDKChannelMonitor *NONNULL_PTR this_arg); +struct LDKEventsProvider ChannelManager_as_EventsProvider(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * Gets the list of pending events which were generated by previous actions, clearing the list - * in the process. - * - * This is called by ChainMonitor::get_and_clear_pending_events() and is equivalent to - * EventsProvider::get_and_clear_pending_events() except that it requires &mut self as we do - * no internal locking in ChannelMonitors. + * Constructs a new Listen which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned Listen must be freed before this_arg is */ -MUST_USE_RES struct LDKCVec_EventZ ChannelMonitor_get_and_clear_pending_events(const struct LDKChannelMonitor *NONNULL_PTR this_arg); +struct LDKListen ChannelManager_as_Listen(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * Used by ChannelManager deserialization to broadcast the latest holder state if its copy of - * the Channel was out-of-date. You may use it to get a broadcastable holder toxic tx in case of - * fallen-behind, i.e when receiving a channel_reestablish with a proof that our counterparty side knows - * a higher revocation secret than the holder commitment number we are aware of. Broadcasting these - * transactions are UNSAFE, as they allow counterparty side to punish you. Nevertheless you may want to - * broadcast them if counterparty don't close channel with his higher commitment transaction after a - * substantial amount of time (a month or even a year) to get back funds. Best may be to contact - * out-of-band the other node operator to coordinate with him if option is available to you. - * In any-case, choice is up to the user. + * Constructs a new Confirm which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned Confirm must be freed before this_arg is */ -MUST_USE_RES struct LDKCVec_TransactionZ ChannelMonitor_get_latest_holder_commitment_txn(const struct LDKChannelMonitor *NONNULL_PTR this_arg, const struct LDKLogger *NONNULL_PTR logger); +struct LDKConfirm ChannelManager_as_Confirm(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * Processes transactions in a newly connected block, which may result in any of the following: - * - update the monitor's state against resolved HTLCs - * - punish the counterparty in the case of seeing a revoked commitment transaction - * - force close the channel and claim/timeout incoming/outgoing HTLCs if near expiration - * - detect settled outputs for later spending - * - schedule and bump any in-flight claims - * - * Returns any new outputs to watch from `txdata`; after called, these are also included in - * [`get_outputs_to_watch`]. + * Blocks until ChannelManager needs to be persisted or a timeout is reached. It returns a bool + * indicating whether persistence is necessary. Only one listener on + * `await_persistable_update` or `await_persistable_update_timeout` is guaranteed to be woken + * up. * - * [`get_outputs_to_watch`]: #method.get_outputs_to_watch + * Note that this method is not available with the `no-std` feature. */ -MUST_USE_RES struct LDKCVec_TransactionOutputsZ ChannelMonitor_block_connected(const struct LDKChannelMonitor *NONNULL_PTR this_arg, const uint8_t (*header)[80], struct LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height, struct LDKBroadcasterInterface broadcaster, struct LDKFeeEstimator fee_estimator, struct LDKLogger logger); +MUST_USE_RES bool ChannelManager_await_persistable_update_timeout(const struct LDKChannelManager *NONNULL_PTR this_arg, uint64_t max_wait); /** - * Determines if the disconnected block contained any transactions of interest and updates - * appropriately. + * Blocks until ChannelManager needs to be persisted. Only one listener on + * `await_persistable_update` or `await_persistable_update_timeout` is guaranteed to be woken + * up. */ -void ChannelMonitor_block_disconnected(const struct LDKChannelMonitor *NONNULL_PTR this_arg, const uint8_t (*header)[80], uint32_t height, struct LDKBroadcasterInterface broadcaster, struct LDKFeeEstimator fee_estimator, struct LDKLogger logger); +void ChannelManager_await_persistable_update(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * Processes transactions confirmed in a block with the given header and height, returning new - * outputs to watch. See [`block_connected`] for details. - * - * Used instead of [`block_connected`] by clients that are notified of transactions rather than - * blocks. See [`chain::Confirm`] for calling expectations. - * - * [`block_connected`]: Self::block_connected + * Gets a [`Future`] that completes when a persistable update is available. Note that + * callbacks registered on the [`Future`] MUST NOT call back into this [`ChannelManager`] and + * should instead register actions to be taken later. */ -MUST_USE_RES struct LDKCVec_TransactionOutputsZ ChannelMonitor_transactions_confirmed(const struct LDKChannelMonitor *NONNULL_PTR this_arg, const uint8_t (*header)[80], struct LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height, struct LDKBroadcasterInterface broadcaster, struct LDKFeeEstimator fee_estimator, struct LDKLogger logger); +MUST_USE_RES struct LDKFuture ChannelManager_get_persistable_update_future(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * Processes a transaction that was reorganized out of the chain. - * - * Used instead of [`block_disconnected`] by clients that are notified of transactions rather - * than blocks. See [`chain::Confirm`] for calling expectations. - * - * [`block_disconnected`]: Self::block_disconnected + * Gets the latest best block which was connected either via the [`chain::Listen`] or + * [`chain::Confirm`] interfaces. */ -void ChannelMonitor_transaction_unconfirmed(const struct LDKChannelMonitor *NONNULL_PTR this_arg, const uint8_t (*txid)[32], struct LDKBroadcasterInterface broadcaster, struct LDKFeeEstimator fee_estimator, struct LDKLogger logger); +MUST_USE_RES struct LDKBestBlock ChannelManager_current_best_block(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * Updates the monitor with the current best chain tip, returning new outputs to watch. See - * [`block_connected`] for details. - * - * Used instead of [`block_connected`] by clients that are notified of transactions rather than - * blocks. See [`chain::Confirm`] for calling expectations. - * - * [`block_connected`]: Self::block_connected + * 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 */ -MUST_USE_RES struct LDKCVec_TransactionOutputsZ ChannelMonitor_best_block_updated(const struct LDKChannelMonitor *NONNULL_PTR this_arg, const uint8_t (*header)[80], uint32_t height, struct LDKBroadcasterInterface broadcaster, struct LDKFeeEstimator fee_estimator, struct LDKLogger logger); +struct LDKChannelMessageHandler ChannelManager_as_ChannelMessageHandler(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * Returns the set of txids that should be monitored for re-organization out of the chain. + * Fetches the set of [`NodeFeatures`] flags which are provided by or required by + * [`ChannelManager`]. */ -MUST_USE_RES struct LDKCVec_TxidZ ChannelMonitor_get_relevant_txids(const struct LDKChannelMonitor *NONNULL_PTR this_arg); +struct LDKNodeFeatures provided_node_features(void); /** - * Gets the latest best block which was connected either via the [`chain::Listen`] or - * [`chain::Confirm`] interfaces. + * Fetches the set of [`ChannelFeatures`] flags which are provided by or required by + * [`ChannelManager`]. */ -MUST_USE_RES struct LDKBestBlock ChannelMonitor_current_best_block(const struct LDKChannelMonitor *NONNULL_PTR this_arg); +struct LDKChannelFeatures provided_channel_features(void); /** - * Gets the balances in this channel which are either claimable by us if we were to - * force-close the channel now or which are claimable on-chain (possibly awaiting - * confirmation). - * - * Any balances in the channel which are available on-chain (excluding on-chain fees) are - * included here until an [`Event::SpendableOutputs`] event has been generated for the - * balance, or until our counterparty has claimed the balance and accrued several - * confirmations on the claim transaction. - * - * Note that the balances available when you or your counterparty have broadcasted revoked - * state(s) may not be fully captured here. - * - * See [`Balance`] for additional details on the types of claimable balances which - * may be returned here and their meanings. + * Fetches the set of [`InitFeatures`] flags which are provided by or required by + * [`ChannelManager`]. */ -MUST_USE_RES struct LDKCVec_BalanceZ ChannelMonitor_get_claimable_balances(const struct LDKChannelMonitor *NONNULL_PTR this_arg); +struct LDKInitFeatures provided_init_features(void); /** - * Read a C2Tuple_BlockHashChannelMonitorZ from a byte array, created by C2Tuple_BlockHashChannelMonitorZ_write + * Serialize the CounterpartyForwardingInfo object into a byte array which can be read by CounterpartyForwardingInfo_read */ -struct LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ C2Tuple_BlockHashChannelMonitorZ_read(struct LDKu8slice ser, const struct LDKKeysInterface *NONNULL_PTR arg); +struct LDKCVec_u8Z CounterpartyForwardingInfo_write(const struct LDKCounterpartyForwardingInfo *NONNULL_PTR obj); /** - * Frees any resources used by the OutPoint, if is_owned is set and inner is non-NULL. + * Read a CounterpartyForwardingInfo from a byte array, created by CounterpartyForwardingInfo_write */ -void OutPoint_free(struct LDKOutPoint this_obj); +struct LDKCResult_CounterpartyForwardingInfoDecodeErrorZ CounterpartyForwardingInfo_read(struct LDKu8slice ser); /** - * The referenced transaction's txid. + * Serialize the ChannelCounterparty object into a byte array which can be read by ChannelCounterparty_read */ -const uint8_t (*OutPoint_get_txid(const struct LDKOutPoint *NONNULL_PTR this_ptr))[32]; +struct LDKCVec_u8Z ChannelCounterparty_write(const struct LDKChannelCounterparty *NONNULL_PTR obj); /** - * The referenced transaction's txid. + * Read a ChannelCounterparty from a byte array, created by ChannelCounterparty_write */ -void OutPoint_set_txid(struct LDKOutPoint *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKCResult_ChannelCounterpartyDecodeErrorZ ChannelCounterparty_read(struct LDKu8slice ser); /** - * The index of the referenced output in its transaction's vout. + * Serialize the ChannelDetails object into a byte array which can be read by ChannelDetails_read */ -uint16_t OutPoint_get_index(const struct LDKOutPoint *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z ChannelDetails_write(const struct LDKChannelDetails *NONNULL_PTR obj); /** - * The index of the referenced output in its transaction's vout. + * Read a ChannelDetails from a byte array, created by ChannelDetails_write */ -void OutPoint_set_index(struct LDKOutPoint *NONNULL_PTR this_ptr, uint16_t val); +struct LDKCResult_ChannelDetailsDecodeErrorZ ChannelDetails_read(struct LDKu8slice ser); /** - * Constructs a new OutPoint given each field + * Serialize the PhantomRouteHints object into a byte array which can be read by PhantomRouteHints_read */ -MUST_USE_RES struct LDKOutPoint OutPoint_new(struct LDKThirtyTwoBytes txid_arg, uint16_t index_arg); +struct LDKCVec_u8Z PhantomRouteHints_write(const struct LDKPhantomRouteHints *NONNULL_PTR obj); /** - * Creates a copy of the OutPoint + * Read a PhantomRouteHints from a byte array, created by PhantomRouteHints_write */ -struct LDKOutPoint OutPoint_clone(const struct LDKOutPoint *NONNULL_PTR orig); +struct LDKCResult_PhantomRouteHintsDecodeErrorZ PhantomRouteHints_read(struct LDKu8slice ser); /** - * Checks if two OutPoints contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Serialize the ChannelManager object into a byte array which can be read by ChannelManager_read */ -bool OutPoint_eq(const struct LDKOutPoint *NONNULL_PTR a, const struct LDKOutPoint *NONNULL_PTR b); +struct LDKCVec_u8Z ChannelManager_write(const struct LDKChannelManager *NONNULL_PTR obj); /** - * Checks if two OutPoints contain equal inner contents. + * Frees any resources used by the ChannelManagerReadArgs, if is_owned is set and inner is non-NULL. */ -uint64_t OutPoint_hash(const struct LDKOutPoint *NONNULL_PTR o); +void ChannelManagerReadArgs_free(struct LDKChannelManagerReadArgs this_obj); /** - * Convert an `OutPoint` to a lightning channel id. + * The keys provider which will give us relevant keys. Some keys will be loaded during + * deserialization and KeysInterface::read_chan_signer will be used to read per-Channel + * signing data. */ -MUST_USE_RES struct LDKThirtyTwoBytes OutPoint_to_channel_id(const struct LDKOutPoint *NONNULL_PTR this_arg); +const struct LDKKeysInterface *ChannelManagerReadArgs_get_keys_manager(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); /** - * Serialize the OutPoint object into a byte array which can be read by OutPoint_read + * The keys provider which will give us relevant keys. Some keys will be loaded during + * deserialization and KeysInterface::read_chan_signer will be used to read per-Channel + * signing data. */ -struct LDKCVec_u8Z OutPoint_write(const struct LDKOutPoint *NONNULL_PTR obj); +void ChannelManagerReadArgs_set_keys_manager(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKKeysInterface val); /** - * Read a OutPoint from a byte array, created by OutPoint_write + * The fee_estimator for use in the ChannelManager in the future. + * + * No calls to the FeeEstimator will be made during deserialization. */ -struct LDKCResult_OutPointDecodeErrorZ OutPoint_read(struct LDKu8slice ser); +const struct LDKFeeEstimator *ChannelManagerReadArgs_get_fee_estimator(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); /** - * Frees any resources used by the DelayedPaymentOutputDescriptor, if is_owned is set and inner is non-NULL. + * The fee_estimator for use in the ChannelManager in the future. + * + * No calls to the FeeEstimator will be made during deserialization. */ -void DelayedPaymentOutputDescriptor_free(struct LDKDelayedPaymentOutputDescriptor this_obj); +void ChannelManagerReadArgs_set_fee_estimator(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKFeeEstimator val); /** - * The outpoint which is spendable + * The chain::Watch for use in the ChannelManager in the future. + * + * No calls to the chain::Watch will be made during deserialization. It is assumed that + * you have deserialized ChannelMonitors separately and will add them to your + * chain::Watch after deserializing this ChannelManager. */ -struct LDKOutPoint DelayedPaymentOutputDescriptor_get_outpoint(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr); +const struct LDKWatch *ChannelManagerReadArgs_get_chain_monitor(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); /** - * The outpoint which is spendable + * The chain::Watch for use in the ChannelManager in the future. + * + * No calls to the chain::Watch will be made during deserialization. It is assumed that + * you have deserialized ChannelMonitors separately and will add them to your + * chain::Watch after deserializing this ChannelManager. */ -void DelayedPaymentOutputDescriptor_set_outpoint(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKOutPoint val); +void ChannelManagerReadArgs_set_chain_monitor(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKWatch val); /** - * Per commitment point to derive delayed_payment_key by key holder + * The BroadcasterInterface which will be used in the ChannelManager in the future and may be + * used to broadcast the latest local commitment transactions of channels which must be + * force-closed during deserialization. */ -struct LDKPublicKey DelayedPaymentOutputDescriptor_get_per_commitment_point(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr); +const struct LDKBroadcasterInterface *ChannelManagerReadArgs_get_tx_broadcaster(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); /** - * Per commitment point to derive delayed_payment_key by key holder + * The BroadcasterInterface which will be used in the ChannelManager in the future and may be + * used to broadcast the latest local commitment transactions of channels which must be + * force-closed during deserialization. */ -void DelayedPaymentOutputDescriptor_set_per_commitment_point(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKPublicKey val); +void ChannelManagerReadArgs_set_tx_broadcaster(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKBroadcasterInterface val); /** - * The nSequence value which must be set in the spending input to satisfy the OP_CSV in - * the witness_script. + * The Logger for use in the ChannelManager and which may be used to log information during + * deserialization. */ -uint16_t DelayedPaymentOutputDescriptor_get_to_self_delay(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr); +const struct LDKLogger *ChannelManagerReadArgs_get_logger(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); /** - * The nSequence value which must be set in the spending input to satisfy the OP_CSV in - * the witness_script. + * The Logger for use in the ChannelManager and which may be used to log information during + * deserialization. */ -void DelayedPaymentOutputDescriptor_set_to_self_delay(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, uint16_t val); +void ChannelManagerReadArgs_set_logger(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKLogger val); /** - * The output which is referenced by the given outpoint + * Default settings used for new channels. Any existing channels will continue to use the + * runtime settings which were stored when the ChannelManager was serialized. */ -void DelayedPaymentOutputDescriptor_set_output(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKTxOut val); +struct LDKUserConfig ChannelManagerReadArgs_get_default_config(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); /** - * The revocation point specific to the commitment transaction which was broadcast. Used to - * derive the witnessScript for this output. + * Default settings used for new channels. Any existing channels will continue to use the + * runtime settings which were stored when the ChannelManager was serialized. */ -struct LDKPublicKey DelayedPaymentOutputDescriptor_get_revocation_pubkey(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr); +void ChannelManagerReadArgs_set_default_config(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKUserConfig val); /** - * The revocation point specific to the commitment transaction which was broadcast. Used to - * derive the witnessScript for this output. + * Simple utility function to create a ChannelManagerReadArgs which creates the monitor + * HashMap for you. This is primarily useful for C bindings where it is not practical to + * populate a HashMap directly from C. */ -void DelayedPaymentOutputDescriptor_set_revocation_pubkey(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKPublicKey val); +MUST_USE_RES struct LDKChannelManagerReadArgs ChannelManagerReadArgs_new(struct LDKKeysInterface keys_manager, struct LDKFeeEstimator fee_estimator, struct LDKWatch chain_monitor, struct LDKBroadcasterInterface tx_broadcaster, struct LDKLogger logger, struct LDKUserConfig default_config, struct LDKCVec_ChannelMonitorZ channel_monitors); /** - * Arbitrary identification information returned by a call to - * `Sign::channel_keys_id()`. This may be useful in re-deriving keys used in - * the channel to spend the output. + * Read a C2Tuple_BlockHashChannelManagerZ from a byte array, created by C2Tuple_BlockHashChannelManagerZ_write */ -const uint8_t (*DelayedPaymentOutputDescriptor_get_channel_keys_id(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr))[32]; +struct LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ C2Tuple_BlockHashChannelManagerZ_read(struct LDKu8slice ser, struct LDKChannelManagerReadArgs arg); /** - * Arbitrary identification information returned by a call to - * `Sign::channel_keys_id()`. This may be useful in re-deriving keys used in - * the channel to spend the output. + * Frees any resources used by the ExpandedKey, if is_owned is set and inner is non-NULL. */ -void DelayedPaymentOutputDescriptor_set_channel_keys_id(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void ExpandedKey_free(struct LDKExpandedKey this_obj); /** - * The value of the channel which this output originated from, possibly indirectly. + * Create a new [`ExpandedKey`] for generating an inbound payment hash and secret. + * + * It is recommended to cache this value and not regenerate it for each new inbound payment. */ -uint64_t DelayedPaymentOutputDescriptor_get_channel_value_satoshis(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKExpandedKey ExpandedKey_new(const uint8_t (*key_material)[32]); /** - * The value of the channel which this output originated from, possibly indirectly. + * Equivalent to [`crate::ln::channelmanager::ChannelManager::create_inbound_payment`], but no + * `ChannelManager` is required. Useful for generating invoices for [phantom node payments] without + * a `ChannelManager`. + * + * `keys` is generated by calling [`KeysInterface::get_inbound_payment_key_material`] and then + * calling [`ExpandedKey::new`] with its result. It is recommended to cache this value and not + * regenerate it for each new inbound payment. + * + * `current_time` is a Unix timestamp representing the current time. + * + * [phantom node payments]: crate::chain::keysinterface::PhantomKeysManager */ -void DelayedPaymentOutputDescriptor_set_channel_value_satoshis(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, uint64_t val); +struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ create(const struct LDKExpandedKey *NONNULL_PTR keys, struct LDKCOption_u64Z min_value_msat, uint32_t invoice_expiry_delta_secs, const struct LDKKeysInterface *NONNULL_PTR keys_manager, uint64_t current_time); /** - * Constructs a new DelayedPaymentOutputDescriptor given each field + * Equivalent to [`crate::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash`], + * but no `ChannelManager` is required. Useful for generating invoices for [phantom node payments] + * without a `ChannelManager`. + * + * See [`create`] for information on the `keys` and `current_time` parameters. + * + * [phantom node payments]: crate::chain::keysinterface::PhantomKeysManager */ -MUST_USE_RES struct LDKDelayedPaymentOutputDescriptor DelayedPaymentOutputDescriptor_new(struct LDKOutPoint outpoint_arg, struct LDKPublicKey per_commitment_point_arg, uint16_t to_self_delay_arg, struct LDKTxOut output_arg, struct LDKPublicKey revocation_pubkey_arg, struct LDKThirtyTwoBytes channel_keys_id_arg, uint64_t channel_value_satoshis_arg); +struct LDKCResult_PaymentSecretNoneZ create_from_hash(const struct LDKExpandedKey *NONNULL_PTR keys, struct LDKCOption_u64Z min_value_msat, struct LDKThirtyTwoBytes payment_hash, uint32_t invoice_expiry_delta_secs, uint64_t current_time); /** - * Creates a copy of the DelayedPaymentOutputDescriptor + * Frees any resources used by the DecodeError */ -struct LDKDelayedPaymentOutputDescriptor DelayedPaymentOutputDescriptor_clone(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR orig); +void DecodeError_free(struct LDKDecodeError this_ptr); /** - * Serialize the DelayedPaymentOutputDescriptor object into a byte array which can be read by DelayedPaymentOutputDescriptor_read + * Creates a copy of the DecodeError */ -struct LDKCVec_u8Z DelayedPaymentOutputDescriptor_write(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR obj); +struct LDKDecodeError DecodeError_clone(const struct LDKDecodeError *NONNULL_PTR orig); /** - * Read a DelayedPaymentOutputDescriptor from a byte array, created by DelayedPaymentOutputDescriptor_write + * Utility method to constructs a new UnknownVersion-variant DecodeError */ -struct LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ DelayedPaymentOutputDescriptor_read(struct LDKu8slice ser); +struct LDKDecodeError DecodeError_unknown_version(void); /** - * Frees any resources used by the StaticPaymentOutputDescriptor, if is_owned is set and inner is non-NULL. + * Utility method to constructs a new UnknownRequiredFeature-variant DecodeError */ -void StaticPaymentOutputDescriptor_free(struct LDKStaticPaymentOutputDescriptor this_obj); +struct LDKDecodeError DecodeError_unknown_required_feature(void); /** - * The outpoint which is spendable + * Utility method to constructs a new InvalidValue-variant DecodeError */ -struct LDKOutPoint StaticPaymentOutputDescriptor_get_outpoint(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr); +struct LDKDecodeError DecodeError_invalid_value(void); /** - * The outpoint which is spendable + * Utility method to constructs a new ShortRead-variant DecodeError */ -void StaticPaymentOutputDescriptor_set_outpoint(struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKOutPoint val); +struct LDKDecodeError DecodeError_short_read(void); /** - * The output which is referenced by the given outpoint + * Utility method to constructs a new BadLengthDescriptor-variant DecodeError */ -void StaticPaymentOutputDescriptor_set_output(struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKTxOut val); +struct LDKDecodeError DecodeError_bad_length_descriptor(void); /** - * Arbitrary identification information returned by a call to - * `Sign::channel_keys_id()`. This may be useful in re-deriving keys used in - * the channel to spend the output. + * Utility method to constructs a new Io-variant DecodeError */ -const uint8_t (*StaticPaymentOutputDescriptor_get_channel_keys_id(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr))[32]; +struct LDKDecodeError DecodeError_io(enum LDKIOError a); /** - * Arbitrary identification information returned by a call to - * `Sign::channel_keys_id()`. This may be useful in re-deriving keys used in - * the channel to spend the output. + * Utility method to constructs a new UnsupportedCompression-variant DecodeError */ -void StaticPaymentOutputDescriptor_set_channel_keys_id(struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKDecodeError DecodeError_unsupported_compression(void); /** - * The value of the channel which this transactions spends. + * Checks if two DecodeErrors contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -uint64_t StaticPaymentOutputDescriptor_get_channel_value_satoshis(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr); +bool DecodeError_eq(const struct LDKDecodeError *NONNULL_PTR a, const struct LDKDecodeError *NONNULL_PTR b); /** - * The value of the channel which this transactions spends. + * Frees any resources used by the Init, if is_owned is set and inner is non-NULL. */ -void StaticPaymentOutputDescriptor_set_channel_value_satoshis(struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr, uint64_t val); +void Init_free(struct LDKInit this_obj); /** - * Constructs a new StaticPaymentOutputDescriptor given each field + * The relevant features which the sender supports */ -MUST_USE_RES struct LDKStaticPaymentOutputDescriptor StaticPaymentOutputDescriptor_new(struct LDKOutPoint outpoint_arg, struct LDKTxOut output_arg, struct LDKThirtyTwoBytes channel_keys_id_arg, uint64_t channel_value_satoshis_arg); +struct LDKInitFeatures Init_get_features(const struct LDKInit *NONNULL_PTR this_ptr); /** - * Creates a copy of the StaticPaymentOutputDescriptor + * The relevant features which the sender supports */ -struct LDKStaticPaymentOutputDescriptor StaticPaymentOutputDescriptor_clone(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR orig); +void Init_set_features(struct LDKInit *NONNULL_PTR this_ptr, struct LDKInitFeatures val); /** - * Serialize the StaticPaymentOutputDescriptor object into a byte array which can be read by StaticPaymentOutputDescriptor_read + * 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 LDKCVec_u8Z StaticPaymentOutputDescriptor_write(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR obj); +struct LDKCOption_NetAddressZ Init_get_remote_network_address(const struct LDKInit *NONNULL_PTR this_ptr); /** - * Read a StaticPaymentOutputDescriptor from a byte array, created by StaticPaymentOutputDescriptor_write + * 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 LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ StaticPaymentOutputDescriptor_read(struct LDKu8slice ser); +void Init_set_remote_network_address(struct LDKInit *NONNULL_PTR this_ptr, struct LDKCOption_NetAddressZ val); /** - * Frees any resources used by the SpendableOutputDescriptor + * Constructs a new Init given each field */ -void SpendableOutputDescriptor_free(struct LDKSpendableOutputDescriptor this_ptr); +MUST_USE_RES struct LDKInit Init_new(struct LDKInitFeatures features_arg, struct LDKCOption_NetAddressZ remote_network_address_arg); /** - * Creates a copy of the SpendableOutputDescriptor + * Creates a copy of the Init */ -struct LDKSpendableOutputDescriptor SpendableOutputDescriptor_clone(const struct LDKSpendableOutputDescriptor *NONNULL_PTR orig); +struct LDKInit Init_clone(const struct LDKInit *NONNULL_PTR orig); /** - * Utility method to constructs a new StaticOutput-variant SpendableOutputDescriptor + * Checks if two Inits contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -struct LDKSpendableOutputDescriptor SpendableOutputDescriptor_static_output(struct LDKOutPoint outpoint, struct LDKTxOut output); +bool Init_eq(const struct LDKInit *NONNULL_PTR a, const struct LDKInit *NONNULL_PTR b); /** - * Utility method to constructs a new DelayedPaymentOutput-variant SpendableOutputDescriptor + * Frees any resources used by the ErrorMessage, if is_owned is set and inner is non-NULL. */ -struct LDKSpendableOutputDescriptor SpendableOutputDescriptor_delayed_payment_output(struct LDKDelayedPaymentOutputDescriptor a); +void ErrorMessage_free(struct LDKErrorMessage this_obj); /** - * Utility method to constructs a new StaticPaymentOutput-variant SpendableOutputDescriptor + * 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. */ -struct LDKSpendableOutputDescriptor SpendableOutputDescriptor_static_payment_output(struct LDKStaticPaymentOutputDescriptor a); +const uint8_t (*ErrorMessage_get_channel_id(const struct LDKErrorMessage *NONNULL_PTR this_ptr))[32]; /** - * Serialize the SpendableOutputDescriptor object into a byte array which can be read by SpendableOutputDescriptor_read + * 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. */ -struct LDKCVec_u8Z SpendableOutputDescriptor_write(const struct LDKSpendableOutputDescriptor *NONNULL_PTR obj); +void ErrorMessage_set_channel_id(struct LDKErrorMessage *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Read a SpendableOutputDescriptor from a byte array, created by SpendableOutputDescriptor_write + * 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. */ -struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ SpendableOutputDescriptor_read(struct LDKu8slice ser); +struct LDKStr ErrorMessage_get_data(const struct LDKErrorMessage *NONNULL_PTR this_ptr); /** - * Calls the free function if one is set + * 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. */ -void BaseSign_free(struct LDKBaseSign this_ptr); +void ErrorMessage_set_data(struct LDKErrorMessage *NONNULL_PTR this_ptr, struct LDKStr val); /** - * Creates a copy of a Sign + * Constructs a new ErrorMessage given each field */ -struct LDKSign Sign_clone(const struct LDKSign *NONNULL_PTR orig); +MUST_USE_RES struct LDKErrorMessage ErrorMessage_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKStr data_arg); /** - * Calls the free function if one is set + * Creates a copy of the ErrorMessage */ -void Sign_free(struct LDKSign this_ptr); +struct LDKErrorMessage ErrorMessage_clone(const struct LDKErrorMessage *NONNULL_PTR orig); /** - * Creates a copy of the Recipient + * Checks if two ErrorMessages contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -enum LDKRecipient Recipient_clone(const enum LDKRecipient *NONNULL_PTR orig); +bool ErrorMessage_eq(const struct LDKErrorMessage *NONNULL_PTR a, const struct LDKErrorMessage *NONNULL_PTR b); /** - * Utility method to constructs a new Node-variant Recipient + * Frees any resources used by the WarningMessage, if is_owned is set and inner is non-NULL. */ -enum LDKRecipient Recipient_node(void); +void WarningMessage_free(struct LDKWarningMessage this_obj); /** - * Utility method to constructs a new PhantomNode-variant Recipient + * The channel ID involved in the warning. + * + * All-0s indicates a warning unrelated to a specific channel. */ -enum LDKRecipient Recipient_phantom_node(void); +const uint8_t (*WarningMessage_get_channel_id(const struct LDKWarningMessage *NONNULL_PTR this_ptr))[32]; /** - * Calls the free function if one is set + * The channel ID involved in the warning. + * + * All-0s indicates a warning unrelated to a specific channel. */ -void KeysInterface_free(struct LDKKeysInterface this_ptr); +void WarningMessage_set_channel_id(struct LDKWarningMessage *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Frees any resources used by the InMemorySigner, if is_owned is set and inner is non-NULL. + * 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 InMemorySigner_free(struct LDKInMemorySigner this_obj); +struct LDKStr WarningMessage_get_data(const struct LDKWarningMessage *NONNULL_PTR this_ptr); /** - * Private key of anchor tx + * 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. */ -const uint8_t (*InMemorySigner_get_funding_key(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; +void WarningMessage_set_data(struct LDKWarningMessage *NONNULL_PTR this_ptr, struct LDKStr val); /** - * Private key of anchor tx + * Constructs a new WarningMessage given each field */ -void InMemorySigner_set_funding_key(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKSecretKey val); +MUST_USE_RES struct LDKWarningMessage WarningMessage_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKStr data_arg); /** - * Holder secret key for blinded revocation pubkey + * Creates a copy of the WarningMessage */ -const uint8_t (*InMemorySigner_get_revocation_base_key(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; +struct LDKWarningMessage WarningMessage_clone(const struct LDKWarningMessage *NONNULL_PTR orig); /** - * Holder secret key for blinded revocation pubkey + * Checks if two WarningMessages contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void InMemorySigner_set_revocation_base_key(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKSecretKey val); +bool WarningMessage_eq(const struct LDKWarningMessage *NONNULL_PTR a, const struct LDKWarningMessage *NONNULL_PTR b); /** - * Holder secret key used for our balance in counterparty-broadcasted commitment transactions + * Frees any resources used by the Ping, if is_owned is set and inner is non-NULL. */ -const uint8_t (*InMemorySigner_get_payment_key(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; +void Ping_free(struct LDKPing this_obj); /** - * Holder secret key used for our balance in counterparty-broadcasted commitment transactions + * The desired response length */ -void InMemorySigner_set_payment_key(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKSecretKey val); +uint16_t Ping_get_ponglen(const struct LDKPing *NONNULL_PTR this_ptr); /** - * Holder secret key used in HTLC tx + * The desired response length */ -const uint8_t (*InMemorySigner_get_delayed_payment_base_key(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; +void Ping_set_ponglen(struct LDKPing *NONNULL_PTR this_ptr, uint16_t val); /** - * Holder secret key used in HTLC tx + * The ping packet size. + * This field is not sent on the wire. byteslen zeros are sent. */ -void InMemorySigner_set_delayed_payment_base_key(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKSecretKey val); +uint16_t Ping_get_byteslen(const struct LDKPing *NONNULL_PTR this_ptr); /** - * Holder htlc secret key used in commitment tx htlc outputs + * The ping packet size. + * This field is not sent on the wire. byteslen zeros are sent. */ -const uint8_t (*InMemorySigner_get_htlc_base_key(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; +void Ping_set_byteslen(struct LDKPing *NONNULL_PTR this_ptr, uint16_t val); /** - * Holder htlc secret key used in commitment tx htlc outputs + * Constructs a new Ping given each field */ -void InMemorySigner_set_htlc_base_key(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKSecretKey val); +MUST_USE_RES struct LDKPing Ping_new(uint16_t ponglen_arg, uint16_t byteslen_arg); /** - * Commitment seed + * Creates a copy of the Ping */ -const uint8_t (*InMemorySigner_get_commitment_seed(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; +struct LDKPing Ping_clone(const struct LDKPing *NONNULL_PTR orig); /** - * Commitment seed + * Checks if two Pings contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void InMemorySigner_set_commitment_seed(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +bool Ping_eq(const struct LDKPing *NONNULL_PTR a, const struct LDKPing *NONNULL_PTR b); /** - * Creates a copy of the InMemorySigner + * Frees any resources used by the Pong, if is_owned is set and inner is non-NULL. */ -struct LDKInMemorySigner InMemorySigner_clone(const struct LDKInMemorySigner *NONNULL_PTR orig); +void Pong_free(struct LDKPong this_obj); /** - * Create a new InMemorySigner + * The pong packet size. + * This field is not sent on the wire. byteslen zeros are sent. */ -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); +uint16_t Pong_get_byteslen(const struct LDKPong *NONNULL_PTR this_ptr); /** - * Counterparty pubkeys. - * Will panic if ready_channel wasn't called. + * The pong packet size. + * This field is not sent on the wire. byteslen zeros are sent. */ -MUST_USE_RES struct LDKChannelPublicKeys InMemorySigner_counterparty_pubkeys(const struct LDKInMemorySigner *NONNULL_PTR this_arg); +void Pong_set_byteslen(struct LDKPong *NONNULL_PTR this_ptr, uint16_t val); /** - * The contest_delay value specified by our counterparty and applied on holder-broadcastable - * transactions, ie the amount of time that we have to wait to recover our funds if we - * broadcast a transaction. - * Will panic if ready_channel wasn't called. + * Constructs a new Pong given each field */ -MUST_USE_RES uint16_t InMemorySigner_counterparty_selected_contest_delay(const struct LDKInMemorySigner *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKPong Pong_new(uint16_t byteslen_arg); /** - * The contest_delay value specified by us and applied on transactions broadcastable - * by our counterparty, ie the amount of time that they have to wait to recover their funds - * if they broadcast a transaction. - * Will panic if ready_channel wasn't called. + * Creates a copy of the Pong */ -MUST_USE_RES uint16_t InMemorySigner_holder_selected_contest_delay(const struct LDKInMemorySigner *NONNULL_PTR this_arg); +struct LDKPong Pong_clone(const struct LDKPong *NONNULL_PTR orig); /** - * Whether the holder is the initiator - * Will panic if ready_channel wasn't called. + * Checks if two Pongs contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -MUST_USE_RES bool InMemorySigner_is_outbound(const struct LDKInMemorySigner *NONNULL_PTR this_arg); +bool Pong_eq(const struct LDKPong *NONNULL_PTR a, const struct LDKPong *NONNULL_PTR b); /** - * Funding outpoint - * Will panic if ready_channel wasn't called. + * Frees any resources used by the OpenChannel, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKOutPoint InMemorySigner_funding_outpoint(const struct LDKInMemorySigner *NONNULL_PTR this_arg); +void OpenChannel_free(struct LDKOpenChannel this_obj); /** - * Obtain a ChannelTransactionParameters for this channel, to be used when verifying or - * building transactions. - * - * Will panic if ready_channel wasn't called. + * The genesis hash of the blockchain where the channel is to be opened */ -MUST_USE_RES struct LDKChannelTransactionParameters InMemorySigner_get_channel_parameters(const struct LDKInMemorySigner *NONNULL_PTR this_arg); +const uint8_t (*OpenChannel_get_chain_hash(const struct LDKOpenChannel *NONNULL_PTR this_ptr))[32]; /** - * Whether anchors should be used. - * Will panic if ready_channel wasn't called. + * The genesis hash of the blockchain where the channel is to be opened */ -MUST_USE_RES bool InMemorySigner_opt_anchors(const struct LDKInMemorySigner *NONNULL_PTR this_arg); +void OpenChannel_set_chain_hash(struct LDKOpenChannel *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * 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, - * is not spending the outpoint described by `descriptor.outpoint`, - * or if an output descriptor script_pubkey does not match the one we can spend. + * A temporary channel ID, until the funding outpoint is announced */ -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); +const uint8_t (*OpenChannel_get_temporary_channel_id(const struct LDKOpenChannel *NONNULL_PTR this_ptr))[32]; /** - * 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, - * 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. + * A temporary channel ID, until the funding outpoint is announced */ -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); +void OpenChannel_set_temporary_channel_id(struct LDKOpenChannel *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Constructs a new BaseSign which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned BaseSign must be freed before this_arg is + * The channel value */ -struct LDKBaseSign InMemorySigner_as_BaseSign(const struct LDKInMemorySigner *NONNULL_PTR this_arg); +uint64_t OpenChannel_get_funding_satoshis(const struct LDKOpenChannel *NONNULL_PTR this_ptr); /** - * Constructs a new Sign which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned Sign must be freed before this_arg is + * The channel value */ -struct LDKSign InMemorySigner_as_Sign(const struct LDKInMemorySigner *NONNULL_PTR this_arg); +void OpenChannel_set_funding_satoshis(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint64_t val); /** - * Serialize the InMemorySigner object into a byte array which can be read by InMemorySigner_read + * The amount to push to the counterparty as part of the open, in milli-satoshi */ -struct LDKCVec_u8Z InMemorySigner_write(const struct LDKInMemorySigner *NONNULL_PTR obj); +uint64_t OpenChannel_get_push_msat(const struct LDKOpenChannel *NONNULL_PTR this_ptr); /** - * Read a InMemorySigner from a byte array, created by InMemorySigner_write + * The amount to push to the counterparty as part of the open, in milli-satoshi */ -struct LDKCResult_InMemorySignerDecodeErrorZ InMemorySigner_read(struct LDKu8slice ser, struct LDKSecretKey arg); +void OpenChannel_set_push_msat(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint64_t val); /** - * Frees any resources used by the KeysManager, if is_owned is set and inner is non-NULL. + * The threshold below which outputs on transactions broadcast by sender will be omitted */ -void KeysManager_free(struct LDKKeysManager this_obj); +uint64_t OpenChannel_get_dust_limit_satoshis(const struct LDKOpenChannel *NONNULL_PTR this_ptr); /** - * Constructs a KeysManager from a 32-byte seed. If the seed is in some way biased (eg your - * CSRNG is busted) this may panic (but more importantly, you will possibly lose funds). - * starting_time isn't strictly required to actually be a time, but it must absolutely, - * without a doubt, be unique to this instance. ie if you start multiple times with the same - * seed, starting_time must be unique to each run. Thus, the easiest way to achieve this is to - * simply use the current time (with very high precision). - * - * The seed MUST be backed up safely prior to use so that the keys can be re-created, however, - * obviously, starting_time should be unique every time you reload the library - it is only - * used to generate new ephemeral key data (which will be stored by the individual channel if - * necessary). - * - * Note that the seed is required to recover certain on-chain funds independent of - * ChannelMonitor data, though a current copy of ChannelMonitor data is also required for any - * channel, and some on-chain during-closing funds. - * - * Note that until the 0.1 release there is no guarantee of backward compatibility between - * versions. Once the library is more fully supported, the docs will be updated to include a - * detailed description of the guarantee. + * The threshold below which outputs on transactions broadcast by sender will be omitted */ -MUST_USE_RES struct LDKKeysManager KeysManager_new(const uint8_t (*seed)[32], uint64_t starting_time_secs, uint32_t starting_time_nanos); +void OpenChannel_set_dust_limit_satoshis(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint64_t val); /** - * Derive an old Sign containing per-channel secrets based on a key derivation parameters. - * - * Key derivation parameters are accessible through a per-channel secrets - * Sign::channel_keys_id and is provided inside DynamicOuputP2WSH in case of - * onchain output detection for which a corresponding delayed_payment_key must be derived. + * The maximum inbound HTLC value in flight towards sender, in milli-satoshi */ -MUST_USE_RES struct LDKInMemorySigner KeysManager_derive_channel_keys(const struct LDKKeysManager *NONNULL_PTR this_arg, uint64_t channel_value_satoshis, const uint8_t (*params)[32]); +uint64_t OpenChannel_get_max_htlc_value_in_flight_msat(const struct LDKOpenChannel *NONNULL_PTR this_ptr); /** - * Creates a Transaction which spends the given descriptors to the given outputs, plus an - * output to the given change destination (if sufficient change value remains). The - * transaction will have a feerate, at least, of the given value. - * - * Returns `Err(())` if the output value is greater than the input value minus required fee, - * if a descriptor was duplicated, or if an output descriptor `script_pubkey` - * does not match the one we can spend. - * - * We do not enforce that outputs meet the dust limit or that any output scripts are standard. - * - * May panic if the `SpendableOutputDescriptor`s were not generated by Channels which used - * this KeysManager or one of the `InMemorySigner` created by this KeysManager. + * The maximum inbound HTLC value in flight towards sender, in milli-satoshi */ -MUST_USE_RES struct LDKCResult_TransactionNoneZ KeysManager_spend_spendable_outputs(const struct LDKKeysManager *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); +void OpenChannel_set_max_htlc_value_in_flight_msat(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint64_t val); /** - * 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 + * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel */ -struct LDKKeysInterface KeysManager_as_KeysInterface(const struct LDKKeysManager *NONNULL_PTR this_arg); +uint64_t OpenChannel_get_channel_reserve_satoshis(const struct LDKOpenChannel *NONNULL_PTR this_ptr); /** - * Frees any resources used by the PhantomKeysManager, if is_owned is set and inner is non-NULL. + * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel */ -void PhantomKeysManager_free(struct LDKPhantomKeysManager this_obj); +void OpenChannel_set_channel_reserve_satoshis(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint64_t val); /** - * 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 + * The minimum HTLC size incoming to sender, in milli-satoshi */ -struct LDKKeysInterface PhantomKeysManager_as_KeysInterface(const struct LDKPhantomKeysManager *NONNULL_PTR this_arg); +uint64_t OpenChannel_get_htlc_minimum_msat(const struct LDKOpenChannel *NONNULL_PTR this_ptr); /** - * Constructs a `PhantomKeysManager` given a 32-byte seed and an additional `cross_node_seed` - * that is shared across all nodes that intend to participate in [phantom node payments] together. - * - * See [`KeysManager::new`] for more information on `seed`, `starting_time_secs`, and - * `starting_time_nanos`. - * - * `cross_node_seed` must be the same across all phantom payment-receiving nodes and also the - * same across restarts, or else inbound payments may fail. - * - * [phantom node payments]: PhantomKeysManager + * The minimum HTLC size incoming to sender, in milli-satoshi */ -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]); +void OpenChannel_set_htlc_minimum_msat(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint64_t val); /** - * See [`KeysManager::spend_spendable_outputs`] for documentation on this method. + * The feerate per 1000-weight of sender generated transactions, until updated by update_fee */ -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); +uint32_t OpenChannel_get_feerate_per_kw(const struct LDKOpenChannel *NONNULL_PTR this_ptr); /** - * See [`KeysManager::derive_channel_keys`] for documentation on this method. + * The feerate per 1000-weight of sender generated transactions, until updated by update_fee */ -MUST_USE_RES struct LDKInMemorySigner PhantomKeysManager_derive_channel_keys(const struct LDKPhantomKeysManager *NONNULL_PTR this_arg, uint64_t channel_value_satoshis, const uint8_t (*params)[32]); +void OpenChannel_set_feerate_per_kw(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint32_t val); /** - * Frees any resources used by the ChannelManager, if is_owned is set and inner is non-NULL. + * The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction */ -void ChannelManager_free(struct LDKChannelManager this_obj); +uint16_t OpenChannel_get_to_self_delay(const struct LDKOpenChannel *NONNULL_PTR this_ptr); /** - * Frees any resources used by the ChainParameters, if is_owned is set and inner is non-NULL. + * The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction */ -void ChainParameters_free(struct LDKChainParameters this_obj); +void OpenChannel_set_to_self_delay(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint16_t val); /** - * The network for determining the `chain_hash` in Lightning messages. + * The maximum number of inbound HTLCs towards sender */ -enum LDKNetwork ChainParameters_get_network(const struct LDKChainParameters *NONNULL_PTR this_ptr); +uint16_t OpenChannel_get_max_accepted_htlcs(const struct LDKOpenChannel *NONNULL_PTR this_ptr); /** - * The network for determining the `chain_hash` in Lightning messages. + * The maximum number of inbound HTLCs towards sender */ -void ChainParameters_set_network(struct LDKChainParameters *NONNULL_PTR this_ptr, enum LDKNetwork val); +void OpenChannel_set_max_accepted_htlcs(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint16_t val); /** - * The hash and height of the latest block successfully connected. - * - * Used to track on-chain channel funding outputs and send payments with reliable timelocks. + * The sender's key controlling the funding transaction */ -struct LDKBestBlock ChainParameters_get_best_block(const struct LDKChainParameters *NONNULL_PTR this_ptr); +struct LDKPublicKey OpenChannel_get_funding_pubkey(const struct LDKOpenChannel *NONNULL_PTR this_ptr); /** - * The hash and height of the latest block successfully connected. - * - * Used to track on-chain channel funding outputs and send payments with reliable timelocks. + * The sender's key controlling the funding transaction */ -void ChainParameters_set_best_block(struct LDKChainParameters *NONNULL_PTR this_ptr, struct LDKBestBlock val); +void OpenChannel_set_funding_pubkey(struct LDKOpenChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Constructs a new ChainParameters given each field + * Used to derive a revocation key for transactions broadcast by counterparty */ -MUST_USE_RES struct LDKChainParameters ChainParameters_new(enum LDKNetwork network_arg, struct LDKBestBlock best_block_arg); +struct LDKPublicKey OpenChannel_get_revocation_basepoint(const struct LDKOpenChannel *NONNULL_PTR this_ptr); /** - * Creates a copy of the ChainParameters + * Used to derive a revocation key for transactions broadcast by counterparty */ -struct LDKChainParameters ChainParameters_clone(const struct LDKChainParameters *NONNULL_PTR orig); +void OpenChannel_set_revocation_basepoint(struct LDKOpenChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Frees any resources used by the CounterpartyForwardingInfo, if is_owned is set and inner is non-NULL. + * A payment key to sender for transactions broadcast by counterparty */ -void CounterpartyForwardingInfo_free(struct LDKCounterpartyForwardingInfo this_obj); +struct LDKPublicKey OpenChannel_get_payment_point(const struct LDKOpenChannel *NONNULL_PTR this_ptr); /** - * Base routing fee in millisatoshis. + * A payment key to sender for transactions broadcast by counterparty */ -uint32_t CounterpartyForwardingInfo_get_fee_base_msat(const struct LDKCounterpartyForwardingInfo *NONNULL_PTR this_ptr); +void OpenChannel_set_payment_point(struct LDKOpenChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Base routing fee in millisatoshis. + * Used to derive a payment key to sender for transactions broadcast by sender */ -void CounterpartyForwardingInfo_set_fee_base_msat(struct LDKCounterpartyForwardingInfo *NONNULL_PTR this_ptr, uint32_t val); +struct LDKPublicKey OpenChannel_get_delayed_payment_basepoint(const struct LDKOpenChannel *NONNULL_PTR this_ptr); /** - * Amount in millionths of a satoshi the channel will charge per transferred satoshi. + * Used to derive a payment key to sender for transactions broadcast by sender */ -uint32_t CounterpartyForwardingInfo_get_fee_proportional_millionths(const struct LDKCounterpartyForwardingInfo *NONNULL_PTR this_ptr); +void OpenChannel_set_delayed_payment_basepoint(struct LDKOpenChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Amount in millionths of a satoshi the channel will charge per transferred satoshi. + * Used to derive an HTLC payment key to sender */ -void CounterpartyForwardingInfo_set_fee_proportional_millionths(struct LDKCounterpartyForwardingInfo *NONNULL_PTR this_ptr, uint32_t val); +struct LDKPublicKey OpenChannel_get_htlc_basepoint(const struct LDKOpenChannel *NONNULL_PTR this_ptr); /** - * The minimum difference in cltv_expiry between an ingoing HTLC and its outgoing counterpart, - * such that the outgoing HTLC is forwardable to this counterparty. See `msgs::ChannelUpdate`'s - * `cltv_expiry_delta` for more details. + * Used to derive an HTLC payment key to sender */ -uint16_t CounterpartyForwardingInfo_get_cltv_expiry_delta(const struct LDKCounterpartyForwardingInfo *NONNULL_PTR this_ptr); +void OpenChannel_set_htlc_basepoint(struct LDKOpenChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * The minimum difference in cltv_expiry between an ingoing HTLC and its outgoing counterpart, - * such that the outgoing HTLC is forwardable to this counterparty. See `msgs::ChannelUpdate`'s - * `cltv_expiry_delta` for more details. + * The first to-be-broadcast-by-sender transaction's per commitment point */ -void CounterpartyForwardingInfo_set_cltv_expiry_delta(struct LDKCounterpartyForwardingInfo *NONNULL_PTR this_ptr, uint16_t val); +struct LDKPublicKey OpenChannel_get_first_per_commitment_point(const struct LDKOpenChannel *NONNULL_PTR this_ptr); /** - * Constructs a new CounterpartyForwardingInfo given each field + * The first to-be-broadcast-by-sender transaction's per commitment point */ -MUST_USE_RES struct LDKCounterpartyForwardingInfo CounterpartyForwardingInfo_new(uint32_t fee_base_msat_arg, uint32_t fee_proportional_millionths_arg, uint16_t cltv_expiry_delta_arg); +void OpenChannel_set_first_per_commitment_point(struct LDKOpenChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Creates a copy of the CounterpartyForwardingInfo + * Channel flags */ -struct LDKCounterpartyForwardingInfo CounterpartyForwardingInfo_clone(const struct LDKCounterpartyForwardingInfo *NONNULL_PTR orig); +uint8_t OpenChannel_get_channel_flags(const struct LDKOpenChannel *NONNULL_PTR this_ptr); /** - * Frees any resources used by the ChannelCounterparty, if is_owned is set and inner is non-NULL. + * Channel flags */ -void ChannelCounterparty_free(struct LDKChannelCounterparty this_obj); +void OpenChannel_set_channel_flags(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint8_t val); /** - * The node_id of our counterparty + * 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 LDKPublicKey ChannelCounterparty_get_node_id(const struct LDKChannelCounterparty *NONNULL_PTR this_ptr); +struct LDKChannelTypeFeatures OpenChannel_get_channel_type(const struct LDKOpenChannel *NONNULL_PTR this_ptr); /** - * The node_id of our counterparty + * 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 ChannelCounterparty_set_node_id(struct LDKChannelCounterparty *NONNULL_PTR this_ptr, struct LDKPublicKey val); +void OpenChannel_set_channel_type(struct LDKOpenChannel *NONNULL_PTR this_ptr, struct LDKChannelTypeFeatures val); /** - * The Features the channel counterparty provided upon last connection. - * Useful for routing as it is the most up-to-date copy of the counterparty's features and - * many routing-relevant features are present in the init context. + * Creates a copy of the OpenChannel */ -struct LDKInitFeatures ChannelCounterparty_get_features(const struct LDKChannelCounterparty *NONNULL_PTR this_ptr); +struct LDKOpenChannel OpenChannel_clone(const struct LDKOpenChannel *NONNULL_PTR orig); /** - * The Features the channel counterparty provided upon last connection. - * Useful for routing as it is the most up-to-date copy of the counterparty's features and - * many routing-relevant features are present in the init context. + * Checks if two OpenChannels contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void ChannelCounterparty_set_features(struct LDKChannelCounterparty *NONNULL_PTR this_ptr, struct LDKInitFeatures val); +bool OpenChannel_eq(const struct LDKOpenChannel *NONNULL_PTR a, const struct LDKOpenChannel *NONNULL_PTR b); /** - * The value, in satoshis, that must always be held in the channel for our counterparty. This - * value ensures that if our counterparty broadcasts a revoked state, we can punish them by - * claiming at least this value on chain. - * - * This value is not included in [`inbound_capacity_msat`] as it can never be spent. - * - * [`inbound_capacity_msat`]: ChannelDetails::inbound_capacity_msat + * Frees any resources used by the AcceptChannel, if is_owned is set and inner is non-NULL. */ -uint64_t ChannelCounterparty_get_unspendable_punishment_reserve(const struct LDKChannelCounterparty *NONNULL_PTR this_ptr); +void AcceptChannel_free(struct LDKAcceptChannel this_obj); /** - * The value, in satoshis, that must always be held in the channel for our counterparty. This - * value ensures that if our counterparty broadcasts a revoked state, we can punish them by - * claiming at least this value on chain. - * - * This value is not included in [`inbound_capacity_msat`] as it can never be spent. - * - * [`inbound_capacity_msat`]: ChannelDetails::inbound_capacity_msat + * A temporary channel ID, until the funding outpoint is announced */ -void ChannelCounterparty_set_unspendable_punishment_reserve(struct LDKChannelCounterparty *NONNULL_PTR this_ptr, uint64_t val); +const uint8_t (*AcceptChannel_get_temporary_channel_id(const struct LDKAcceptChannel *NONNULL_PTR this_ptr))[32]; /** - * Information on the fees and requirements that the counterparty requires when forwarding - * payments to us through this channel. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * A temporary channel ID, until the funding outpoint is announced */ -struct LDKCounterpartyForwardingInfo ChannelCounterparty_get_forwarding_info(const struct LDKChannelCounterparty *NONNULL_PTR this_ptr); +void AcceptChannel_set_temporary_channel_id(struct LDKAcceptChannel *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Information on the fees and requirements that the counterparty requires when forwarding - * payments to us through this channel. - * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + * The threshold below which outputs on transactions broadcast by sender will be omitted */ -void ChannelCounterparty_set_forwarding_info(struct LDKChannelCounterparty *NONNULL_PTR this_ptr, struct LDKCounterpartyForwardingInfo val); +uint64_t AcceptChannel_get_dust_limit_satoshis(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); /** - * Constructs a new ChannelCounterparty given each field + * The threshold below which outputs on transactions broadcast by sender will be omitted */ -MUST_USE_RES struct LDKChannelCounterparty ChannelCounterparty_new(struct LDKPublicKey node_id_arg, struct LDKInitFeatures features_arg, uint64_t unspendable_punishment_reserve_arg, struct LDKCounterpartyForwardingInfo forwarding_info_arg); +void AcceptChannel_set_dust_limit_satoshis(struct LDKAcceptChannel *NONNULL_PTR this_ptr, uint64_t val); /** - * Creates a copy of the ChannelCounterparty + * The maximum inbound HTLC value in flight towards sender, in milli-satoshi */ -struct LDKChannelCounterparty ChannelCounterparty_clone(const struct LDKChannelCounterparty *NONNULL_PTR orig); +uint64_t AcceptChannel_get_max_htlc_value_in_flight_msat(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); /** - * Frees any resources used by the ChannelDetails, if is_owned is set and inner is non-NULL. + * The maximum inbound HTLC value in flight towards sender, in milli-satoshi */ -void ChannelDetails_free(struct LDKChannelDetails this_obj); +void AcceptChannel_set_max_htlc_value_in_flight_msat(struct LDKAcceptChannel *NONNULL_PTR this_ptr, uint64_t val); /** - * The channel's ID (prior to funding transaction generation, this is a random 32 bytes, - * thereafter this is the txid of the funding transaction xor the funding transaction output). - * Note that this means this value is *not* persistent - it can change once during the - * lifetime of the channel. + * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel */ -const uint8_t (*ChannelDetails_get_channel_id(const struct LDKChannelDetails *NONNULL_PTR this_ptr))[32]; +uint64_t AcceptChannel_get_channel_reserve_satoshis(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); /** - * The channel's ID (prior to funding transaction generation, this is a random 32 bytes, - * thereafter this is the txid of the funding transaction xor the funding transaction output). - * Note that this means this value is *not* persistent - it can change once during the - * lifetime of the channel. + * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel */ -void ChannelDetails_set_channel_id(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void AcceptChannel_set_channel_reserve_satoshis(struct LDKAcceptChannel *NONNULL_PTR this_ptr, uint64_t val); /** - * Parameters which apply to our counterparty. See individual fields for more information. + * The minimum HTLC size incoming to sender, in milli-satoshi */ -struct LDKChannelCounterparty ChannelDetails_get_counterparty(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +uint64_t AcceptChannel_get_htlc_minimum_msat(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); /** - * Parameters which apply to our counterparty. See individual fields for more information. + * The minimum HTLC size incoming to sender, in milli-satoshi */ -void ChannelDetails_set_counterparty(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKChannelCounterparty val); +void AcceptChannel_set_htlc_minimum_msat(struct LDKAcceptChannel *NONNULL_PTR this_ptr, uint64_t val); /** - * The Channel's funding transaction output, if we've negotiated the funding transaction with - * our counterparty already. - * - * Note that, if this has been set, `channel_id` will be equivalent to - * `funding_txo.unwrap().to_channel_id()`. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Minimum depth of the funding transaction before the channel is considered open */ -struct LDKOutPoint ChannelDetails_get_funding_txo(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +uint32_t AcceptChannel_get_minimum_depth(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); /** - * The Channel's funding transaction output, if we've negotiated the funding transaction with - * our counterparty already. - * - * Note that, if this has been set, `channel_id` will be equivalent to - * `funding_txo.unwrap().to_channel_id()`. - * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + * Minimum depth of the funding transaction before the channel is considered open */ -void ChannelDetails_set_funding_txo(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKOutPoint val); +void AcceptChannel_set_minimum_depth(struct LDKAcceptChannel *NONNULL_PTR this_ptr, uint32_t 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. + * The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction */ -struct LDKCOption_u64Z ChannelDetails_get_short_channel_id(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +uint16_t AcceptChannel_get_to_self_delay(const struct LDKAcceptChannel *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. + * The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction */ -void ChannelDetails_set_short_channel_id(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); +void AcceptChannel_set_to_self_delay(struct LDKAcceptChannel *NONNULL_PTR this_ptr, uint16_t val); /** - * The value, in satoshis, of this channel as appears in the funding output + * The maximum number of inbound HTLCs towards sender */ -uint64_t ChannelDetails_get_channel_value_satoshis(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +uint16_t AcceptChannel_get_max_accepted_htlcs(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); /** - * The value, in satoshis, of this channel as appears in the funding output + * The maximum number of inbound HTLCs towards sender */ -void ChannelDetails_set_channel_value_satoshis(struct LDKChannelDetails *NONNULL_PTR this_ptr, uint64_t val); +void AcceptChannel_set_max_accepted_htlcs(struct LDKAcceptChannel *NONNULL_PTR this_ptr, uint16_t val); /** - * The value, in satoshis, that must always be held in the channel for us. This value ensures - * that if we broadcast a revoked state, our counterparty can punish us by claiming at least - * this value on chain. - * - * This value is not included in [`outbound_capacity_msat`] as it can never be spent. - * - * This value will be `None` for outbound channels until the counterparty accepts the channel. - * - * [`outbound_capacity_msat`]: ChannelDetails::outbound_capacity_msat + * The sender's key controlling the funding transaction */ -struct LDKCOption_u64Z ChannelDetails_get_unspendable_punishment_reserve(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +struct LDKPublicKey AcceptChannel_get_funding_pubkey(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); /** - * The value, in satoshis, that must always be held in the channel for us. This value ensures - * that if we broadcast a revoked state, our counterparty can punish us by claiming at least - * this value on chain. - * - * This value is not included in [`outbound_capacity_msat`] as it can never be spent. - * - * This value will be `None` for outbound channels until the counterparty accepts the channel. - * - * [`outbound_capacity_msat`]: ChannelDetails::outbound_capacity_msat + * The sender's key controlling the funding transaction */ -void ChannelDetails_set_unspendable_punishment_reserve(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); +void AcceptChannel_set_funding_pubkey(struct LDKAcceptChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * The `user_channel_id` passed in to create_channel, or 0 if the channel was inbound. + * Used to derive a revocation key for transactions broadcast by counterparty */ -uint64_t ChannelDetails_get_user_channel_id(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +struct LDKPublicKey AcceptChannel_get_revocation_basepoint(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); /** - * The `user_channel_id` passed in to create_channel, or 0 if the channel was inbound. + * Used to derive a revocation key for transactions broadcast by counterparty */ -void ChannelDetails_set_user_channel_id(struct LDKChannelDetails *NONNULL_PTR this_ptr, uint64_t val); +void AcceptChannel_set_revocation_basepoint(struct LDKAcceptChannel *NONNULL_PTR this_ptr, struct LDKPublicKey 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`] + * A payment key to sender for transactions broadcast by counterparty */ -uint64_t ChannelDetails_get_balance_msat(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +struct LDKPublicKey AcceptChannel_get_payment_point(const struct LDKAcceptChannel *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`] + * A payment key to sender for transactions broadcast by counterparty */ -void ChannelDetails_set_balance_msat(struct LDKChannelDetails *NONNULL_PTR this_ptr, uint64_t val); +void AcceptChannel_set_payment_point(struct LDKAcceptChannel *NONNULL_PTR this_ptr, struct LDKPublicKey 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, 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. + * Used to derive a payment key to sender for transactions broadcast by sender */ -uint64_t ChannelDetails_get_outbound_capacity_msat(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +struct LDKPublicKey AcceptChannel_get_delayed_payment_basepoint(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); /** - * 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, 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. + * Used to derive a payment key to sender for transactions broadcast by sender */ -void ChannelDetails_set_outbound_capacity_msat(struct LDKChannelDetails *NONNULL_PTR this_ptr, uint64_t val); +void AcceptChannel_set_delayed_payment_basepoint(struct LDKAcceptChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * The available inbound capacity for the remote peer to send HTLCs to us. This does not - * include any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not - * available for inclusion in new inbound HTLCs). - * Note that there are some corner cases not fully handled here, so the actual available - * inbound capacity may be slightly higher than this. - * - * This value is not exact. Due to various in-flight changes, feerate changes, and our - * counterparty's conflict-avoidance policy, exactly this amount is not likely to be spendable. - * However, our counterparty should be able to spend nearly this amount. + * Used to derive an HTLC payment key to sender for transactions broadcast by counterparty */ -uint64_t ChannelDetails_get_inbound_capacity_msat(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +struct LDKPublicKey AcceptChannel_get_htlc_basepoint(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); /** - * The available inbound capacity for the remote peer to send HTLCs to us. This does not - * include any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not - * available for inclusion in new inbound HTLCs). - * Note that there are some corner cases not fully handled here, so the actual available - * inbound capacity may be slightly higher than this. - * - * This value is not exact. Due to various in-flight changes, feerate changes, and our - * counterparty's conflict-avoidance policy, exactly this amount is not likely to be spendable. - * However, our counterparty should be able to spend nearly this amount. + * Used to derive an HTLC payment key to sender for transactions broadcast by counterparty */ -void ChannelDetails_set_inbound_capacity_msat(struct LDKChannelDetails *NONNULL_PTR this_ptr, uint64_t val); +void AcceptChannel_set_htlc_basepoint(struct LDKAcceptChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * The number of required confirmations on the funding transaction before the funding will be - * considered \"locked\". This number is selected by the channel fundee (i.e. us if - * [`is_outbound`] is *not* set), and can be selected for inbound channels with - * [`ChannelHandshakeConfig::minimum_depth`] or limited for outbound channels with - * [`ChannelHandshakeLimits::max_minimum_depth`]. - * - * This value will be `None` for outbound channels until the counterparty accepts the channel. - * - * [`is_outbound`]: ChannelDetails::is_outbound - * [`ChannelHandshakeConfig::minimum_depth`]: crate::util::config::ChannelHandshakeConfig::minimum_depth - * [`ChannelHandshakeLimits::max_minimum_depth`]: crate::util::config::ChannelHandshakeLimits::max_minimum_depth + * The first to-be-broadcast-by-sender transaction's per commitment point */ -struct LDKCOption_u32Z ChannelDetails_get_confirmations_required(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +struct LDKPublicKey AcceptChannel_get_first_per_commitment_point(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); /** - * The number of required confirmations on the funding transaction before the funding will be - * considered \"locked\". This number is selected by the channel fundee (i.e. us if - * [`is_outbound`] is *not* set), and can be selected for inbound channels with - * [`ChannelHandshakeConfig::minimum_depth`] or limited for outbound channels with - * [`ChannelHandshakeLimits::max_minimum_depth`]. - * - * This value will be `None` for outbound channels until the counterparty accepts the channel. - * - * [`is_outbound`]: ChannelDetails::is_outbound - * [`ChannelHandshakeConfig::minimum_depth`]: crate::util::config::ChannelHandshakeConfig::minimum_depth - * [`ChannelHandshakeLimits::max_minimum_depth`]: crate::util::config::ChannelHandshakeLimits::max_minimum_depth + * The first to-be-broadcast-by-sender transaction's per commitment point */ -void ChannelDetails_set_confirmations_required(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u32Z val); +void AcceptChannel_set_first_per_commitment_point(struct LDKAcceptChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * The number of blocks (after our commitment transaction confirms) that we will need to wait - * until we can claim our funds after we force-close the channel. During this time our - * counterparty is allowed to punish us if we broadcasted a stale state. If our counterparty - * force-closes the channel and broadcasts a commitment transaction we do not have to wait any - * time to claim our non-HTLC-encumbered funds. + * 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 value will be `None` for outbound channels until the counterparty accepts the channel. + * 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 LDKCOption_u16Z ChannelDetails_get_force_close_spend_delay(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +struct LDKChannelTypeFeatures AcceptChannel_get_channel_type(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); /** - * The number of blocks (after our commitment transaction confirms) that we will need to wait - * until we can claim our funds after we force-close the channel. During this time our - * counterparty is allowed to punish us if we broadcasted a stale state. If our counterparty - * force-closes the channel and broadcasts a commitment transaction we do not have to wait any - * time to claim our non-HTLC-encumbered funds. + * 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`]. * - * This value will be `None` for outbound channels until the counterparty accepts the channel. + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void ChannelDetails_set_force_close_spend_delay(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u16Z val); +void AcceptChannel_set_channel_type(struct LDKAcceptChannel *NONNULL_PTR this_ptr, struct LDKChannelTypeFeatures val); /** - * True if the channel was initiated (and thus funded) by us. + * Creates a copy of the AcceptChannel */ -bool ChannelDetails_get_is_outbound(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +struct LDKAcceptChannel AcceptChannel_clone(const struct LDKAcceptChannel *NONNULL_PTR orig); /** - * True if the channel was initiated (and thus funded) by us. + * Checks if two AcceptChannels contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void ChannelDetails_set_is_outbound(struct LDKChannelDetails *NONNULL_PTR this_ptr, bool val); +bool AcceptChannel_eq(const struct LDKAcceptChannel *NONNULL_PTR a, const struct LDKAcceptChannel *NONNULL_PTR b); /** - * True if the channel is confirmed, funding_locked messages have been exchanged, and the - * channel is not currently being shut down. `funding_locked` message exchange implies the - * required confirmation count has been reached (and we were connected to the peer at some - * point after the funding transaction received enough confirmations). The required - * confirmation count is provided in [`confirmations_required`]. - * - * [`confirmations_required`]: ChannelDetails::confirmations_required + * Frees any resources used by the FundingCreated, if is_owned is set and inner is non-NULL. */ -bool ChannelDetails_get_is_funding_locked(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +void FundingCreated_free(struct LDKFundingCreated this_obj); /** - * True if the channel is confirmed, funding_locked messages have been exchanged, and the - * channel is not currently being shut down. `funding_locked` message exchange implies the - * required confirmation count has been reached (and we were connected to the peer at some - * point after the funding transaction received enough confirmations). The required - * confirmation count is provided in [`confirmations_required`]. - * - * [`confirmations_required`]: ChannelDetails::confirmations_required + * A temporary channel ID, until the funding is established */ -void ChannelDetails_set_is_funding_locked(struct LDKChannelDetails *NONNULL_PTR this_ptr, bool val); +const uint8_t (*FundingCreated_get_temporary_channel_id(const struct LDKFundingCreated *NONNULL_PTR this_ptr))[32]; /** - * True if the channel is (a) confirmed and funding_locked messages have been exchanged, (b) - * the peer is connected, and (c) the channel is not currently negotiating a shutdown. - * - * This is a strict superset of `is_funding_locked`. + * A temporary channel ID, until the funding is established */ -bool ChannelDetails_get_is_usable(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +void FundingCreated_set_temporary_channel_id(struct LDKFundingCreated *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * True if the channel is (a) confirmed and funding_locked messages have been exchanged, (b) - * the peer is connected, and (c) the channel is not currently negotiating a shutdown. - * - * This is a strict superset of `is_funding_locked`. + * The funding transaction ID */ -void ChannelDetails_set_is_usable(struct LDKChannelDetails *NONNULL_PTR this_ptr, bool val); +const uint8_t (*FundingCreated_get_funding_txid(const struct LDKFundingCreated *NONNULL_PTR this_ptr))[32]; /** - * True if this channel is (or will be) publicly-announced. + * The funding transaction ID */ -bool ChannelDetails_get_is_public(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +void FundingCreated_set_funding_txid(struct LDKFundingCreated *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * True if this channel is (or will be) publicly-announced. + * The specific output index funding this channel */ -void ChannelDetails_set_is_public(struct LDKChannelDetails *NONNULL_PTR this_ptr, bool val); +uint16_t FundingCreated_get_funding_output_index(const struct LDKFundingCreated *NONNULL_PTR this_ptr); /** - * Constructs a new ChannelDetails given each field + * The specific output index funding this channel */ -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 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); +void FundingCreated_set_funding_output_index(struct LDKFundingCreated *NONNULL_PTR this_ptr, uint16_t val); /** - * Creates a copy of the ChannelDetails + * The signature of the channel initiator (funder) on the initial commitment transaction */ -struct LDKChannelDetails ChannelDetails_clone(const struct LDKChannelDetails *NONNULL_PTR orig); +struct LDKSignature FundingCreated_get_signature(const struct LDKFundingCreated *NONNULL_PTR this_ptr); /** - * Frees any resources used by the PaymentSendFailure + * The signature of the channel initiator (funder) on the initial commitment transaction */ -void PaymentSendFailure_free(struct LDKPaymentSendFailure this_ptr); +void FundingCreated_set_signature(struct LDKFundingCreated *NONNULL_PTR this_ptr, struct LDKSignature val); /** - * Creates a copy of the PaymentSendFailure + * Constructs a new FundingCreated given each field */ -struct LDKPaymentSendFailure PaymentSendFailure_clone(const struct LDKPaymentSendFailure *NONNULL_PTR orig); +MUST_USE_RES struct LDKFundingCreated FundingCreated_new(struct LDKThirtyTwoBytes temporary_channel_id_arg, struct LDKThirtyTwoBytes funding_txid_arg, uint16_t funding_output_index_arg, struct LDKSignature signature_arg); /** - * Utility method to constructs a new ParameterError-variant PaymentSendFailure + * Creates a copy of the FundingCreated */ -struct LDKPaymentSendFailure PaymentSendFailure_parameter_error(struct LDKAPIError a); +struct LDKFundingCreated FundingCreated_clone(const struct LDKFundingCreated *NONNULL_PTR orig); /** - * Utility method to constructs a new PathParameterError-variant PaymentSendFailure + * Checks if two FundingCreateds contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -struct LDKPaymentSendFailure PaymentSendFailure_path_parameter_error(struct LDKCVec_CResult_NoneAPIErrorZZ a); +bool FundingCreated_eq(const struct LDKFundingCreated *NONNULL_PTR a, const struct LDKFundingCreated *NONNULL_PTR b); /** - * Utility method to constructs a new AllFailedRetrySafe-variant PaymentSendFailure + * Frees any resources used by the FundingSigned, if is_owned is set and inner is non-NULL. */ -struct LDKPaymentSendFailure PaymentSendFailure_all_failed_retry_safe(struct LDKCVec_APIErrorZ a); +void FundingSigned_free(struct LDKFundingSigned this_obj); /** - * Utility method to constructs a new PartialFailure-variant PaymentSendFailure + * The channel ID */ -struct LDKPaymentSendFailure PaymentSendFailure_partial_failure(struct LDKCVec_CResult_NoneAPIErrorZZ results, struct LDKRouteParameters failed_paths_retry, struct LDKThirtyTwoBytes payment_id); +const uint8_t (*FundingSigned_get_channel_id(const struct LDKFundingSigned *NONNULL_PTR this_ptr))[32]; /** - * Frees any resources used by the PhantomRouteHints, if is_owned is set and inner is non-NULL. + * The channel ID */ -void PhantomRouteHints_free(struct LDKPhantomRouteHints this_obj); +void FundingSigned_set_channel_id(struct LDKFundingSigned *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * The list of channels to be included in the invoice route hints. + * The signature of the channel acceptor (fundee) on the initial commitment transaction */ -struct LDKCVec_ChannelDetailsZ PhantomRouteHints_get_channels(const struct LDKPhantomRouteHints *NONNULL_PTR this_ptr); +struct LDKSignature FundingSigned_get_signature(const struct LDKFundingSigned *NONNULL_PTR this_ptr); /** - * The list of channels to be included in the invoice route hints. + * The signature of the channel acceptor (fundee) on the initial commitment transaction */ -void PhantomRouteHints_set_channels(struct LDKPhantomRouteHints *NONNULL_PTR this_ptr, struct LDKCVec_ChannelDetailsZ val); +void FundingSigned_set_signature(struct LDKFundingSigned *NONNULL_PTR this_ptr, struct LDKSignature val); /** - * A fake scid used for representing the phantom node's fake channel in generating the invoice - * route hints. + * Constructs a new FundingSigned given each field */ -uint64_t PhantomRouteHints_get_phantom_scid(const struct LDKPhantomRouteHints *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKFundingSigned FundingSigned_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKSignature signature_arg); /** - * A fake scid used for representing the phantom node's fake channel in generating the invoice - * route hints. + * Creates a copy of the FundingSigned */ -void PhantomRouteHints_set_phantom_scid(struct LDKPhantomRouteHints *NONNULL_PTR this_ptr, uint64_t val); +struct LDKFundingSigned FundingSigned_clone(const struct LDKFundingSigned *NONNULL_PTR orig); /** - * The pubkey of the real backing node that would ultimately receive the payment. + * Checks if two FundingSigneds contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -struct LDKPublicKey PhantomRouteHints_get_real_node_pubkey(const struct LDKPhantomRouteHints *NONNULL_PTR this_ptr); +bool FundingSigned_eq(const struct LDKFundingSigned *NONNULL_PTR a, const struct LDKFundingSigned *NONNULL_PTR b); /** - * The pubkey of the real backing node that would ultimately receive the payment. + * Frees any resources used by the ChannelReady, if is_owned is set and inner is non-NULL. */ -void PhantomRouteHints_set_real_node_pubkey(struct LDKPhantomRouteHints *NONNULL_PTR this_ptr, struct LDKPublicKey val); +void ChannelReady_free(struct LDKChannelReady this_obj); /** - * Constructs a new PhantomRouteHints given each field + * The channel ID */ -MUST_USE_RES struct LDKPhantomRouteHints PhantomRouteHints_new(struct LDKCVec_ChannelDetailsZ channels_arg, uint64_t phantom_scid_arg, struct LDKPublicKey real_node_pubkey_arg); +const uint8_t (*ChannelReady_get_channel_id(const struct LDKChannelReady *NONNULL_PTR this_ptr))[32]; /** - * Constructs a new ChannelManager to hold several channels and route between them. - * - * This is the main \"logic hub\" for all channel-related actions, and implements - * ChannelMessageHandler. - * - * Non-proportional fees are fixed according to our risk using the provided fee estimator. - * - * panics if channel_value_satoshis is >= `MAX_FUNDING_SATOSHIS`! - * - * Users need to notify the new ChannelManager when a new block is connected or - * disconnected using its `block_connected` and `block_disconnected` methods, starting - * from after `params.latest_hash`. + * The channel ID */ -MUST_USE_RES struct LDKChannelManager ChannelManager_new(struct LDKFeeEstimator fee_est, struct LDKWatch chain_monitor, struct LDKBroadcasterInterface tx_broadcaster, struct LDKLogger logger, struct LDKKeysInterface keys_manager, struct LDKUserConfig config, struct LDKChainParameters params); +void ChannelReady_set_channel_id(struct LDKChannelReady *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Gets the current configuration applied to all new channels, as + * The per-commitment point of the second commitment transaction */ -MUST_USE_RES struct LDKUserConfig ChannelManager_get_current_default_configuration(const struct LDKChannelManager *NONNULL_PTR this_arg); +struct LDKPublicKey ChannelReady_get_next_per_commitment_point(const struct LDKChannelReady *NONNULL_PTR this_ptr); /** - * Creates a new outbound channel to the given remote node and with the given value. - * - * `user_channel_id` will be provided back as in - * [`Event::FundingGenerationReady::user_channel_id`] to allow tracking of which events - * correspond with which `create_channel` call. Note that the `user_channel_id` defaults to 0 - * for inbound channels, so you may wish to avoid using 0 for `user_channel_id` here. - * `user_channel_id` has no meaning inside of LDK, it is simply copied to events and otherwise - * ignored. - * - * Raises [`APIError::APIMisuseError`] when `channel_value_satoshis` > 2**24 or `push_msat` is - * greater than `channel_value_satoshis * 1k` or `channel_value_satoshis < 1000`. - * - * Note that we do not check if you are currently connected to the given peer. If no - * connection is available, the outbound `open_channel` message may fail to send, resulting in - * the channel eventually being silently forgotten (dropped on reload). - * - * Returns the new Channel's temporary `channel_id`. This ID will appear as - * [`Event::FundingGenerationReady::temporary_channel_id`] and in - * [`ChannelDetails::channel_id`] until after - * [`ChannelManager::funding_transaction_generated`] is called, swapping the Channel's ID for - * one derived from the funding transaction's TXID. If the counterparty rejects the channel - * immediately, this temporary ID will appear in [`Event::ChannelClosed::channel_id`]. - * - * [`Event::FundingGenerationReady::user_channel_id`]: events::Event::FundingGenerationReady::user_channel_id - * [`Event::FundingGenerationReady::temporary_channel_id`]: events::Event::FundingGenerationReady::temporary_channel_id - * [`Event::ChannelClosed::channel_id`]: events::Event::ChannelClosed::channel_id - * - * Note that override_config (or a relevant inner pointer) may be NULL or all-0s to represent None + * The per-commitment point of the second commitment transaction */ -MUST_USE_RES struct LDKCResult__u832APIErrorZ ChannelManager_create_channel(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKPublicKey their_network_key, uint64_t channel_value_satoshis, uint64_t push_msat, uint64_t user_channel_id, struct LDKUserConfig override_config); +void ChannelReady_set_next_per_commitment_point(struct LDKChannelReady *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Gets the list of open channels, in random order. See ChannelDetail field documentation for - * more information. + * 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. */ -MUST_USE_RES struct LDKCVec_ChannelDetailsZ ChannelManager_list_channels(const struct LDKChannelManager *NONNULL_PTR this_arg); +struct LDKCOption_u64Z ChannelReady_get_short_channel_id_alias(const struct LDKChannelReady *NONNULL_PTR this_ptr); /** - * Gets the list of usable channels, in random order. Useful as an argument to - * get_route to ensure non-announced channels are used. - * - * These are guaranteed to have their [`ChannelDetails::is_usable`] value set to true, see the - * documentation for [`ChannelDetails::is_usable`] for more info on exactly what the criteria - * are. + * 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. */ -MUST_USE_RES struct LDKCVec_ChannelDetailsZ ChannelManager_list_usable_channels(const struct LDKChannelManager *NONNULL_PTR this_arg); +void ChannelReady_set_short_channel_id_alias(struct LDKChannelReady *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); /** - * Begins the process of closing a channel. After this call (plus some timeout), no new HTLCs - * will be accepted on the given channel, and after additional timeout/the closing of all - * pending HTLCs, the channel will be closed on chain. - * - * * If we are the channel initiator, we will pay between our [`Background`] and - * [`ChannelConfig::force_close_avoidance_max_fee_satoshis`] plus our [`Normal`] fee - * estimate. - * * If our counterparty is the channel initiator, we will require a channel closing - * transaction feerate of at least our [`Background`] feerate or the feerate which - * would appear on a force-closure transaction, whichever is lower. We will allow our - * counterparty to pay as much fee as they'd like, however. - * - * May generate a SendShutdown message event on success, which should be relayed. - * - * [`ChannelConfig::force_close_avoidance_max_fee_satoshis`]: crate::util::config::ChannelConfig::force_close_avoidance_max_fee_satoshis - * [`Background`]: crate::chain::chaininterface::ConfirmationTarget::Background - * [`Normal`]: crate::chain::chaininterface::ConfirmationTarget::Normal + * Constructs a new ChannelReady given each field */ -MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_close_channel(const struct LDKChannelManager *NONNULL_PTR this_arg, const uint8_t (*channel_id)[32]); +MUST_USE_RES struct LDKChannelReady ChannelReady_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKPublicKey next_per_commitment_point_arg, struct LDKCOption_u64Z short_channel_id_alias_arg); /** - * Begins the process of closing a channel. After this call (plus some timeout), no new HTLCs - * will be accepted on the given channel, and after additional timeout/the closing of all - * pending HTLCs, the channel will be closed on chain. - * - * `target_feerate_sat_per_1000_weight` has different meanings depending on if we initiated - * the channel being closed or not: - * * If we are the channel initiator, we will pay at least this feerate on the closing - * transaction. The upper-bound is set by - * [`ChannelConfig::force_close_avoidance_max_fee_satoshis`] plus our [`Normal`] fee - * estimate (or `target_feerate_sat_per_1000_weight`, if it is greater). - * * If our counterparty is the channel initiator, we will refuse to accept a channel closure - * transaction feerate below `target_feerate_sat_per_1000_weight` (or the feerate which - * will appear on a force-closure transaction, whichever is lower). - * - * May generate a SendShutdown message event on success, which should be relayed. - * - * [`ChannelConfig::force_close_avoidance_max_fee_satoshis`]: crate::util::config::ChannelConfig::force_close_avoidance_max_fee_satoshis - * [`Background`]: crate::chain::chaininterface::ConfirmationTarget::Background - * [`Normal`]: crate::chain::chaininterface::ConfirmationTarget::Normal + * Creates a copy of the ChannelReady */ -MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_close_channel_with_target_feerate(const struct LDKChannelManager *NONNULL_PTR this_arg, const uint8_t (*channel_id)[32], uint32_t target_feerate_sats_per_1000_weight); +struct LDKChannelReady ChannelReady_clone(const struct LDKChannelReady *NONNULL_PTR orig); /** - * Force closes a channel, immediately broadcasting the latest local commitment transaction to - * the chain and rejecting new HTLCs on the given channel. Fails if channel_id is unknown to the manager. + * Checks if two ChannelReadys contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_force_close_channel(const struct LDKChannelManager *NONNULL_PTR this_arg, const uint8_t (*channel_id)[32]); +bool ChannelReady_eq(const struct LDKChannelReady *NONNULL_PTR a, const struct LDKChannelReady *NONNULL_PTR b); /** - * Force close all channels, immediately broadcasting the latest local commitment transaction - * for each to the chain and rejecting new HTLCs on each. + * Frees any resources used by the Shutdown, if is_owned is set and inner is non-NULL. */ -void ChannelManager_force_close_all_channels(const struct LDKChannelManager *NONNULL_PTR this_arg); +void Shutdown_free(struct LDKShutdown this_obj); /** - * Sends a payment along a given route. - * - * Value parameters are provided via the last hop in route, see documentation for RouteHop - * fields for more info. - * - * Note that if the payment_hash already exists elsewhere (eg you're sending a duplicative - * payment), we don't do anything to stop you! We always try to ensure that if the provided - * next hop knows the preimage to payment_hash they can claim an additional amount as - * specified in the last hop in the route! Thus, you should probably do your own - * payment_preimage tracking (which you should already be doing as they represent \"proof of - * payment\") and prevent double-sends yourself. - * - * May generate SendHTLCs message(s) event on success, which should be relayed. - * - * Each path may have a different return value, and PaymentSendValue may return a Vec with - * each entry matching the corresponding-index entry in the route paths, see - * PaymentSendFailure for more info. - * - * In general, a path may raise: - * * APIError::RouteError when an invalid route or forwarding parameter (cltv_delta, fee, - * node public key) is specified. - * * APIError::ChannelUnavailable if the next-hop channel is not available for updates - * (including due to previous monitor update failure or new permanent monitor update - * failure). - * * APIError::MonitorUpdateFailed if a new monitor update failure prevented sending the - * relevant updates. - * - * Note that depending on the type of the PaymentSendFailure the HTLC may have been - * irrevocably committed to on our end. In such a case, do NOT retry the payment with a - * different route unless you intend to pay twice! - * - * payment_secret is unrelated to payment_hash (or PaymentPreimage) and exists to authenticate - * the sender to the recipient and prevent payment-probing (deanonymization) attacks. For - * newer nodes, it will be provided to you in the invoice. If you do not have one, the Route - * must not contain multiple paths as multi-path payments require a recipient-provided - * payment_secret. - * If a payment_secret *is* provided, we assume that the invoice had the payment_secret feature - * bit set (either as required or as available). If multiple paths are present in the Route, - * we assume the invoice had the basic_mpp feature set. - * - * Note that payment_secret (or a relevant inner pointer) may be NULL or all-0s to represent None + * The channel ID */ -MUST_USE_RES struct LDKCResult_PaymentIdPaymentSendFailureZ ChannelManager_send_payment(const struct LDKChannelManager *NONNULL_PTR this_arg, const struct LDKRoute *NONNULL_PTR route, struct LDKThirtyTwoBytes payment_hash, struct LDKThirtyTwoBytes payment_secret); +const uint8_t (*Shutdown_get_channel_id(const struct LDKShutdown *NONNULL_PTR this_ptr))[32]; /** - * Retries a payment along the given [`Route`]. - * - * 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, 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`] + * The channel ID + */ +void Shutdown_set_channel_id(struct LDKShutdown *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); + +/** + * The destination of this peer's funds on closing. + * Must be in one of these forms: p2pkh, p2sh, p2wpkh, p2wsh. */ -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); +struct LDKu8slice Shutdown_get_scriptpubkey(const struct LDKShutdown *NONNULL_PTR this_ptr); /** - * 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 + * The destination of this peer's funds on closing. + * Must be in one of these forms: p2pkh, p2sh, p2wpkh, p2wsh. */ -void ChannelManager_abandon_payment(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes payment_id); +void Shutdown_set_scriptpubkey(struct LDKShutdown *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val); /** - * 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 - * the preimage, it must be a cryptographically secure random value that no intermediate node - * would be able to guess -- otherwise, an intermediate node may claim the payment and it will - * never reach the recipient. - * - * See [`send_payment`] documentation for more details on the return value of this function. - * - * Similar to regular payments, you MUST NOT reuse a `payment_preimage` value. See - * [`send_payment`] for more information about the risks of duplicate preimage usage. - * - * Note that `route` must have exactly one path. - * - * [`send_payment`]: Self::send_payment - * - * Note that payment_preimage (or a relevant inner pointer) may be NULL or all-0s to represent None + * Constructs a new Shutdown given each field */ -MUST_USE_RES struct LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ ChannelManager_send_spontaneous_payment(const struct LDKChannelManager *NONNULL_PTR this_arg, const struct LDKRoute *NONNULL_PTR route, struct LDKThirtyTwoBytes payment_preimage); +MUST_USE_RES struct LDKShutdown Shutdown_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKCVec_u8Z scriptpubkey_arg); /** - * Call this upon creation of a funding transaction for the given channel. - * - * 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`]. - * - * 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 - * keys per-channel). - * - * Do NOT broadcast the funding transaction yourself. When we have safely received our - * counterparty's signature the funding transaction will automatically be broadcast via the - * [`BroadcasterInterface`] provided when this `ChannelManager` was constructed. - * - * Note that this includes RBF or similar transaction replacement strategies - lightning does - * not currently support replacing a funding transaction on an existing channel. Instead, - * create a new channel with a conflicting funding transaction. - * - * [`Event::FundingGenerationReady`]: crate::util::events::Event::FundingGenerationReady - * [`Event::ChannelClosed`]: crate::util::events::Event::ChannelClosed + * Creates a copy of the Shutdown */ -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); +struct LDKShutdown Shutdown_clone(const struct LDKShutdown *NONNULL_PTR orig); /** - * Regenerates channel_announcements and generates a signed node_announcement from the given - * arguments, providing them in corresponding events via - * [`get_and_clear_pending_msg_events`], if at least one public channel has been confirmed - * on-chain. This effectively re-broadcasts all channel announcements and sends our node - * announcement to ensure that the lightning P2P network is aware of the channels we have and - * our network addresses. - * - * `rgb` is a node \"color\" and `alias` is a printable human-readable string to describe this - * node to humans. They carry no in-protocol meaning. - * - * `addresses` represent the set (possibly empty) of socket addresses on which this node - * accepts incoming connections. These will be included in the node_announcement, publicly - * tying these addresses together and to this node. If you wish to preserve user privacy, - * addresses should likely contain only Tor Onion addresses. - * - * Panics if `addresses` is absurdly large (more than 500). - * - * [`get_and_clear_pending_msg_events`]: MessageSendEventsProvider::get_and_clear_pending_msg_events + * Checks if two Shutdowns contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void ChannelManager_broadcast_node_announcement(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKThreeBytes rgb, struct LDKThirtyTwoBytes alias, struct LDKCVec_NetAddressZ addresses); +bool Shutdown_eq(const struct LDKShutdown *NONNULL_PTR a, const struct LDKShutdown *NONNULL_PTR b); /** - * Processes HTLCs which are pending waiting on random forward delay. - * - * Should only really ever be called in response to a PendingHTLCsForwardable event. - * Will likely generate further events. + * Frees any resources used by the ClosingSignedFeeRange, if is_owned is set and inner is non-NULL. */ -void ChannelManager_process_pending_htlc_forwards(const struct LDKChannelManager *NONNULL_PTR this_arg); +void ClosingSignedFeeRange_free(struct LDKClosingSignedFeeRange this_obj); /** - * Performs actions which should happen on startup and roughly once per minute thereafter. - * - * This currently includes: - * * Increasing or decreasing the on-chain feerate estimates for our outbound channels, - * * Broadcasting `ChannelUpdate` messages if we've been disconnected from our peer for more - * than a minute, informing the network that they should no longer attempt to route over - * the channel. - * - * Note that this may cause reentrancy through `chain::Watch::update_channel` calls or feerate - * estimate fetches. + * The minimum absolute fee, in satoshis, which the sender is willing to place on the closing + * transaction. */ -void ChannelManager_timer_tick_occurred(const struct LDKChannelManager *NONNULL_PTR this_arg); +uint64_t ClosingSignedFeeRange_get_min_fee_satoshis(const struct LDKClosingSignedFeeRange *NONNULL_PTR this_ptr); /** - * Indicates that the preimage for payment_hash is unknown or the received amount is incorrect - * after a PaymentReceived event, failing the HTLC back to its origin and freeing resources - * along the path (including in our own channel on which we received it). - * Returns false if no payment was found to fail backwards, true if the process of failing the - * HTLC backwards has been started. + * The minimum absolute fee, in satoshis, which the sender is willing to place on the closing + * transaction. */ -MUST_USE_RES bool ChannelManager_fail_htlc_backwards(const struct LDKChannelManager *NONNULL_PTR this_arg, const uint8_t (*payment_hash)[32]); +void ClosingSignedFeeRange_set_min_fee_satoshis(struct LDKClosingSignedFeeRange *NONNULL_PTR this_ptr, uint64_t val); /** - * 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. - * - * 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 + * The maximum absolute fee, in satoshis, which the sender is willing to place on the closing + * transaction. */ -MUST_USE_RES bool ChannelManager_claim_funds(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes payment_preimage); +uint64_t ClosingSignedFeeRange_get_max_fee_satoshis(const struct LDKClosingSignedFeeRange *NONNULL_PTR this_ptr); /** - * Gets the node_id held by this ChannelManager + * The maximum absolute fee, in satoshis, which the sender is willing to place on the closing + * transaction. */ -MUST_USE_RES struct LDKPublicKey ChannelManager_get_our_node_id(const struct LDKChannelManager *NONNULL_PTR this_arg); +void ClosingSignedFeeRange_set_max_fee_satoshis(struct LDKClosingSignedFeeRange *NONNULL_PTR this_ptr, uint64_t val); /** - * Called to accept a request to open a channel after [`Event::OpenChannelRequest`] has been - * triggered. - * - * The `temporary_channel_id` parameter indicates which inbound channel should be accepted. - * - * [`Event::OpenChannelRequest`]: crate::util::events::Event::OpenChannelRequest + * Constructs a new ClosingSignedFeeRange given each field */ -MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_accept_inbound_channel(const struct LDKChannelManager *NONNULL_PTR this_arg, const uint8_t (*temporary_channel_id)[32]); +MUST_USE_RES struct LDKClosingSignedFeeRange ClosingSignedFeeRange_new(uint64_t min_fee_satoshis_arg, uint64_t max_fee_satoshis_arg); /** - * 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. - * - * 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 - * passed directly to [`claim_funds`]. - * - * 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 + * Creates a copy of the ClosingSignedFeeRange */ -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); +struct LDKClosingSignedFeeRange ClosingSignedFeeRange_clone(const struct LDKClosingSignedFeeRange *NONNULL_PTR orig); /** - * 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. - * - * # Note - * This method is deprecated and will be removed soon. - * - * [`create_inbound_payment`]: Self::create_inbound_payment + * Checks if two ClosingSignedFeeRanges contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -MUST_USE_RES struct 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); +bool ClosingSignedFeeRange_eq(const struct LDKClosingSignedFeeRange *NONNULL_PTR a, const struct LDKClosingSignedFeeRange *NONNULL_PTR b); /** - * Gets a [`PaymentSecret`] for a given [`PaymentHash`], for which the payment preimage is - * stored external to LDK. - * - * A [`PaymentReceived`] event will only be generated if the [`PaymentSecret`] matches a - * 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`]) 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` - * before a [`PaymentReceived`] event will be generated, ensuring that we do not provide the - * sender \"proof-of-payment\" unless they have paid the required amount. - * - * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for - * in excess of the current time. This should roughly match the expiry time set in the invoice. - * After this many seconds, we will remove the inbound payment, resulting in any attempts to - * pay the invoice failing. The BOLT spec suggests 3,600 secs as a default validity time for - * invoices when no timeout is set. - * - * Note that we use block header time to time-out pending inbound payments (with some margin - * to compensate for the inaccuracy of block header timestamps). Thus, in practice we will - * accept a payment and generate a [`PaymentReceived`] event for some time after the expiry. - * If you need exact expiry semantics, you should enforce them upon receipt of - * [`PaymentReceived`]. - * - * 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 + * Frees any resources used by the ClosingSigned, if is_owned is set and inner is non-NULL. */ -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); +void ClosingSigned_free(struct LDKClosingSigned this_obj); /** - * 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. - * - * # Note - * This method is deprecated and will be removed soon. - * - * [`create_inbound_payment_for_hash`]: Self::create_inbound_payment_for_hash + * The channel ID */ -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); +const uint8_t (*ClosingSigned_get_channel_id(const struct LDKClosingSigned *NONNULL_PTR this_ptr))[32]; /** - * 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 + * The channel ID */ -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); +void ClosingSigned_set_channel_id(struct LDKClosingSigned *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * 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 + * The proposed total fee for the closing transaction */ -MUST_USE_RES uint64_t ChannelManager_get_phantom_scid(const struct LDKChannelManager *NONNULL_PTR this_arg); +uint64_t ClosingSigned_get_fee_satoshis(const struct LDKClosingSigned *NONNULL_PTR this_ptr); /** - * Gets route hints for use in receiving [phantom node payments]. - * - * [phantom node payments]: crate::chain::keysinterface::PhantomKeysManager + * The proposed total fee for the closing transaction */ -MUST_USE_RES struct LDKPhantomRouteHints ChannelManager_get_phantom_route_hints(const struct LDKChannelManager *NONNULL_PTR this_arg); +void ClosingSigned_set_fee_satoshis(struct LDKClosingSigned *NONNULL_PTR this_ptr, uint64_t val); /** - * Constructs a new MessageSendEventsProvider which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned MessageSendEventsProvider must be freed before this_arg is + * A signature on the closing transaction + */ +struct LDKSignature ClosingSigned_get_signature(const struct LDKClosingSigned *NONNULL_PTR this_ptr); + +/** + * A signature on the closing transaction */ -struct LDKMessageSendEventsProvider ChannelManager_as_MessageSendEventsProvider(const struct LDKChannelManager *NONNULL_PTR this_arg); +void ClosingSigned_set_signature(struct LDKClosingSigned *NONNULL_PTR this_ptr, struct LDKSignature val); /** - * Constructs a new EventsProvider which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned EventsProvider must be freed before this_arg is + * The minimum and maximum fees which the sender is willing to accept, provided only by new + * nodes. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKEventsProvider ChannelManager_as_EventsProvider(const struct LDKChannelManager *NONNULL_PTR this_arg); +struct LDKClosingSignedFeeRange ClosingSigned_get_fee_range(const struct LDKClosingSigned *NONNULL_PTR this_ptr); /** - * Constructs a new Listen which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned Listen must be freed before this_arg is + * The minimum and maximum fees which the sender is willing to accept, provided only by new + * nodes. + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKListen ChannelManager_as_Listen(const struct LDKChannelManager *NONNULL_PTR this_arg); +void ClosingSigned_set_fee_range(struct LDKClosingSigned *NONNULL_PTR this_ptr, struct LDKClosingSignedFeeRange val); /** - * Constructs a new Confirm which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned Confirm must be freed before this_arg is + * Constructs a new ClosingSigned given each field */ -struct LDKConfirm ChannelManager_as_Confirm(const struct LDKChannelManager *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKClosingSigned ClosingSigned_new(struct LDKThirtyTwoBytes channel_id_arg, uint64_t fee_satoshis_arg, struct LDKSignature signature_arg, struct LDKClosingSignedFeeRange fee_range_arg); /** - * Blocks until ChannelManager needs to be persisted or a timeout is reached. It returns a bool - * indicating whether persistence is necessary. Only one listener on - * `await_persistable_update` or `await_persistable_update_timeout` is guaranteed to be woken - * up. - * - * Note that this method is not available with the `no-std` feature. + * Creates a copy of the ClosingSigned */ -MUST_USE_RES bool ChannelManager_await_persistable_update_timeout(const struct LDKChannelManager *NONNULL_PTR this_arg, uint64_t max_wait); +struct LDKClosingSigned ClosingSigned_clone(const struct LDKClosingSigned *NONNULL_PTR orig); /** - * Blocks until ChannelManager needs to be persisted. Only one listener on - * `await_persistable_update` or `await_persistable_update_timeout` is guaranteed to be woken - * up. + * Checks if two ClosingSigneds contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void ChannelManager_await_persistable_update(const struct LDKChannelManager *NONNULL_PTR this_arg); +bool ClosingSigned_eq(const struct LDKClosingSigned *NONNULL_PTR a, const struct LDKClosingSigned *NONNULL_PTR b); /** - * Gets the latest best block which was connected either via the [`chain::Listen`] or - * [`chain::Confirm`] interfaces. + * Frees any resources used by the UpdateAddHTLC, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKBestBlock ChannelManager_current_best_block(const struct LDKChannelManager *NONNULL_PTR this_arg); +void UpdateAddHTLC_free(struct LDKUpdateAddHTLC this_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 + * The channel ID */ -struct LDKChannelMessageHandler ChannelManager_as_ChannelMessageHandler(const struct LDKChannelManager *NONNULL_PTR this_arg); +const uint8_t (*UpdateAddHTLC_get_channel_id(const struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr))[32]; /** - * Serialize the CounterpartyForwardingInfo object into a byte array which can be read by CounterpartyForwardingInfo_read + * The channel ID */ -struct LDKCVec_u8Z CounterpartyForwardingInfo_write(const struct LDKCounterpartyForwardingInfo *NONNULL_PTR obj); +void UpdateAddHTLC_set_channel_id(struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Read a CounterpartyForwardingInfo from a byte array, created by CounterpartyForwardingInfo_write + * The HTLC ID */ -struct LDKCResult_CounterpartyForwardingInfoDecodeErrorZ CounterpartyForwardingInfo_read(struct LDKu8slice ser); +uint64_t UpdateAddHTLC_get_htlc_id(const struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr); /** - * Serialize the ChannelCounterparty object into a byte array which can be read by ChannelCounterparty_read + * The HTLC ID */ -struct LDKCVec_u8Z ChannelCounterparty_write(const struct LDKChannelCounterparty *NONNULL_PTR obj); +void UpdateAddHTLC_set_htlc_id(struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr, uint64_t val); /** - * Read a ChannelCounterparty from a byte array, created by ChannelCounterparty_write + * The HTLC value in milli-satoshi */ -struct LDKCResult_ChannelCounterpartyDecodeErrorZ ChannelCounterparty_read(struct LDKu8slice ser); +uint64_t UpdateAddHTLC_get_amount_msat(const struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr); /** - * Serialize the ChannelDetails object into a byte array which can be read by ChannelDetails_read + * The HTLC value in milli-satoshi */ -struct LDKCVec_u8Z ChannelDetails_write(const struct LDKChannelDetails *NONNULL_PTR obj); +void UpdateAddHTLC_set_amount_msat(struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr, uint64_t val); /** - * Read a ChannelDetails from a byte array, created by ChannelDetails_write + * The payment hash, the pre-image of which controls HTLC redemption */ -struct LDKCResult_ChannelDetailsDecodeErrorZ ChannelDetails_read(struct LDKu8slice ser); +const uint8_t (*UpdateAddHTLC_get_payment_hash(const struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr))[32]; /** - * Serialize the PhantomRouteHints object into a byte array which can be read by PhantomRouteHints_read + * The payment hash, the pre-image of which controls HTLC redemption */ -struct LDKCVec_u8Z PhantomRouteHints_write(const struct LDKPhantomRouteHints *NONNULL_PTR obj); +void UpdateAddHTLC_set_payment_hash(struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Read a PhantomRouteHints from a byte array, created by PhantomRouteHints_write + * The expiry height of the HTLC */ -struct LDKCResult_PhantomRouteHintsDecodeErrorZ PhantomRouteHints_read(struct LDKu8slice ser); +uint32_t UpdateAddHTLC_get_cltv_expiry(const struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr); /** - * Serialize the ChannelManager object into a byte array which can be read by ChannelManager_read + * The expiry height of the HTLC */ -struct LDKCVec_u8Z ChannelManager_write(const struct LDKChannelManager *NONNULL_PTR obj); +void UpdateAddHTLC_set_cltv_expiry(struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr, uint32_t val); /** - * Frees any resources used by the ChannelManagerReadArgs, if is_owned is set and inner is non-NULL. + * Creates a copy of the UpdateAddHTLC */ -void ChannelManagerReadArgs_free(struct LDKChannelManagerReadArgs this_obj); +struct LDKUpdateAddHTLC UpdateAddHTLC_clone(const struct LDKUpdateAddHTLC *NONNULL_PTR orig); /** - * The keys provider which will give us relevant keys. Some keys will be loaded during - * deserialization and KeysInterface::read_chan_signer will be used to read per-Channel - * signing data. + * Checks if two UpdateAddHTLCs 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. */ -const struct LDKKeysInterface *ChannelManagerReadArgs_get_keys_manager(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); +bool UpdateAddHTLC_eq(const struct LDKUpdateAddHTLC *NONNULL_PTR a, const struct LDKUpdateAddHTLC *NONNULL_PTR b); /** - * The keys provider which will give us relevant keys. Some keys will be loaded during - * deserialization and KeysInterface::read_chan_signer will be used to read per-Channel - * signing data. + * Frees any resources used by the OnionMessage, if is_owned is set and inner is non-NULL. */ -void ChannelManagerReadArgs_set_keys_manager(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKKeysInterface val); +void OnionMessage_free(struct LDKOnionMessage this_obj); /** - * The fee_estimator for use in the ChannelManager in the future. - * - * No calls to the FeeEstimator will be made during deserialization. + * Used in decrypting the onion packet's payload. */ -const struct LDKFeeEstimator *ChannelManagerReadArgs_get_fee_estimator(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); +struct LDKPublicKey OnionMessage_get_blinding_point(const struct LDKOnionMessage *NONNULL_PTR this_ptr); /** - * The fee_estimator for use in the ChannelManager in the future. - * - * No calls to the FeeEstimator will be made during deserialization. + * Used in decrypting the onion packet's payload. */ -void ChannelManagerReadArgs_set_fee_estimator(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKFeeEstimator val); +void OnionMessage_set_blinding_point(struct LDKOnionMessage *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * The chain::Watch for use in the ChannelManager in the future. - * - * No calls to the chain::Watch will be made during deserialization. It is assumed that - * you have deserialized ChannelMonitors separately and will add them to your - * chain::Watch after deserializing this ChannelManager. + * Creates a copy of the OnionMessage */ -const struct LDKWatch *ChannelManagerReadArgs_get_chain_monitor(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); +struct LDKOnionMessage OnionMessage_clone(const struct LDKOnionMessage *NONNULL_PTR orig); /** - * The chain::Watch for use in the ChannelManager in the future. - * - * No calls to the chain::Watch will be made during deserialization. It is assumed that - * you have deserialized ChannelMonitors separately and will add them to your - * chain::Watch after deserializing this ChannelManager. + * Checks if two OnionMessages contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void ChannelManagerReadArgs_set_chain_monitor(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKWatch val); +bool OnionMessage_eq(const struct LDKOnionMessage *NONNULL_PTR a, const struct LDKOnionMessage *NONNULL_PTR b); /** - * The BroadcasterInterface which will be used in the ChannelManager in the future and may be - * used to broadcast the latest local commitment transactions of channels which must be - * force-closed during deserialization. + * Frees any resources used by the UpdateFulfillHTLC, if is_owned is set and inner is non-NULL. */ -const struct LDKBroadcasterInterface *ChannelManagerReadArgs_get_tx_broadcaster(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); +void UpdateFulfillHTLC_free(struct LDKUpdateFulfillHTLC this_obj); /** - * The BroadcasterInterface which will be used in the ChannelManager in the future and may be - * used to broadcast the latest local commitment transactions of channels which must be - * force-closed during deserialization. + * The channel ID */ -void ChannelManagerReadArgs_set_tx_broadcaster(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKBroadcasterInterface val); +const uint8_t (*UpdateFulfillHTLC_get_channel_id(const struct LDKUpdateFulfillHTLC *NONNULL_PTR this_ptr))[32]; /** - * The Logger for use in the ChannelManager and which may be used to log information during - * deserialization. + * The channel ID */ -const struct LDKLogger *ChannelManagerReadArgs_get_logger(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); +void UpdateFulfillHTLC_set_channel_id(struct LDKUpdateFulfillHTLC *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * The Logger for use in the ChannelManager and which may be used to log information during - * deserialization. + * The HTLC ID */ -void ChannelManagerReadArgs_set_logger(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKLogger val); +uint64_t UpdateFulfillHTLC_get_htlc_id(const struct LDKUpdateFulfillHTLC *NONNULL_PTR this_ptr); /** - * Default settings used for new channels. Any existing channels will continue to use the - * runtime settings which were stored when the ChannelManager was serialized. + * The HTLC ID */ -struct LDKUserConfig ChannelManagerReadArgs_get_default_config(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); +void UpdateFulfillHTLC_set_htlc_id(struct LDKUpdateFulfillHTLC *NONNULL_PTR this_ptr, uint64_t val); /** - * Default settings used for new channels. Any existing channels will continue to use the - * runtime settings which were stored when the ChannelManager was serialized. + * The pre-image of the payment hash, allowing HTLC redemption */ -void ChannelManagerReadArgs_set_default_config(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKUserConfig val); +const uint8_t (*UpdateFulfillHTLC_get_payment_preimage(const struct LDKUpdateFulfillHTLC *NONNULL_PTR this_ptr))[32]; /** - * Simple utility function to create a ChannelManagerReadArgs which creates the monitor - * HashMap for you. This is primarily useful for C bindings where it is not practical to - * populate a HashMap directly from C. + * The pre-image of the payment hash, allowing HTLC redemption */ -MUST_USE_RES struct LDKChannelManagerReadArgs ChannelManagerReadArgs_new(struct LDKKeysInterface keys_manager, struct LDKFeeEstimator fee_estimator, struct LDKWatch chain_monitor, struct LDKBroadcasterInterface tx_broadcaster, struct LDKLogger logger, struct LDKUserConfig default_config, struct LDKCVec_ChannelMonitorZ channel_monitors); +void UpdateFulfillHTLC_set_payment_preimage(struct LDKUpdateFulfillHTLC *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Read a C2Tuple_BlockHashChannelManagerZ from a byte array, created by C2Tuple_BlockHashChannelManagerZ_write + * Constructs a new UpdateFulfillHTLC given each field */ -struct LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ C2Tuple_BlockHashChannelManagerZ_read(struct LDKu8slice ser, struct LDKChannelManagerReadArgs arg); +MUST_USE_RES struct LDKUpdateFulfillHTLC UpdateFulfillHTLC_new(struct LDKThirtyTwoBytes channel_id_arg, uint64_t htlc_id_arg, struct LDKThirtyTwoBytes payment_preimage_arg); /** - * Frees any resources used by the DecodeError, if is_owned is set and inner is non-NULL. + * Creates a copy of the UpdateFulfillHTLC */ -void DecodeError_free(struct LDKDecodeError this_obj); +struct LDKUpdateFulfillHTLC UpdateFulfillHTLC_clone(const struct LDKUpdateFulfillHTLC *NONNULL_PTR orig); /** - * Creates a copy of the DecodeError + * Checks if two UpdateFulfillHTLCs contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -struct LDKDecodeError DecodeError_clone(const struct LDKDecodeError *NONNULL_PTR orig); +bool UpdateFulfillHTLC_eq(const struct LDKUpdateFulfillHTLC *NONNULL_PTR a, const struct LDKUpdateFulfillHTLC *NONNULL_PTR b); /** - * Frees any resources used by the Init, if is_owned is set and inner is non-NULL. + * Frees any resources used by the UpdateFailHTLC, if is_owned is set and inner is non-NULL. */ -void Init_free(struct LDKInit this_obj); +void UpdateFailHTLC_free(struct LDKUpdateFailHTLC this_obj); /** - * The relevant features which the sender supports + * The channel ID */ -struct LDKInitFeatures Init_get_features(const struct LDKInit *NONNULL_PTR this_ptr); +const uint8_t (*UpdateFailHTLC_get_channel_id(const struct LDKUpdateFailHTLC *NONNULL_PTR this_ptr))[32]; /** - * The relevant features which the sender supports + * The channel ID */ -void Init_set_features(struct LDKInit *NONNULL_PTR this_ptr, struct LDKInitFeatures val); +void UpdateFailHTLC_set_channel_id(struct LDKUpdateFailHTLC *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Constructs a new Init given each field + * The HTLC ID */ -MUST_USE_RES struct LDKInit Init_new(struct LDKInitFeatures features_arg); +uint64_t UpdateFailHTLC_get_htlc_id(const struct LDKUpdateFailHTLC *NONNULL_PTR this_ptr); /** - * Creates a copy of the Init + * The HTLC ID */ -struct LDKInit Init_clone(const struct LDKInit *NONNULL_PTR orig); +void UpdateFailHTLC_set_htlc_id(struct LDKUpdateFailHTLC *NONNULL_PTR this_ptr, uint64_t val); /** - * Frees any resources used by the ErrorMessage, if is_owned is set and inner is non-NULL. + * Creates a copy of the UpdateFailHTLC */ -void ErrorMessage_free(struct LDKErrorMessage this_obj); +struct LDKUpdateFailHTLC UpdateFailHTLC_clone(const struct LDKUpdateFailHTLC *NONNULL_PTR orig); /** - * 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. + * Checks if two UpdateFailHTLCs 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. */ -const uint8_t (*ErrorMessage_get_channel_id(const struct LDKErrorMessage *NONNULL_PTR this_ptr))[32]; +bool UpdateFailHTLC_eq(const struct LDKUpdateFailHTLC *NONNULL_PTR a, const struct LDKUpdateFailHTLC *NONNULL_PTR b); /** - * 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. + * Frees any resources used by the UpdateFailMalformedHTLC, if is_owned is set and inner is non-NULL. */ -void ErrorMessage_set_channel_id(struct LDKErrorMessage *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void UpdateFailMalformedHTLC_free(struct LDKUpdateFailMalformedHTLC this_obj); /** - * 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 channel ID */ -struct LDKStr ErrorMessage_get_data(const struct LDKErrorMessage *NONNULL_PTR this_ptr); +const uint8_t (*UpdateFailMalformedHTLC_get_channel_id(const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR this_ptr))[32]; /** - * 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 channel ID */ -void ErrorMessage_set_data(struct LDKErrorMessage *NONNULL_PTR this_ptr, struct LDKStr val); +void UpdateFailMalformedHTLC_set_channel_id(struct LDKUpdateFailMalformedHTLC *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Constructs a new ErrorMessage given each field + * The HTLC ID */ -MUST_USE_RES struct LDKErrorMessage ErrorMessage_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKStr data_arg); +uint64_t UpdateFailMalformedHTLC_get_htlc_id(const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR this_ptr); /** - * Creates a copy of the ErrorMessage + * The HTLC ID */ -struct LDKErrorMessage ErrorMessage_clone(const struct LDKErrorMessage *NONNULL_PTR orig); +void UpdateFailMalformedHTLC_set_htlc_id(struct LDKUpdateFailMalformedHTLC *NONNULL_PTR this_ptr, uint64_t val); /** - * Frees any resources used by the WarningMessage, if is_owned is set and inner is non-NULL. + * The failure code */ -void WarningMessage_free(struct LDKWarningMessage this_obj); +uint16_t UpdateFailMalformedHTLC_get_failure_code(const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR this_ptr); /** - * The channel ID involved in the warning. - * - * All-0s indicates a warning unrelated to a specific channel. + * The failure code */ -const uint8_t (*WarningMessage_get_channel_id(const struct LDKWarningMessage *NONNULL_PTR this_ptr))[32]; +void UpdateFailMalformedHTLC_set_failure_code(struct LDKUpdateFailMalformedHTLC *NONNULL_PTR this_ptr, uint16_t val); /** - * The channel ID involved in the warning. - * - * All-0s indicates a warning unrelated to a specific channel. + * Creates a copy of the UpdateFailMalformedHTLC */ -void WarningMessage_set_channel_id(struct LDKWarningMessage *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKUpdateFailMalformedHTLC UpdateFailMalformedHTLC_clone(const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR orig); /** - * 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. + * Checks if two UpdateFailMalformedHTLCs contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -struct LDKStr WarningMessage_get_data(const struct LDKWarningMessage *NONNULL_PTR this_ptr); +bool UpdateFailMalformedHTLC_eq(const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR a, const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR b); /** - * 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. + * Frees any resources used by the CommitmentSigned, if is_owned is set and inner is non-NULL. */ -void WarningMessage_set_data(struct LDKWarningMessage *NONNULL_PTR this_ptr, struct LDKStr val); +void CommitmentSigned_free(struct LDKCommitmentSigned this_obj); /** - * Constructs a new WarningMessage given each field + * The channel ID */ -MUST_USE_RES struct LDKWarningMessage WarningMessage_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKStr data_arg); +const uint8_t (*CommitmentSigned_get_channel_id(const struct LDKCommitmentSigned *NONNULL_PTR this_ptr))[32]; /** - * Creates a copy of the WarningMessage + * The channel ID */ -struct LDKWarningMessage WarningMessage_clone(const struct LDKWarningMessage *NONNULL_PTR orig); +void CommitmentSigned_set_channel_id(struct LDKCommitmentSigned *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Frees any resources used by the Ping, if is_owned is set and inner is non-NULL. + * A signature on the commitment transaction */ -void Ping_free(struct LDKPing this_obj); +struct LDKSignature CommitmentSigned_get_signature(const struct LDKCommitmentSigned *NONNULL_PTR this_ptr); /** - * The desired response length + * A signature on the commitment transaction */ -uint16_t Ping_get_ponglen(const struct LDKPing *NONNULL_PTR this_ptr); +void CommitmentSigned_set_signature(struct LDKCommitmentSigned *NONNULL_PTR this_ptr, struct LDKSignature val); /** - * The desired response length + * Signatures on the HTLC transactions + * + * Returns a copy of the field. */ -void Ping_set_ponglen(struct LDKPing *NONNULL_PTR this_ptr, uint16_t val); +struct LDKCVec_SignatureZ CommitmentSigned_get_htlc_signatures(const struct LDKCommitmentSigned *NONNULL_PTR this_ptr); /** - * The ping packet size. - * This field is not sent on the wire. byteslen zeros are sent. + * Signatures on the HTLC transactions */ -uint16_t Ping_get_byteslen(const struct LDKPing *NONNULL_PTR this_ptr); +void CommitmentSigned_set_htlc_signatures(struct LDKCommitmentSigned *NONNULL_PTR this_ptr, struct LDKCVec_SignatureZ val); /** - * The ping packet size. - * This field is not sent on the wire. byteslen zeros are sent. + * Constructs a new CommitmentSigned given each field */ -void Ping_set_byteslen(struct LDKPing *NONNULL_PTR this_ptr, uint16_t val); +MUST_USE_RES struct LDKCommitmentSigned CommitmentSigned_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKSignature signature_arg, struct LDKCVec_SignatureZ htlc_signatures_arg); /** - * Constructs a new Ping given each field + * Creates a copy of the CommitmentSigned */ -MUST_USE_RES struct LDKPing Ping_new(uint16_t ponglen_arg, uint16_t byteslen_arg); +struct LDKCommitmentSigned CommitmentSigned_clone(const struct LDKCommitmentSigned *NONNULL_PTR orig); /** - * Creates a copy of the Ping + * Checks if two CommitmentSigneds contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -struct LDKPing Ping_clone(const struct LDKPing *NONNULL_PTR orig); +bool CommitmentSigned_eq(const struct LDKCommitmentSigned *NONNULL_PTR a, const struct LDKCommitmentSigned *NONNULL_PTR b); /** - * Frees any resources used by the Pong, if is_owned is set and inner is non-NULL. + * Frees any resources used by the RevokeAndACK, if is_owned is set and inner is non-NULL. */ -void Pong_free(struct LDKPong this_obj); +void RevokeAndACK_free(struct LDKRevokeAndACK this_obj); /** - * The pong packet size. - * This field is not sent on the wire. byteslen zeros are sent. + * The channel ID */ -uint16_t Pong_get_byteslen(const struct LDKPong *NONNULL_PTR this_ptr); +const uint8_t (*RevokeAndACK_get_channel_id(const struct LDKRevokeAndACK *NONNULL_PTR this_ptr))[32]; /** - * The pong packet size. - * This field is not sent on the wire. byteslen zeros are sent. + * The channel ID */ -void Pong_set_byteslen(struct LDKPong *NONNULL_PTR this_ptr, uint16_t val); +void RevokeAndACK_set_channel_id(struct LDKRevokeAndACK *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Constructs a new Pong given each field + * The secret corresponding to the per-commitment point */ -MUST_USE_RES struct LDKPong Pong_new(uint16_t byteslen_arg); +const uint8_t (*RevokeAndACK_get_per_commitment_secret(const struct LDKRevokeAndACK *NONNULL_PTR this_ptr))[32]; /** - * Creates a copy of the Pong + * The secret corresponding to the per-commitment point */ -struct LDKPong Pong_clone(const struct LDKPong *NONNULL_PTR orig); +void RevokeAndACK_set_per_commitment_secret(struct LDKRevokeAndACK *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Frees any resources used by the OpenChannel, if is_owned is set and inner is non-NULL. + * The next sender-broadcast commitment transaction's per-commitment point */ -void OpenChannel_free(struct LDKOpenChannel this_obj); +struct LDKPublicKey RevokeAndACK_get_next_per_commitment_point(const struct LDKRevokeAndACK *NONNULL_PTR this_ptr); /** - * The genesis hash of the blockchain where the channel is to be opened + * The next sender-broadcast commitment transaction's per-commitment point */ -const uint8_t (*OpenChannel_get_chain_hash(const struct LDKOpenChannel *NONNULL_PTR this_ptr))[32]; +void RevokeAndACK_set_next_per_commitment_point(struct LDKRevokeAndACK *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * The genesis hash of the blockchain where the channel is to be opened + * Constructs a new RevokeAndACK given each field */ -void OpenChannel_set_chain_hash(struct LDKOpenChannel *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +MUST_USE_RES struct LDKRevokeAndACK RevokeAndACK_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKThirtyTwoBytes per_commitment_secret_arg, struct LDKPublicKey next_per_commitment_point_arg); /** - * A temporary channel ID, until the funding outpoint is announced + * Creates a copy of the RevokeAndACK */ -const uint8_t (*OpenChannel_get_temporary_channel_id(const struct LDKOpenChannel *NONNULL_PTR this_ptr))[32]; +struct LDKRevokeAndACK RevokeAndACK_clone(const struct LDKRevokeAndACK *NONNULL_PTR orig); /** - * A temporary channel ID, until the funding outpoint is announced + * Checks if two RevokeAndACKs contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void OpenChannel_set_temporary_channel_id(struct LDKOpenChannel *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +bool RevokeAndACK_eq(const struct LDKRevokeAndACK *NONNULL_PTR a, const struct LDKRevokeAndACK *NONNULL_PTR b); /** - * The channel value + * Frees any resources used by the UpdateFee, if is_owned is set and inner is non-NULL. */ -uint64_t OpenChannel_get_funding_satoshis(const struct LDKOpenChannel *NONNULL_PTR this_ptr); +void UpdateFee_free(struct LDKUpdateFee this_obj); /** - * The channel value + * The channel ID */ -void OpenChannel_set_funding_satoshis(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint64_t val); +const uint8_t (*UpdateFee_get_channel_id(const struct LDKUpdateFee *NONNULL_PTR this_ptr))[32]; /** - * The amount to push to the counterparty as part of the open, in milli-satoshi + * The channel ID */ -uint64_t OpenChannel_get_push_msat(const struct LDKOpenChannel *NONNULL_PTR this_ptr); +void UpdateFee_set_channel_id(struct LDKUpdateFee *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * The amount to push to the counterparty as part of the open, in milli-satoshi + * Fee rate per 1000-weight of the transaction */ -void OpenChannel_set_push_msat(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint64_t val); +uint32_t UpdateFee_get_feerate_per_kw(const struct LDKUpdateFee *NONNULL_PTR this_ptr); /** - * The threshold below which outputs on transactions broadcast by sender will be omitted + * Fee rate per 1000-weight of the transaction */ -uint64_t OpenChannel_get_dust_limit_satoshis(const struct LDKOpenChannel *NONNULL_PTR this_ptr); +void UpdateFee_set_feerate_per_kw(struct LDKUpdateFee *NONNULL_PTR this_ptr, uint32_t val); /** - * The threshold below which outputs on transactions broadcast by sender will be omitted + * Constructs a new UpdateFee given each field */ -void OpenChannel_set_dust_limit_satoshis(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint64_t val); +MUST_USE_RES struct LDKUpdateFee UpdateFee_new(struct LDKThirtyTwoBytes channel_id_arg, uint32_t feerate_per_kw_arg); /** - * The maximum inbound HTLC value in flight towards sender, in milli-satoshi + * Creates a copy of the UpdateFee */ -uint64_t OpenChannel_get_max_htlc_value_in_flight_msat(const struct LDKOpenChannel *NONNULL_PTR this_ptr); +struct LDKUpdateFee UpdateFee_clone(const struct LDKUpdateFee *NONNULL_PTR orig); /** - * The maximum inbound HTLC value in flight towards sender, in milli-satoshi + * Checks if two UpdateFees contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void OpenChannel_set_max_htlc_value_in_flight_msat(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint64_t val); +bool UpdateFee_eq(const struct LDKUpdateFee *NONNULL_PTR a, const struct LDKUpdateFee *NONNULL_PTR b); /** - * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel + * Frees any resources used by the DataLossProtect, if is_owned is set and inner is non-NULL. */ -uint64_t OpenChannel_get_channel_reserve_satoshis(const struct LDKOpenChannel *NONNULL_PTR this_ptr); +void DataLossProtect_free(struct LDKDataLossProtect this_obj); /** - * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel + * Proof that the sender knows the per-commitment secret of a specific commitment transaction + * belonging to the recipient */ -void OpenChannel_set_channel_reserve_satoshis(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint64_t val); +const uint8_t (*DataLossProtect_get_your_last_per_commitment_secret(const struct LDKDataLossProtect *NONNULL_PTR this_ptr))[32]; /** - * The minimum HTLC size incoming to sender, in milli-satoshi + * Proof that the sender knows the per-commitment secret of a specific commitment transaction + * belonging to the recipient */ -uint64_t OpenChannel_get_htlc_minimum_msat(const struct LDKOpenChannel *NONNULL_PTR this_ptr); +void DataLossProtect_set_your_last_per_commitment_secret(struct LDKDataLossProtect *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * The minimum HTLC size incoming to sender, in milli-satoshi + * The sender's per-commitment point for their current commitment transaction */ -void OpenChannel_set_htlc_minimum_msat(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint64_t val); +struct LDKPublicKey DataLossProtect_get_my_current_per_commitment_point(const struct LDKDataLossProtect *NONNULL_PTR this_ptr); /** - * The feerate per 1000-weight of sender generated transactions, until updated by update_fee + * The sender's per-commitment point for their current commitment transaction */ -uint32_t OpenChannel_get_feerate_per_kw(const struct LDKOpenChannel *NONNULL_PTR this_ptr); +void DataLossProtect_set_my_current_per_commitment_point(struct LDKDataLossProtect *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * The feerate per 1000-weight of sender generated transactions, until updated by update_fee + * Constructs a new DataLossProtect given each field */ -void OpenChannel_set_feerate_per_kw(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint32_t val); +MUST_USE_RES struct LDKDataLossProtect DataLossProtect_new(struct LDKThirtyTwoBytes your_last_per_commitment_secret_arg, struct LDKPublicKey my_current_per_commitment_point_arg); /** - * The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction + * Creates a copy of the DataLossProtect */ -uint16_t OpenChannel_get_to_self_delay(const struct LDKOpenChannel *NONNULL_PTR this_ptr); +struct LDKDataLossProtect DataLossProtect_clone(const struct LDKDataLossProtect *NONNULL_PTR orig); /** - * The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction + * Checks if two DataLossProtects contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void OpenChannel_set_to_self_delay(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint16_t val); +bool DataLossProtect_eq(const struct LDKDataLossProtect *NONNULL_PTR a, const struct LDKDataLossProtect *NONNULL_PTR b); /** - * The maximum number of inbound HTLCs towards sender + * Frees any resources used by the ChannelReestablish, if is_owned is set and inner is non-NULL. */ -uint16_t OpenChannel_get_max_accepted_htlcs(const struct LDKOpenChannel *NONNULL_PTR this_ptr); +void ChannelReestablish_free(struct LDKChannelReestablish this_obj); /** - * The maximum number of inbound HTLCs towards sender + * The channel ID */ -void OpenChannel_set_max_accepted_htlcs(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint16_t val); +const uint8_t (*ChannelReestablish_get_channel_id(const struct LDKChannelReestablish *NONNULL_PTR this_ptr))[32]; /** - * The sender's key controlling the funding transaction + * The channel ID */ -struct LDKPublicKey OpenChannel_get_funding_pubkey(const struct LDKOpenChannel *NONNULL_PTR this_ptr); +void ChannelReestablish_set_channel_id(struct LDKChannelReestablish *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * The sender's key controlling the funding transaction + * The next commitment number for the sender */ -void OpenChannel_set_funding_pubkey(struct LDKOpenChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); +uint64_t ChannelReestablish_get_next_local_commitment_number(const struct LDKChannelReestablish *NONNULL_PTR this_ptr); /** - * Used to derive a revocation key for transactions broadcast by counterparty + * The next commitment number for the sender */ -struct LDKPublicKey OpenChannel_get_revocation_basepoint(const struct LDKOpenChannel *NONNULL_PTR this_ptr); +void ChannelReestablish_set_next_local_commitment_number(struct LDKChannelReestablish *NONNULL_PTR this_ptr, uint64_t val); /** - * Used to derive a revocation key for transactions broadcast by counterparty + * The next commitment number for the recipient */ -void OpenChannel_set_revocation_basepoint(struct LDKOpenChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); +uint64_t ChannelReestablish_get_next_remote_commitment_number(const struct LDKChannelReestablish *NONNULL_PTR this_ptr); /** - * A payment key to sender for transactions broadcast by counterparty + * The next commitment number for the recipient */ -struct LDKPublicKey OpenChannel_get_payment_point(const struct LDKOpenChannel *NONNULL_PTR this_ptr); +void ChannelReestablish_set_next_remote_commitment_number(struct LDKChannelReestablish *NONNULL_PTR this_ptr, uint64_t val); /** - * A payment key to sender for transactions broadcast by counterparty + * Creates a copy of the ChannelReestablish */ -void OpenChannel_set_payment_point(struct LDKOpenChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); +struct LDKChannelReestablish ChannelReestablish_clone(const struct LDKChannelReestablish *NONNULL_PTR orig); /** - * Used to derive a payment key to sender for transactions broadcast by sender + * Checks if two ChannelReestablishs contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -struct LDKPublicKey OpenChannel_get_delayed_payment_basepoint(const struct LDKOpenChannel *NONNULL_PTR this_ptr); +bool ChannelReestablish_eq(const struct LDKChannelReestablish *NONNULL_PTR a, const struct LDKChannelReestablish *NONNULL_PTR b); /** - * Used to derive a payment key to sender for transactions broadcast by sender + * Frees any resources used by the AnnouncementSignatures, if is_owned is set and inner is non-NULL. */ -void OpenChannel_set_delayed_payment_basepoint(struct LDKOpenChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); +void AnnouncementSignatures_free(struct LDKAnnouncementSignatures this_obj); /** - * Used to derive an HTLC payment key to sender + * The channel ID */ -struct LDKPublicKey OpenChannel_get_htlc_basepoint(const struct LDKOpenChannel *NONNULL_PTR this_ptr); +const uint8_t (*AnnouncementSignatures_get_channel_id(const struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr))[32]; /** - * Used to derive an HTLC payment key to sender + * The channel ID */ -void OpenChannel_set_htlc_basepoint(struct LDKOpenChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); +void AnnouncementSignatures_set_channel_id(struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * The first to-be-broadcast-by-sender transaction's per commitment point + * The short channel ID */ -struct LDKPublicKey OpenChannel_get_first_per_commitment_point(const struct LDKOpenChannel *NONNULL_PTR this_ptr); +uint64_t AnnouncementSignatures_get_short_channel_id(const struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr); /** - * The first to-be-broadcast-by-sender transaction's per commitment point + * The short channel ID */ -void OpenChannel_set_first_per_commitment_point(struct LDKOpenChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); +void AnnouncementSignatures_set_short_channel_id(struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr, uint64_t val); /** - * Channel flags + * A signature by the node key */ -uint8_t OpenChannel_get_channel_flags(const struct LDKOpenChannel *NONNULL_PTR this_ptr); +struct LDKSignature AnnouncementSignatures_get_node_signature(const struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr); /** - * Channel flags + * A signature by the node key */ -void OpenChannel_set_channel_flags(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint8_t val); +void AnnouncementSignatures_set_node_signature(struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr, struct LDKSignature 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 + * A signature by the funding key */ -struct LDKChannelTypeFeatures OpenChannel_get_channel_type(const struct LDKOpenChannel *NONNULL_PTR this_ptr); +struct LDKSignature AnnouncementSignatures_get_bitcoin_signature(const struct LDKAnnouncementSignatures *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 + * A signature by the funding key */ -void OpenChannel_set_channel_type(struct LDKOpenChannel *NONNULL_PTR this_ptr, struct LDKChannelTypeFeatures val); +void AnnouncementSignatures_set_bitcoin_signature(struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr, struct LDKSignature val); /** - * Creates a copy of the OpenChannel + * Constructs a new AnnouncementSignatures given each field */ -struct LDKOpenChannel OpenChannel_clone(const struct LDKOpenChannel *NONNULL_PTR orig); +MUST_USE_RES struct LDKAnnouncementSignatures AnnouncementSignatures_new(struct LDKThirtyTwoBytes channel_id_arg, uint64_t short_channel_id_arg, struct LDKSignature node_signature_arg, struct LDKSignature bitcoin_signature_arg); /** - * Frees any resources used by the AcceptChannel, if is_owned is set and inner is non-NULL. + * Creates a copy of the AnnouncementSignatures */ -void AcceptChannel_free(struct LDKAcceptChannel this_obj); +struct LDKAnnouncementSignatures AnnouncementSignatures_clone(const struct LDKAnnouncementSignatures *NONNULL_PTR orig); /** - * A temporary channel ID, until the funding outpoint is announced + * Checks if two AnnouncementSignaturess 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. */ -const uint8_t (*AcceptChannel_get_temporary_channel_id(const struct LDKAcceptChannel *NONNULL_PTR this_ptr))[32]; +bool AnnouncementSignatures_eq(const struct LDKAnnouncementSignatures *NONNULL_PTR a, const struct LDKAnnouncementSignatures *NONNULL_PTR b); /** - * A temporary channel ID, until the funding outpoint is announced + * Frees any resources used by the NetAddress */ -void AcceptChannel_set_temporary_channel_id(struct LDKAcceptChannel *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void NetAddress_free(struct LDKNetAddress this_ptr); /** - * The threshold below which outputs on transactions broadcast by sender will be omitted + * Creates a copy of the NetAddress */ -uint64_t AcceptChannel_get_dust_limit_satoshis(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); +struct LDKNetAddress NetAddress_clone(const struct LDKNetAddress *NONNULL_PTR orig); /** - * The threshold below which outputs on transactions broadcast by sender will be omitted + * Utility method to constructs a new IPv4-variant NetAddress */ -void AcceptChannel_set_dust_limit_satoshis(struct LDKAcceptChannel *NONNULL_PTR this_ptr, uint64_t val); +struct LDKNetAddress NetAddress_ipv4(struct LDKFourBytes addr, uint16_t port); /** - * The maximum inbound HTLC value in flight towards sender, in milli-satoshi + * Utility method to constructs a new IPv6-variant NetAddress */ -uint64_t AcceptChannel_get_max_htlc_value_in_flight_msat(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); +struct LDKNetAddress NetAddress_ipv6(struct LDKSixteenBytes addr, uint16_t port); /** - * The maximum inbound HTLC value in flight towards sender, in milli-satoshi + * Utility method to constructs a new OnionV2-variant NetAddress */ -void AcceptChannel_set_max_htlc_value_in_flight_msat(struct LDKAcceptChannel *NONNULL_PTR this_ptr, uint64_t val); +struct LDKNetAddress NetAddress_onion_v2(struct LDKTwelveBytes a); /** - * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel + * Utility method to constructs a new OnionV3-variant NetAddress */ -uint64_t AcceptChannel_get_channel_reserve_satoshis(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); +struct LDKNetAddress NetAddress_onion_v3(struct LDKThirtyTwoBytes ed25519_pubkey, uint16_t checksum, uint8_t version, uint16_t port); /** - * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel + * Utility method to constructs a new Hostname-variant NetAddress */ -void AcceptChannel_set_channel_reserve_satoshis(struct LDKAcceptChannel *NONNULL_PTR this_ptr, uint64_t val); +struct LDKNetAddress NetAddress_hostname(struct LDKHostname hostname, uint16_t port); /** - * The minimum HTLC size incoming to sender, in milli-satoshi + * Checks if two NetAddresss contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -uint64_t AcceptChannel_get_htlc_minimum_msat(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); +bool NetAddress_eq(const struct LDKNetAddress *NONNULL_PTR a, const struct LDKNetAddress *NONNULL_PTR b); /** - * The minimum HTLC size incoming to sender, in milli-satoshi + * Serialize the NetAddress object into a byte array which can be read by NetAddress_read */ -void AcceptChannel_set_htlc_minimum_msat(struct LDKAcceptChannel *NONNULL_PTR this_ptr, uint64_t val); +struct LDKCVec_u8Z NetAddress_write(const struct LDKNetAddress *NONNULL_PTR obj); /** - * Minimum depth of the funding transaction before the channel is considered open + * Read a NetAddress from a byte array, created by NetAddress_write */ -uint32_t AcceptChannel_get_minimum_depth(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); +struct LDKCResult_NetAddressDecodeErrorZ NetAddress_read(struct LDKu8slice ser); /** - * Minimum depth of the funding transaction before the channel is considered open + * Frees any resources used by the UnsignedNodeAnnouncement, if is_owned is set and inner is non-NULL. */ -void AcceptChannel_set_minimum_depth(struct LDKAcceptChannel *NONNULL_PTR this_ptr, uint32_t val); +void UnsignedNodeAnnouncement_free(struct LDKUnsignedNodeAnnouncement this_obj); /** - * The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction + * The advertised features */ -uint16_t AcceptChannel_get_to_self_delay(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); +struct LDKNodeFeatures UnsignedNodeAnnouncement_get_features(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr); /** - * The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction + * The advertised features */ -void AcceptChannel_set_to_self_delay(struct LDKAcceptChannel *NONNULL_PTR this_ptr, uint16_t val); +void UnsignedNodeAnnouncement_set_features(struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKNodeFeatures val); /** - * The maximum number of inbound HTLCs towards sender + * A strictly monotonic announcement counter, with gaps allowed */ -uint16_t AcceptChannel_get_max_accepted_htlcs(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); +uint32_t UnsignedNodeAnnouncement_get_timestamp(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr); /** - * The maximum number of inbound HTLCs towards sender + * A strictly monotonic announcement counter, with gaps allowed */ -void AcceptChannel_set_max_accepted_htlcs(struct LDKAcceptChannel *NONNULL_PTR this_ptr, uint16_t val); +void UnsignedNodeAnnouncement_set_timestamp(struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr, uint32_t val); /** - * The sender's key controlling the funding transaction + * The node_id this announcement originated from (don't rebroadcast the node_announcement back + * to this node). */ -struct LDKPublicKey AcceptChannel_get_funding_pubkey(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); +struct LDKPublicKey UnsignedNodeAnnouncement_get_node_id(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr); /** - * The sender's key controlling the funding transaction + * The node_id this announcement originated from (don't rebroadcast the node_announcement back + * to this node). */ -void AcceptChannel_set_funding_pubkey(struct LDKAcceptChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); +void UnsignedNodeAnnouncement_set_node_id(struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Used to derive a revocation key for transactions broadcast by counterparty + * An RGB color for UI purposes */ -struct LDKPublicKey AcceptChannel_get_revocation_basepoint(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); +const uint8_t (*UnsignedNodeAnnouncement_get_rgb(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr))[3]; /** - * Used to derive a revocation key for transactions broadcast by counterparty + * An RGB color for UI purposes */ -void AcceptChannel_set_revocation_basepoint(struct LDKAcceptChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); +void UnsignedNodeAnnouncement_set_rgb(struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKThreeBytes val); /** - * A payment key to sender for transactions broadcast by counterparty + * An alias, for UI purposes. This should be sanitized before use. There is no guarantee + * of uniqueness. */ -struct LDKPublicKey AcceptChannel_get_payment_point(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); +const uint8_t (*UnsignedNodeAnnouncement_get_alias(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr))[32]; /** - * A payment key to sender for transactions broadcast by counterparty + * An alias, for UI purposes. This should be sanitized before use. There is no guarantee + * of uniqueness. */ -void AcceptChannel_set_payment_point(struct LDKAcceptChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); +void UnsignedNodeAnnouncement_set_alias(struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Used to derive a payment key to sender for transactions broadcast by sender + * List of addresses on which this node is reachable + * + * Returns a copy of the field. */ -struct LDKPublicKey AcceptChannel_get_delayed_payment_basepoint(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); +struct LDKCVec_NetAddressZ UnsignedNodeAnnouncement_get_addresses(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr); /** - * Used to derive a payment key to sender for transactions broadcast by sender + * List of addresses on which this node is reachable */ -void AcceptChannel_set_delayed_payment_basepoint(struct LDKAcceptChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); +void UnsignedNodeAnnouncement_set_addresses(struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKCVec_NetAddressZ val); /** - * Used to derive an HTLC payment key to sender for transactions broadcast by counterparty + * Creates a copy of the UnsignedNodeAnnouncement */ -struct LDKPublicKey AcceptChannel_get_htlc_basepoint(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); +struct LDKUnsignedNodeAnnouncement UnsignedNodeAnnouncement_clone(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR orig); /** - * Used to derive an HTLC payment key to sender for transactions broadcast by counterparty + * Checks if two UnsignedNodeAnnouncements contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void AcceptChannel_set_htlc_basepoint(struct LDKAcceptChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); +bool UnsignedNodeAnnouncement_eq(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR a, const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR b); /** - * The first to-be-broadcast-by-sender transaction's per commitment point + * Frees any resources used by the NodeAnnouncement, if is_owned is set and inner is non-NULL. */ -struct LDKPublicKey AcceptChannel_get_first_per_commitment_point(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); +void NodeAnnouncement_free(struct LDKNodeAnnouncement this_obj); /** - * The first to-be-broadcast-by-sender transaction's per commitment point + * The signature by the node key */ -void AcceptChannel_set_first_per_commitment_point(struct LDKAcceptChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); +struct LDKSignature NodeAnnouncement_get_signature(const struct LDKNodeAnnouncement *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 the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * The signature by the node key */ -struct LDKChannelTypeFeatures AcceptChannel_get_channel_type(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); +void NodeAnnouncement_set_signature(struct LDKNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKSignature val); /** - * The channel type that this channel will represent. If none is set, we derive the channel - * type from the intersection of our feature bits with our counterparty's feature bits from - * the Init message. - * - * This is required to match the equivalent field in [`OpenChannel::channel_type`]. - * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + * The actual content of the announcement */ -void AcceptChannel_set_channel_type(struct LDKAcceptChannel *NONNULL_PTR this_ptr, struct LDKChannelTypeFeatures val); +struct LDKUnsignedNodeAnnouncement NodeAnnouncement_get_contents(const struct LDKNodeAnnouncement *NONNULL_PTR this_ptr); /** - * Creates a copy of the AcceptChannel + * The actual content of the announcement */ -struct LDKAcceptChannel AcceptChannel_clone(const struct LDKAcceptChannel *NONNULL_PTR orig); +void NodeAnnouncement_set_contents(struct LDKNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKUnsignedNodeAnnouncement val); /** - * Frees any resources used by the FundingCreated, if is_owned is set and inner is non-NULL. + * Constructs a new NodeAnnouncement given each field */ -void FundingCreated_free(struct LDKFundingCreated this_obj); +MUST_USE_RES struct LDKNodeAnnouncement NodeAnnouncement_new(struct LDKSignature signature_arg, struct LDKUnsignedNodeAnnouncement contents_arg); /** - * A temporary channel ID, until the funding is established + * Creates a copy of the NodeAnnouncement */ -const uint8_t (*FundingCreated_get_temporary_channel_id(const struct LDKFundingCreated *NONNULL_PTR this_ptr))[32]; +struct LDKNodeAnnouncement NodeAnnouncement_clone(const struct LDKNodeAnnouncement *NONNULL_PTR orig); /** - * A temporary channel ID, until the funding is established + * Checks if two NodeAnnouncements contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void FundingCreated_set_temporary_channel_id(struct LDKFundingCreated *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +bool NodeAnnouncement_eq(const struct LDKNodeAnnouncement *NONNULL_PTR a, const struct LDKNodeAnnouncement *NONNULL_PTR b); /** - * The funding transaction ID + * Frees any resources used by the UnsignedChannelAnnouncement, if is_owned is set and inner is non-NULL. */ -const uint8_t (*FundingCreated_get_funding_txid(const struct LDKFundingCreated *NONNULL_PTR this_ptr))[32]; +void UnsignedChannelAnnouncement_free(struct LDKUnsignedChannelAnnouncement this_obj); /** - * The funding transaction ID + * The advertised channel features */ -void FundingCreated_set_funding_txid(struct LDKFundingCreated *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKChannelFeatures UnsignedChannelAnnouncement_get_features(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr); /** - * The specific output index funding this channel + * The advertised channel features */ -uint16_t FundingCreated_get_funding_output_index(const struct LDKFundingCreated *NONNULL_PTR this_ptr); +void UnsignedChannelAnnouncement_set_features(struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKChannelFeatures val); /** - * The specific output index funding this channel + * The genesis hash of the blockchain where the channel is to be opened */ -void FundingCreated_set_funding_output_index(struct LDKFundingCreated *NONNULL_PTR this_ptr, uint16_t val); +const uint8_t (*UnsignedChannelAnnouncement_get_chain_hash(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr))[32]; /** - * The signature of the channel initiator (funder) on the initial commitment transaction + * The genesis hash of the blockchain where the channel is to be opened */ -struct LDKSignature FundingCreated_get_signature(const struct LDKFundingCreated *NONNULL_PTR this_ptr); +void UnsignedChannelAnnouncement_set_chain_hash(struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * The signature of the channel initiator (funder) on the initial commitment transaction + * The short channel ID */ -void FundingCreated_set_signature(struct LDKFundingCreated *NONNULL_PTR this_ptr, struct LDKSignature val); +uint64_t UnsignedChannelAnnouncement_get_short_channel_id(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr); /** - * Constructs a new FundingCreated given each field + * The short channel ID */ -MUST_USE_RES struct LDKFundingCreated FundingCreated_new(struct LDKThirtyTwoBytes temporary_channel_id_arg, struct LDKThirtyTwoBytes funding_txid_arg, uint16_t funding_output_index_arg, struct LDKSignature signature_arg); +void UnsignedChannelAnnouncement_set_short_channel_id(struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr, uint64_t val); /** - * Creates a copy of the FundingCreated + * One of the two node_ids which are endpoints of this channel */ -struct LDKFundingCreated FundingCreated_clone(const struct LDKFundingCreated *NONNULL_PTR orig); +struct LDKPublicKey UnsignedChannelAnnouncement_get_node_id_1(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr); /** - * Frees any resources used by the FundingSigned, if is_owned is set and inner is non-NULL. + * One of the two node_ids which are endpoints of this channel */ -void FundingSigned_free(struct LDKFundingSigned this_obj); +void UnsignedChannelAnnouncement_set_node_id_1(struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * The channel ID + * The other of the two node_ids which are endpoints of this channel */ -const uint8_t (*FundingSigned_get_channel_id(const struct LDKFundingSigned *NONNULL_PTR this_ptr))[32]; +struct LDKPublicKey UnsignedChannelAnnouncement_get_node_id_2(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr); /** - * The channel ID + * The other of the two node_ids which are endpoints of this channel */ -void FundingSigned_set_channel_id(struct LDKFundingSigned *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void UnsignedChannelAnnouncement_set_node_id_2(struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * The signature of the channel acceptor (fundee) on the initial commitment transaction + * The funding key for the first node */ -struct LDKSignature FundingSigned_get_signature(const struct LDKFundingSigned *NONNULL_PTR this_ptr); +struct LDKPublicKey UnsignedChannelAnnouncement_get_bitcoin_key_1(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr); /** - * The signature of the channel acceptor (fundee) on the initial commitment transaction + * The funding key for the first node */ -void FundingSigned_set_signature(struct LDKFundingSigned *NONNULL_PTR this_ptr, struct LDKSignature val); +void UnsignedChannelAnnouncement_set_bitcoin_key_1(struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Constructs a new FundingSigned given each field + * The funding key for the second node */ -MUST_USE_RES struct LDKFundingSigned FundingSigned_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKSignature signature_arg); +struct LDKPublicKey UnsignedChannelAnnouncement_get_bitcoin_key_2(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr); /** - * Creates a copy of the FundingSigned + * The funding key for the second node */ -struct LDKFundingSigned FundingSigned_clone(const struct LDKFundingSigned *NONNULL_PTR orig); +void UnsignedChannelAnnouncement_set_bitcoin_key_2(struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Frees any resources used by the FundingLocked, if is_owned is set and inner is non-NULL. + * Creates a copy of the UnsignedChannelAnnouncement */ -void FundingLocked_free(struct LDKFundingLocked this_obj); +struct LDKUnsignedChannelAnnouncement UnsignedChannelAnnouncement_clone(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR orig); /** - * The channel ID + * Checks if two UnsignedChannelAnnouncements 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. */ -const uint8_t (*FundingLocked_get_channel_id(const struct LDKFundingLocked *NONNULL_PTR this_ptr))[32]; +bool UnsignedChannelAnnouncement_eq(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR a, const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR b); /** - * The channel ID + * Frees any resources used by the ChannelAnnouncement, if is_owned is set and inner is non-NULL. */ -void FundingLocked_set_channel_id(struct LDKFundingLocked *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void ChannelAnnouncement_free(struct LDKChannelAnnouncement this_obj); /** - * The per-commitment point of the second commitment transaction + * Authentication of the announcement by the first public node */ -struct LDKPublicKey FundingLocked_get_next_per_commitment_point(const struct LDKFundingLocked *NONNULL_PTR this_ptr); +struct LDKSignature ChannelAnnouncement_get_node_signature_1(const struct LDKChannelAnnouncement *NONNULL_PTR this_ptr); /** - * The per-commitment point of the second commitment transaction + * Authentication of the announcement by the first public node */ -void FundingLocked_set_next_per_commitment_point(struct LDKFundingLocked *NONNULL_PTR this_ptr, struct LDKPublicKey val); +void ChannelAnnouncement_set_node_signature_1(struct LDKChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKSignature val); /** - * Constructs a new FundingLocked given each field + * Authentication of the announcement by the second public node */ -MUST_USE_RES struct LDKFundingLocked FundingLocked_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKPublicKey next_per_commitment_point_arg); +struct LDKSignature ChannelAnnouncement_get_node_signature_2(const struct LDKChannelAnnouncement *NONNULL_PTR this_ptr); /** - * Creates a copy of the FundingLocked + * Authentication of the announcement by the second public node */ -struct LDKFundingLocked FundingLocked_clone(const struct LDKFundingLocked *NONNULL_PTR orig); +void ChannelAnnouncement_set_node_signature_2(struct LDKChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKSignature val); /** - * Frees any resources used by the Shutdown, if is_owned is set and inner is non-NULL. + * Proof of funding UTXO ownership by the first public node */ -void Shutdown_free(struct LDKShutdown this_obj); +struct LDKSignature ChannelAnnouncement_get_bitcoin_signature_1(const struct LDKChannelAnnouncement *NONNULL_PTR this_ptr); /** - * The channel ID + * Proof of funding UTXO ownership by the first public node */ -const uint8_t (*Shutdown_get_channel_id(const struct LDKShutdown *NONNULL_PTR this_ptr))[32]; +void ChannelAnnouncement_set_bitcoin_signature_1(struct LDKChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKSignature val); /** - * The channel ID + * Proof of funding UTXO ownership by the second public node */ -void Shutdown_set_channel_id(struct LDKShutdown *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKSignature ChannelAnnouncement_get_bitcoin_signature_2(const struct LDKChannelAnnouncement *NONNULL_PTR this_ptr); /** - * The destination of this peer's funds on closing. - * Must be in one of these forms: p2pkh, p2sh, p2wpkh, p2wsh. + * Proof of funding UTXO ownership by the second public node */ -struct LDKu8slice Shutdown_get_scriptpubkey(const struct LDKShutdown *NONNULL_PTR this_ptr); +void ChannelAnnouncement_set_bitcoin_signature_2(struct LDKChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKSignature val); /** - * The destination of this peer's funds on closing. - * Must be in one of these forms: p2pkh, p2sh, p2wpkh, p2wsh. + * The actual announcement */ -void Shutdown_set_scriptpubkey(struct LDKShutdown *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val); +struct LDKUnsignedChannelAnnouncement ChannelAnnouncement_get_contents(const struct LDKChannelAnnouncement *NONNULL_PTR this_ptr); /** - * Constructs a new Shutdown given each field + * The actual announcement */ -MUST_USE_RES struct LDKShutdown Shutdown_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKCVec_u8Z scriptpubkey_arg); +void ChannelAnnouncement_set_contents(struct LDKChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKUnsignedChannelAnnouncement val); /** - * Creates a copy of the Shutdown + * Constructs a new ChannelAnnouncement given each field */ -struct LDKShutdown Shutdown_clone(const struct LDKShutdown *NONNULL_PTR orig); +MUST_USE_RES struct LDKChannelAnnouncement ChannelAnnouncement_new(struct LDKSignature node_signature_1_arg, struct LDKSignature node_signature_2_arg, struct LDKSignature bitcoin_signature_1_arg, struct LDKSignature bitcoin_signature_2_arg, struct LDKUnsignedChannelAnnouncement contents_arg); /** - * Frees any resources used by the ClosingSignedFeeRange, if is_owned is set and inner is non-NULL. + * Creates a copy of the ChannelAnnouncement */ -void ClosingSignedFeeRange_free(struct LDKClosingSignedFeeRange this_obj); +struct LDKChannelAnnouncement ChannelAnnouncement_clone(const struct LDKChannelAnnouncement *NONNULL_PTR orig); /** - * The minimum absolute fee, in satoshis, which the sender is willing to place on the closing - * transaction. + * Checks if two ChannelAnnouncements contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -uint64_t ClosingSignedFeeRange_get_min_fee_satoshis(const struct LDKClosingSignedFeeRange *NONNULL_PTR this_ptr); +bool ChannelAnnouncement_eq(const struct LDKChannelAnnouncement *NONNULL_PTR a, const struct LDKChannelAnnouncement *NONNULL_PTR b); /** - * The minimum absolute fee, in satoshis, which the sender is willing to place on the closing - * transaction. + * Frees any resources used by the UnsignedChannelUpdate, if is_owned is set and inner is non-NULL. */ -void ClosingSignedFeeRange_set_min_fee_satoshis(struct LDKClosingSignedFeeRange *NONNULL_PTR this_ptr, uint64_t val); +void UnsignedChannelUpdate_free(struct LDKUnsignedChannelUpdate this_obj); /** - * The maximum absolute fee, in satoshis, which the sender is willing to place on the closing - * transaction. + * The genesis hash of the blockchain where the channel is to be opened */ -uint64_t ClosingSignedFeeRange_get_max_fee_satoshis(const struct LDKClosingSignedFeeRange *NONNULL_PTR this_ptr); +const uint8_t (*UnsignedChannelUpdate_get_chain_hash(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr))[32]; /** - * The maximum absolute fee, in satoshis, which the sender is willing to place on the closing - * transaction. + * The genesis hash of the blockchain where the channel is to be opened */ -void ClosingSignedFeeRange_set_max_fee_satoshis(struct LDKClosingSignedFeeRange *NONNULL_PTR this_ptr, uint64_t val); +void UnsignedChannelUpdate_set_chain_hash(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Constructs a new ClosingSignedFeeRange given each field + * The short channel ID */ -MUST_USE_RES struct LDKClosingSignedFeeRange ClosingSignedFeeRange_new(uint64_t min_fee_satoshis_arg, uint64_t max_fee_satoshis_arg); +uint64_t UnsignedChannelUpdate_get_short_channel_id(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); /** - * Creates a copy of the ClosingSignedFeeRange + * The short channel ID */ -struct LDKClosingSignedFeeRange ClosingSignedFeeRange_clone(const struct LDKClosingSignedFeeRange *NONNULL_PTR orig); +void UnsignedChannelUpdate_set_short_channel_id(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint64_t val); /** - * Frees any resources used by the ClosingSigned, if is_owned is set and inner is non-NULL. + * A strictly monotonic announcement counter, with gaps allowed, specific to this channel */ -void ClosingSigned_free(struct LDKClosingSigned this_obj); +uint32_t UnsignedChannelUpdate_get_timestamp(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); /** - * The channel ID + * A strictly monotonic announcement counter, with gaps allowed, specific to this channel */ -const uint8_t (*ClosingSigned_get_channel_id(const struct LDKClosingSigned *NONNULL_PTR this_ptr))[32]; +void UnsignedChannelUpdate_set_timestamp(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint32_t val); /** - * The channel ID + * Channel flags */ -void ClosingSigned_set_channel_id(struct LDKClosingSigned *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +uint8_t UnsignedChannelUpdate_get_flags(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); /** - * The proposed total fee for the closing transaction + * Channel flags */ -uint64_t ClosingSigned_get_fee_satoshis(const struct LDKClosingSigned *NONNULL_PTR this_ptr); +void UnsignedChannelUpdate_set_flags(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint8_t val); /** - * The proposed total fee for the closing transaction + * The number of blocks such that if: + * `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta` + * then we need to fail the HTLC backwards. When forwarding an HTLC, cltv_expiry_delta determines + * the outgoing HTLC's minimum cltv_expiry value -- so, if an incoming HTLC comes in with a + * cltv_expiry of 100000, and the node we're forwarding to has a cltv_expiry_delta value of 10, + * then we'll check that the outgoing HTLC's cltv_expiry value is at least 100010 before + * forwarding. Note that the HTLC sender is the one who originally sets this value when + * constructing the route. */ -void ClosingSigned_set_fee_satoshis(struct LDKClosingSigned *NONNULL_PTR this_ptr, uint64_t val); +uint16_t UnsignedChannelUpdate_get_cltv_expiry_delta(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); /** - * A signature on the closing transaction + * The number of blocks such that if: + * `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta` + * then we need to fail the HTLC backwards. When forwarding an HTLC, cltv_expiry_delta determines + * the outgoing HTLC's minimum cltv_expiry value -- so, if an incoming HTLC comes in with a + * cltv_expiry of 100000, and the node we're forwarding to has a cltv_expiry_delta value of 10, + * then we'll check that the outgoing HTLC's cltv_expiry value is at least 100010 before + * forwarding. Note that the HTLC sender is the one who originally sets this value when + * constructing the route. */ -struct LDKSignature ClosingSigned_get_signature(const struct LDKClosingSigned *NONNULL_PTR this_ptr); +void UnsignedChannelUpdate_set_cltv_expiry_delta(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint16_t val); /** - * A signature on the closing transaction + * The minimum HTLC size incoming to sender, in milli-satoshi */ -void ClosingSigned_set_signature(struct LDKClosingSigned *NONNULL_PTR this_ptr, struct LDKSignature val); +uint64_t UnsignedChannelUpdate_get_htlc_minimum_msat(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); /** - * The minimum and maximum fees which the sender is willing to accept, provided only by new - * nodes. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * The minimum HTLC size incoming to sender, in milli-satoshi */ -struct LDKClosingSignedFeeRange ClosingSigned_get_fee_range(const struct LDKClosingSigned *NONNULL_PTR this_ptr); +void UnsignedChannelUpdate_set_htlc_minimum_msat(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint64_t val); /** - * The minimum and maximum fees which the sender is willing to accept, provided only by new - * nodes. - * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + * The maximum HTLC value incoming to sender, in milli-satoshi. Used to be optional. */ -void ClosingSigned_set_fee_range(struct LDKClosingSigned *NONNULL_PTR this_ptr, struct LDKClosingSignedFeeRange val); +uint64_t UnsignedChannelUpdate_get_htlc_maximum_msat(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); /** - * Constructs a new ClosingSigned given each field + * The maximum HTLC value incoming to sender, in milli-satoshi. Used to be optional. */ -MUST_USE_RES struct LDKClosingSigned ClosingSigned_new(struct LDKThirtyTwoBytes channel_id_arg, uint64_t fee_satoshis_arg, struct LDKSignature signature_arg, struct LDKClosingSignedFeeRange fee_range_arg); +void UnsignedChannelUpdate_set_htlc_maximum_msat(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint64_t val); /** - * Creates a copy of the ClosingSigned + * The base HTLC fee charged by sender, in milli-satoshi */ -struct LDKClosingSigned ClosingSigned_clone(const struct LDKClosingSigned *NONNULL_PTR orig); +uint32_t UnsignedChannelUpdate_get_fee_base_msat(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); /** - * Frees any resources used by the UpdateAddHTLC, if is_owned is set and inner is non-NULL. + * The base HTLC fee charged by sender, in milli-satoshi */ -void UpdateAddHTLC_free(struct LDKUpdateAddHTLC this_obj); +void UnsignedChannelUpdate_set_fee_base_msat(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint32_t val); /** - * The channel ID + * The amount to fee multiplier, in micro-satoshi */ -const uint8_t (*UpdateAddHTLC_get_channel_id(const struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr))[32]; +uint32_t UnsignedChannelUpdate_get_fee_proportional_millionths(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); /** - * The channel ID + * The amount to fee multiplier, in micro-satoshi */ -void UpdateAddHTLC_set_channel_id(struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void UnsignedChannelUpdate_set_fee_proportional_millionths(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint32_t val); /** - * The HTLC ID + * Excess data which was signed as a part of the message which we do not (yet) understand how + * to decode. This is stored to ensure forward-compatibility as new fields are added to the + * lightning gossip + * + * Returns a copy of the field. */ -uint64_t UpdateAddHTLC_get_htlc_id(const struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z UnsignedChannelUpdate_get_excess_data(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); /** - * The HTLC ID + * Excess data which was signed as a part of the message which we do not (yet) understand how + * to decode. This is stored to ensure forward-compatibility as new fields are added to the + * lightning gossip */ -void UpdateAddHTLC_set_htlc_id(struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr, uint64_t val); +void UnsignedChannelUpdate_set_excess_data(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val); /** - * The HTLC value in milli-satoshi + * Constructs a new UnsignedChannelUpdate given each field */ -uint64_t UpdateAddHTLC_get_amount_msat(const struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKUnsignedChannelUpdate UnsignedChannelUpdate_new(struct LDKThirtyTwoBytes chain_hash_arg, uint64_t short_channel_id_arg, uint32_t timestamp_arg, uint8_t flags_arg, uint16_t cltv_expiry_delta_arg, uint64_t htlc_minimum_msat_arg, uint64_t htlc_maximum_msat_arg, uint32_t fee_base_msat_arg, uint32_t fee_proportional_millionths_arg, struct LDKCVec_u8Z excess_data_arg); /** - * The HTLC value in milli-satoshi + * Creates a copy of the UnsignedChannelUpdate */ -void UpdateAddHTLC_set_amount_msat(struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr, uint64_t val); +struct LDKUnsignedChannelUpdate UnsignedChannelUpdate_clone(const struct LDKUnsignedChannelUpdate *NONNULL_PTR orig); /** - * The payment hash, the pre-image of which controls HTLC redemption + * Checks if two UnsignedChannelUpdates 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. */ -const uint8_t (*UpdateAddHTLC_get_payment_hash(const struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr))[32]; +bool UnsignedChannelUpdate_eq(const struct LDKUnsignedChannelUpdate *NONNULL_PTR a, const struct LDKUnsignedChannelUpdate *NONNULL_PTR b); /** - * The payment hash, the pre-image of which controls HTLC redemption + * Frees any resources used by the ChannelUpdate, if is_owned is set and inner is non-NULL. */ -void UpdateAddHTLC_set_payment_hash(struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void ChannelUpdate_free(struct LDKChannelUpdate this_obj); /** - * The expiry height of the HTLC + * A signature of the channel update */ -uint32_t UpdateAddHTLC_get_cltv_expiry(const struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr); +struct LDKSignature ChannelUpdate_get_signature(const struct LDKChannelUpdate *NONNULL_PTR this_ptr); /** - * The expiry height of the HTLC + * A signature of the channel update */ -void UpdateAddHTLC_set_cltv_expiry(struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr, uint32_t val); +void ChannelUpdate_set_signature(struct LDKChannelUpdate *NONNULL_PTR this_ptr, struct LDKSignature val); /** - * Creates a copy of the UpdateAddHTLC + * The actual channel update */ -struct LDKUpdateAddHTLC UpdateAddHTLC_clone(const struct LDKUpdateAddHTLC *NONNULL_PTR orig); +struct LDKUnsignedChannelUpdate ChannelUpdate_get_contents(const struct LDKChannelUpdate *NONNULL_PTR this_ptr); /** - * Frees any resources used by the UpdateFulfillHTLC, if is_owned is set and inner is non-NULL. + * The actual channel update */ -void UpdateFulfillHTLC_free(struct LDKUpdateFulfillHTLC this_obj); +void ChannelUpdate_set_contents(struct LDKChannelUpdate *NONNULL_PTR this_ptr, struct LDKUnsignedChannelUpdate val); /** - * The channel ID + * Constructs a new ChannelUpdate given each field */ -const uint8_t (*UpdateFulfillHTLC_get_channel_id(const struct LDKUpdateFulfillHTLC *NONNULL_PTR this_ptr))[32]; +MUST_USE_RES struct LDKChannelUpdate ChannelUpdate_new(struct LDKSignature signature_arg, struct LDKUnsignedChannelUpdate contents_arg); /** - * The channel ID + * Creates a copy of the ChannelUpdate */ -void UpdateFulfillHTLC_set_channel_id(struct LDKUpdateFulfillHTLC *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKChannelUpdate ChannelUpdate_clone(const struct LDKChannelUpdate *NONNULL_PTR orig); /** - * The HTLC ID + * Checks if two ChannelUpdates contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -uint64_t UpdateFulfillHTLC_get_htlc_id(const struct LDKUpdateFulfillHTLC *NONNULL_PTR this_ptr); +bool ChannelUpdate_eq(const struct LDKChannelUpdate *NONNULL_PTR a, const struct LDKChannelUpdate *NONNULL_PTR b); /** - * The HTLC ID + * Frees any resources used by the QueryChannelRange, if is_owned is set and inner is non-NULL. */ -void UpdateFulfillHTLC_set_htlc_id(struct LDKUpdateFulfillHTLC *NONNULL_PTR this_ptr, uint64_t val); +void QueryChannelRange_free(struct LDKQueryChannelRange this_obj); /** - * The pre-image of the payment hash, allowing HTLC redemption + * The genesis hash of the blockchain being queried */ -const uint8_t (*UpdateFulfillHTLC_get_payment_preimage(const struct LDKUpdateFulfillHTLC *NONNULL_PTR this_ptr))[32]; +const uint8_t (*QueryChannelRange_get_chain_hash(const struct LDKQueryChannelRange *NONNULL_PTR this_ptr))[32]; /** - * The pre-image of the payment hash, allowing HTLC redemption + * The genesis hash of the blockchain being queried */ -void UpdateFulfillHTLC_set_payment_preimage(struct LDKUpdateFulfillHTLC *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void QueryChannelRange_set_chain_hash(struct LDKQueryChannelRange *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Constructs a new UpdateFulfillHTLC given each field + * The height of the first block for the channel UTXOs being queried */ -MUST_USE_RES struct LDKUpdateFulfillHTLC UpdateFulfillHTLC_new(struct LDKThirtyTwoBytes channel_id_arg, uint64_t htlc_id_arg, struct LDKThirtyTwoBytes payment_preimage_arg); +uint32_t QueryChannelRange_get_first_blocknum(const struct LDKQueryChannelRange *NONNULL_PTR this_ptr); /** - * Creates a copy of the UpdateFulfillHTLC + * The height of the first block for the channel UTXOs being queried */ -struct LDKUpdateFulfillHTLC UpdateFulfillHTLC_clone(const struct LDKUpdateFulfillHTLC *NONNULL_PTR orig); +void QueryChannelRange_set_first_blocknum(struct LDKQueryChannelRange *NONNULL_PTR this_ptr, uint32_t val); /** - * Frees any resources used by the UpdateFailHTLC, if is_owned is set and inner is non-NULL. + * The number of blocks to include in the query results */ -void UpdateFailHTLC_free(struct LDKUpdateFailHTLC this_obj); +uint32_t QueryChannelRange_get_number_of_blocks(const struct LDKQueryChannelRange *NONNULL_PTR this_ptr); /** - * The channel ID + * The number of blocks to include in the query results */ -const uint8_t (*UpdateFailHTLC_get_channel_id(const struct LDKUpdateFailHTLC *NONNULL_PTR this_ptr))[32]; +void QueryChannelRange_set_number_of_blocks(struct LDKQueryChannelRange *NONNULL_PTR this_ptr, uint32_t val); /** - * The channel ID + * Constructs a new QueryChannelRange given each field */ -void UpdateFailHTLC_set_channel_id(struct LDKUpdateFailHTLC *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +MUST_USE_RES struct LDKQueryChannelRange QueryChannelRange_new(struct LDKThirtyTwoBytes chain_hash_arg, uint32_t first_blocknum_arg, uint32_t number_of_blocks_arg); /** - * The HTLC ID + * Creates a copy of the QueryChannelRange */ -uint64_t UpdateFailHTLC_get_htlc_id(const struct LDKUpdateFailHTLC *NONNULL_PTR this_ptr); +struct LDKQueryChannelRange QueryChannelRange_clone(const struct LDKQueryChannelRange *NONNULL_PTR orig); /** - * The HTLC ID + * Checks if two QueryChannelRanges contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void UpdateFailHTLC_set_htlc_id(struct LDKUpdateFailHTLC *NONNULL_PTR this_ptr, uint64_t val); +bool QueryChannelRange_eq(const struct LDKQueryChannelRange *NONNULL_PTR a, const struct LDKQueryChannelRange *NONNULL_PTR b); /** - * Creates a copy of the UpdateFailHTLC + * Frees any resources used by the ReplyChannelRange, if is_owned is set and inner is non-NULL. */ -struct LDKUpdateFailHTLC UpdateFailHTLC_clone(const struct LDKUpdateFailHTLC *NONNULL_PTR orig); +void ReplyChannelRange_free(struct LDKReplyChannelRange this_obj); /** - * Frees any resources used by the UpdateFailMalformedHTLC, if is_owned is set and inner is non-NULL. + * The genesis hash of the blockchain being queried */ -void UpdateFailMalformedHTLC_free(struct LDKUpdateFailMalformedHTLC this_obj); +const uint8_t (*ReplyChannelRange_get_chain_hash(const struct LDKReplyChannelRange *NONNULL_PTR this_ptr))[32]; /** - * The channel ID + * The genesis hash of the blockchain being queried */ -const uint8_t (*UpdateFailMalformedHTLC_get_channel_id(const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR this_ptr))[32]; +void ReplyChannelRange_set_chain_hash(struct LDKReplyChannelRange *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * The channel ID + * The height of the first block in the range of the reply */ -void UpdateFailMalformedHTLC_set_channel_id(struct LDKUpdateFailMalformedHTLC *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +uint32_t ReplyChannelRange_get_first_blocknum(const struct LDKReplyChannelRange *NONNULL_PTR this_ptr); /** - * The HTLC ID + * The height of the first block in the range of the reply */ -uint64_t UpdateFailMalformedHTLC_get_htlc_id(const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR this_ptr); +void ReplyChannelRange_set_first_blocknum(struct LDKReplyChannelRange *NONNULL_PTR this_ptr, uint32_t val); /** - * The HTLC ID + * The number of blocks included in the range of the reply */ -void UpdateFailMalformedHTLC_set_htlc_id(struct LDKUpdateFailMalformedHTLC *NONNULL_PTR this_ptr, uint64_t val); +uint32_t ReplyChannelRange_get_number_of_blocks(const struct LDKReplyChannelRange *NONNULL_PTR this_ptr); /** - * The failure code + * The number of blocks included in the range of the reply */ -uint16_t UpdateFailMalformedHTLC_get_failure_code(const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR this_ptr); +void ReplyChannelRange_set_number_of_blocks(struct LDKReplyChannelRange *NONNULL_PTR this_ptr, uint32_t val); /** - * The failure code + * True when this is the final reply for a query */ -void UpdateFailMalformedHTLC_set_failure_code(struct LDKUpdateFailMalformedHTLC *NONNULL_PTR this_ptr, uint16_t val); +bool ReplyChannelRange_get_sync_complete(const struct LDKReplyChannelRange *NONNULL_PTR this_ptr); /** - * Creates a copy of the UpdateFailMalformedHTLC + * True when this is the final reply for a query */ -struct LDKUpdateFailMalformedHTLC UpdateFailMalformedHTLC_clone(const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR orig); +void ReplyChannelRange_set_sync_complete(struct LDKReplyChannelRange *NONNULL_PTR this_ptr, bool val); /** - * Frees any resources used by the CommitmentSigned, if is_owned is set and inner is non-NULL. + * The short_channel_ids in the channel range + * + * Returns a copy of the field. */ -void CommitmentSigned_free(struct LDKCommitmentSigned this_obj); +struct LDKCVec_u64Z ReplyChannelRange_get_short_channel_ids(const struct LDKReplyChannelRange *NONNULL_PTR this_ptr); /** - * The channel ID + * The short_channel_ids in the channel range */ -const uint8_t (*CommitmentSigned_get_channel_id(const struct LDKCommitmentSigned *NONNULL_PTR this_ptr))[32]; +void ReplyChannelRange_set_short_channel_ids(struct LDKReplyChannelRange *NONNULL_PTR this_ptr, struct LDKCVec_u64Z val); /** - * The channel ID + * Constructs a new ReplyChannelRange given each field */ -void CommitmentSigned_set_channel_id(struct LDKCommitmentSigned *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +MUST_USE_RES struct LDKReplyChannelRange ReplyChannelRange_new(struct LDKThirtyTwoBytes chain_hash_arg, uint32_t first_blocknum_arg, uint32_t number_of_blocks_arg, bool sync_complete_arg, struct LDKCVec_u64Z short_channel_ids_arg); /** - * A signature on the commitment transaction + * Creates a copy of the ReplyChannelRange */ -struct LDKSignature CommitmentSigned_get_signature(const struct LDKCommitmentSigned *NONNULL_PTR this_ptr); +struct LDKReplyChannelRange ReplyChannelRange_clone(const struct LDKReplyChannelRange *NONNULL_PTR orig); /** - * A signature on the commitment transaction + * Checks if two ReplyChannelRanges contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void CommitmentSigned_set_signature(struct LDKCommitmentSigned *NONNULL_PTR this_ptr, struct LDKSignature val); +bool ReplyChannelRange_eq(const struct LDKReplyChannelRange *NONNULL_PTR a, const struct LDKReplyChannelRange *NONNULL_PTR b); /** - * Signatures on the HTLC transactions + * Frees any resources used by the QueryShortChannelIds, if is_owned is set and inner is non-NULL. */ -void CommitmentSigned_set_htlc_signatures(struct LDKCommitmentSigned *NONNULL_PTR this_ptr, struct LDKCVec_SignatureZ val); +void QueryShortChannelIds_free(struct LDKQueryShortChannelIds this_obj); /** - * Constructs a new CommitmentSigned given each field + * The genesis hash of the blockchain being queried */ -MUST_USE_RES struct LDKCommitmentSigned CommitmentSigned_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKSignature signature_arg, struct LDKCVec_SignatureZ htlc_signatures_arg); +const uint8_t (*QueryShortChannelIds_get_chain_hash(const struct LDKQueryShortChannelIds *NONNULL_PTR this_ptr))[32]; /** - * Creates a copy of the CommitmentSigned + * The genesis hash of the blockchain being queried */ -struct LDKCommitmentSigned CommitmentSigned_clone(const struct LDKCommitmentSigned *NONNULL_PTR orig); +void QueryShortChannelIds_set_chain_hash(struct LDKQueryShortChannelIds *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Frees any resources used by the RevokeAndACK, if is_owned is set and inner is non-NULL. + * The short_channel_ids that are being queried + * + * Returns a copy of the field. */ -void RevokeAndACK_free(struct LDKRevokeAndACK this_obj); +struct LDKCVec_u64Z QueryShortChannelIds_get_short_channel_ids(const struct LDKQueryShortChannelIds *NONNULL_PTR this_ptr); /** - * The channel ID + * The short_channel_ids that are being queried */ -const uint8_t (*RevokeAndACK_get_channel_id(const struct LDKRevokeAndACK *NONNULL_PTR this_ptr))[32]; +void QueryShortChannelIds_set_short_channel_ids(struct LDKQueryShortChannelIds *NONNULL_PTR this_ptr, struct LDKCVec_u64Z val); /** - * The channel ID + * Constructs a new QueryShortChannelIds given each field */ -void RevokeAndACK_set_channel_id(struct LDKRevokeAndACK *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +MUST_USE_RES struct LDKQueryShortChannelIds QueryShortChannelIds_new(struct LDKThirtyTwoBytes chain_hash_arg, struct LDKCVec_u64Z short_channel_ids_arg); /** - * The secret corresponding to the per-commitment point + * Creates a copy of the QueryShortChannelIds */ -const uint8_t (*RevokeAndACK_get_per_commitment_secret(const struct LDKRevokeAndACK *NONNULL_PTR this_ptr))[32]; +struct LDKQueryShortChannelIds QueryShortChannelIds_clone(const struct LDKQueryShortChannelIds *NONNULL_PTR orig); /** - * The secret corresponding to the per-commitment point + * Checks if two QueryShortChannelIdss contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void RevokeAndACK_set_per_commitment_secret(struct LDKRevokeAndACK *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +bool QueryShortChannelIds_eq(const struct LDKQueryShortChannelIds *NONNULL_PTR a, const struct LDKQueryShortChannelIds *NONNULL_PTR b); /** - * The next sender-broadcast commitment transaction's per-commitment point + * Frees any resources used by the ReplyShortChannelIdsEnd, if is_owned is set and inner is non-NULL. */ -struct LDKPublicKey RevokeAndACK_get_next_per_commitment_point(const struct LDKRevokeAndACK *NONNULL_PTR this_ptr); +void ReplyShortChannelIdsEnd_free(struct LDKReplyShortChannelIdsEnd this_obj); /** - * The next sender-broadcast commitment transaction's per-commitment point + * The genesis hash of the blockchain that was queried */ -void RevokeAndACK_set_next_per_commitment_point(struct LDKRevokeAndACK *NONNULL_PTR this_ptr, struct LDKPublicKey val); +const uint8_t (*ReplyShortChannelIdsEnd_get_chain_hash(const struct LDKReplyShortChannelIdsEnd *NONNULL_PTR this_ptr))[32]; /** - * Constructs a new RevokeAndACK given each field + * The genesis hash of the blockchain that was queried */ -MUST_USE_RES struct LDKRevokeAndACK RevokeAndACK_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKThirtyTwoBytes per_commitment_secret_arg, struct LDKPublicKey next_per_commitment_point_arg); +void ReplyShortChannelIdsEnd_set_chain_hash(struct LDKReplyShortChannelIdsEnd *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Creates a copy of the RevokeAndACK + * Indicates if the query recipient maintains up-to-date channel + * information for the chain_hash */ -struct LDKRevokeAndACK RevokeAndACK_clone(const struct LDKRevokeAndACK *NONNULL_PTR orig); +bool ReplyShortChannelIdsEnd_get_full_information(const struct LDKReplyShortChannelIdsEnd *NONNULL_PTR this_ptr); /** - * Frees any resources used by the UpdateFee, if is_owned is set and inner is non-NULL. + * Indicates if the query recipient maintains up-to-date channel + * information for the chain_hash */ -void UpdateFee_free(struct LDKUpdateFee this_obj); +void ReplyShortChannelIdsEnd_set_full_information(struct LDKReplyShortChannelIdsEnd *NONNULL_PTR this_ptr, bool val); /** - * The channel ID + * Constructs a new ReplyShortChannelIdsEnd given each field */ -const uint8_t (*UpdateFee_get_channel_id(const struct LDKUpdateFee *NONNULL_PTR this_ptr))[32]; +MUST_USE_RES struct LDKReplyShortChannelIdsEnd ReplyShortChannelIdsEnd_new(struct LDKThirtyTwoBytes chain_hash_arg, bool full_information_arg); /** - * The channel ID + * Creates a copy of the ReplyShortChannelIdsEnd */ -void UpdateFee_set_channel_id(struct LDKUpdateFee *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKReplyShortChannelIdsEnd ReplyShortChannelIdsEnd_clone(const struct LDKReplyShortChannelIdsEnd *NONNULL_PTR orig); /** - * Fee rate per 1000-weight of the transaction + * Checks if two ReplyShortChannelIdsEnds 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. */ -uint32_t UpdateFee_get_feerate_per_kw(const struct LDKUpdateFee *NONNULL_PTR this_ptr); +bool ReplyShortChannelIdsEnd_eq(const struct LDKReplyShortChannelIdsEnd *NONNULL_PTR a, const struct LDKReplyShortChannelIdsEnd *NONNULL_PTR b); /** - * Fee rate per 1000-weight of the transaction + * Frees any resources used by the GossipTimestampFilter, if is_owned is set and inner is non-NULL. */ -void UpdateFee_set_feerate_per_kw(struct LDKUpdateFee *NONNULL_PTR this_ptr, uint32_t val); +void GossipTimestampFilter_free(struct LDKGossipTimestampFilter this_obj); /** - * Constructs a new UpdateFee given each field + * The genesis hash of the blockchain for channel and node information */ -MUST_USE_RES struct LDKUpdateFee UpdateFee_new(struct LDKThirtyTwoBytes channel_id_arg, uint32_t feerate_per_kw_arg); +const uint8_t (*GossipTimestampFilter_get_chain_hash(const struct LDKGossipTimestampFilter *NONNULL_PTR this_ptr))[32]; /** - * Creates a copy of the UpdateFee + * The genesis hash of the blockchain for channel and node information */ -struct LDKUpdateFee UpdateFee_clone(const struct LDKUpdateFee *NONNULL_PTR orig); +void GossipTimestampFilter_set_chain_hash(struct LDKGossipTimestampFilter *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Frees any resources used by the DataLossProtect, if is_owned is set and inner is non-NULL. + * The starting unix timestamp */ -void DataLossProtect_free(struct LDKDataLossProtect this_obj); +uint32_t GossipTimestampFilter_get_first_timestamp(const struct LDKGossipTimestampFilter *NONNULL_PTR this_ptr); /** - * Proof that the sender knows the per-commitment secret of a specific commitment transaction - * belonging to the recipient + * The starting unix timestamp */ -const uint8_t (*DataLossProtect_get_your_last_per_commitment_secret(const struct LDKDataLossProtect *NONNULL_PTR this_ptr))[32]; +void GossipTimestampFilter_set_first_timestamp(struct LDKGossipTimestampFilter *NONNULL_PTR this_ptr, uint32_t val); /** - * Proof that the sender knows the per-commitment secret of a specific commitment transaction - * belonging to the recipient + * The range of information in seconds */ -void DataLossProtect_set_your_last_per_commitment_secret(struct LDKDataLossProtect *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +uint32_t GossipTimestampFilter_get_timestamp_range(const struct LDKGossipTimestampFilter *NONNULL_PTR this_ptr); /** - * The sender's per-commitment point for their current commitment transaction + * The range of information in seconds */ -struct LDKPublicKey DataLossProtect_get_my_current_per_commitment_point(const struct LDKDataLossProtect *NONNULL_PTR this_ptr); +void GossipTimestampFilter_set_timestamp_range(struct LDKGossipTimestampFilter *NONNULL_PTR this_ptr, uint32_t val); /** - * The sender's per-commitment point for their current commitment transaction + * Constructs a new GossipTimestampFilter given each field */ -void DataLossProtect_set_my_current_per_commitment_point(struct LDKDataLossProtect *NONNULL_PTR this_ptr, struct LDKPublicKey val); +MUST_USE_RES struct LDKGossipTimestampFilter GossipTimestampFilter_new(struct LDKThirtyTwoBytes chain_hash_arg, uint32_t first_timestamp_arg, uint32_t timestamp_range_arg); /** - * Constructs a new DataLossProtect given each field + * Creates a copy of the GossipTimestampFilter */ -MUST_USE_RES struct LDKDataLossProtect DataLossProtect_new(struct LDKThirtyTwoBytes your_last_per_commitment_secret_arg, struct LDKPublicKey my_current_per_commitment_point_arg); +struct LDKGossipTimestampFilter GossipTimestampFilter_clone(const struct LDKGossipTimestampFilter *NONNULL_PTR orig); /** - * Creates a copy of the DataLossProtect + * Checks if two GossipTimestampFilters contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -struct LDKDataLossProtect DataLossProtect_clone(const struct LDKDataLossProtect *NONNULL_PTR orig); +bool GossipTimestampFilter_eq(const struct LDKGossipTimestampFilter *NONNULL_PTR a, const struct LDKGossipTimestampFilter *NONNULL_PTR b); /** - * Frees any resources used by the ChannelReestablish, if is_owned is set and inner is non-NULL. + * Frees any resources used by the ErrorAction */ -void ChannelReestablish_free(struct LDKChannelReestablish this_obj); +void ErrorAction_free(struct LDKErrorAction this_ptr); /** - * The channel ID + * Creates a copy of the ErrorAction */ -const uint8_t (*ChannelReestablish_get_channel_id(const struct LDKChannelReestablish *NONNULL_PTR this_ptr))[32]; +struct LDKErrorAction ErrorAction_clone(const struct LDKErrorAction *NONNULL_PTR orig); /** - * The channel ID + * Utility method to constructs a new DisconnectPeer-variant ErrorAction */ -void ChannelReestablish_set_channel_id(struct LDKChannelReestablish *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKErrorAction ErrorAction_disconnect_peer(struct LDKErrorMessage msg); /** - * The next commitment number for the sender + * Utility method to constructs a new IgnoreError-variant ErrorAction */ -uint64_t ChannelReestablish_get_next_local_commitment_number(const struct LDKChannelReestablish *NONNULL_PTR this_ptr); +struct LDKErrorAction ErrorAction_ignore_error(void); /** - * The next commitment number for the sender + * Utility method to constructs a new IgnoreAndLog-variant ErrorAction */ -void ChannelReestablish_set_next_local_commitment_number(struct LDKChannelReestablish *NONNULL_PTR this_ptr, uint64_t val); +struct LDKErrorAction ErrorAction_ignore_and_log(enum LDKLevel a); /** - * The next commitment number for the recipient + * Utility method to constructs a new IgnoreDuplicateGossip-variant ErrorAction */ -uint64_t ChannelReestablish_get_next_remote_commitment_number(const struct LDKChannelReestablish *NONNULL_PTR this_ptr); +struct LDKErrorAction ErrorAction_ignore_duplicate_gossip(void); /** - * The next commitment number for the recipient + * Utility method to constructs a new SendErrorMessage-variant ErrorAction */ -void ChannelReestablish_set_next_remote_commitment_number(struct LDKChannelReestablish *NONNULL_PTR this_ptr, uint64_t val); +struct LDKErrorAction ErrorAction_send_error_message(struct LDKErrorMessage msg); /** - * Creates a copy of the ChannelReestablish + * Utility method to constructs a new SendWarningMessage-variant ErrorAction */ -struct LDKChannelReestablish ChannelReestablish_clone(const struct LDKChannelReestablish *NONNULL_PTR orig); +struct LDKErrorAction ErrorAction_send_warning_message(struct LDKWarningMessage msg, enum LDKLevel log_level); /** - * Frees any resources used by the AnnouncementSignatures, if is_owned is set and inner is non-NULL. + * Frees any resources used by the LightningError, if is_owned is set and inner is non-NULL. */ -void AnnouncementSignatures_free(struct LDKAnnouncementSignatures this_obj); +void LightningError_free(struct LDKLightningError this_obj); /** - * The channel ID + * A human-readable message describing the error */ -const uint8_t (*AnnouncementSignatures_get_channel_id(const struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr))[32]; +struct LDKStr LightningError_get_err(const struct LDKLightningError *NONNULL_PTR this_ptr); /** - * The channel ID + * A human-readable message describing the error */ -void AnnouncementSignatures_set_channel_id(struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void LightningError_set_err(struct LDKLightningError *NONNULL_PTR this_ptr, struct LDKStr val); /** - * The short channel ID + * The action which should be taken against the offending peer. */ -uint64_t AnnouncementSignatures_get_short_channel_id(const struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr); +struct LDKErrorAction LightningError_get_action(const struct LDKLightningError *NONNULL_PTR this_ptr); /** - * The short channel ID + * The action which should be taken against the offending peer. */ -void AnnouncementSignatures_set_short_channel_id(struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr, uint64_t val); +void LightningError_set_action(struct LDKLightningError *NONNULL_PTR this_ptr, struct LDKErrorAction val); /** - * A signature by the node key + * Constructs a new LightningError given each field */ -struct LDKSignature AnnouncementSignatures_get_node_signature(const struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKLightningError LightningError_new(struct LDKStr err_arg, struct LDKErrorAction action_arg); /** - * A signature by the node key + * Creates a copy of the LightningError */ -void AnnouncementSignatures_set_node_signature(struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr, struct LDKSignature val); +struct LDKLightningError LightningError_clone(const struct LDKLightningError *NONNULL_PTR orig); /** - * A signature by the funding key + * Frees any resources used by the CommitmentUpdate, if is_owned is set and inner is non-NULL. */ -struct LDKSignature AnnouncementSignatures_get_bitcoin_signature(const struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr); +void CommitmentUpdate_free(struct LDKCommitmentUpdate this_obj); /** - * A signature by the funding key + * update_add_htlc messages which should be sent */ -void AnnouncementSignatures_set_bitcoin_signature(struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr, struct LDKSignature val); +struct LDKCVec_UpdateAddHTLCZ CommitmentUpdate_get_update_add_htlcs(const struct LDKCommitmentUpdate *NONNULL_PTR this_ptr); /** - * Constructs a new AnnouncementSignatures given each field + * update_add_htlc messages which should be sent */ -MUST_USE_RES struct LDKAnnouncementSignatures AnnouncementSignatures_new(struct LDKThirtyTwoBytes channel_id_arg, uint64_t short_channel_id_arg, struct LDKSignature node_signature_arg, struct LDKSignature bitcoin_signature_arg); +void CommitmentUpdate_set_update_add_htlcs(struct LDKCommitmentUpdate *NONNULL_PTR this_ptr, struct LDKCVec_UpdateAddHTLCZ val); /** - * Creates a copy of the AnnouncementSignatures + * update_fulfill_htlc messages which should be sent */ -struct LDKAnnouncementSignatures AnnouncementSignatures_clone(const struct LDKAnnouncementSignatures *NONNULL_PTR orig); +struct LDKCVec_UpdateFulfillHTLCZ CommitmentUpdate_get_update_fulfill_htlcs(const struct LDKCommitmentUpdate *NONNULL_PTR this_ptr); /** - * Frees any resources used by the NetAddress + * update_fulfill_htlc messages which should be sent */ -void NetAddress_free(struct LDKNetAddress this_ptr); +void CommitmentUpdate_set_update_fulfill_htlcs(struct LDKCommitmentUpdate *NONNULL_PTR this_ptr, struct LDKCVec_UpdateFulfillHTLCZ val); /** - * Creates a copy of the NetAddress + * update_fail_htlc messages which should be sent */ -struct LDKNetAddress NetAddress_clone(const struct LDKNetAddress *NONNULL_PTR orig); +struct LDKCVec_UpdateFailHTLCZ CommitmentUpdate_get_update_fail_htlcs(const struct LDKCommitmentUpdate *NONNULL_PTR this_ptr); /** - * Utility method to constructs a new IPv4-variant NetAddress + * update_fail_htlc messages which should be sent */ -struct LDKNetAddress NetAddress_ipv4(struct LDKFourBytes addr, uint16_t port); +void CommitmentUpdate_set_update_fail_htlcs(struct LDKCommitmentUpdate *NONNULL_PTR this_ptr, struct LDKCVec_UpdateFailHTLCZ val); /** - * Utility method to constructs a new IPv6-variant NetAddress + * update_fail_malformed_htlc messages which should be sent */ -struct LDKNetAddress NetAddress_ipv6(struct LDKSixteenBytes addr, uint16_t port); +struct LDKCVec_UpdateFailMalformedHTLCZ CommitmentUpdate_get_update_fail_malformed_htlcs(const struct LDKCommitmentUpdate *NONNULL_PTR this_ptr); /** - * Utility method to constructs a new OnionV2-variant NetAddress + * update_fail_malformed_htlc messages which should be sent */ -struct LDKNetAddress NetAddress_onion_v2(struct LDKTwelveBytes a); +void CommitmentUpdate_set_update_fail_malformed_htlcs(struct LDKCommitmentUpdate *NONNULL_PTR this_ptr, struct LDKCVec_UpdateFailMalformedHTLCZ val); /** - * Utility method to constructs a new OnionV3-variant NetAddress + * An update_fee message which should be sent + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKNetAddress NetAddress_onion_v3(struct LDKThirtyTwoBytes ed25519_pubkey, uint16_t checksum, uint8_t version, uint16_t port); +struct LDKUpdateFee CommitmentUpdate_get_update_fee(const struct LDKCommitmentUpdate *NONNULL_PTR this_ptr); /** - * Serialize the NetAddress object into a byte array which can be read by NetAddress_read + * An update_fee message which should be sent + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKCVec_u8Z NetAddress_write(const struct LDKNetAddress *NONNULL_PTR obj); +void CommitmentUpdate_set_update_fee(struct LDKCommitmentUpdate *NONNULL_PTR this_ptr, struct LDKUpdateFee val); /** - * Read a NetAddress from a byte array, created by NetAddress_write + * Finally, the commitment_signed message which should be sent */ -struct LDKCResult_NetAddressDecodeErrorZ NetAddress_read(struct LDKu8slice ser); +struct LDKCommitmentSigned CommitmentUpdate_get_commitment_signed(const struct LDKCommitmentUpdate *NONNULL_PTR this_ptr); /** - * Frees any resources used by the UnsignedNodeAnnouncement, if is_owned is set and inner is non-NULL. + * Finally, the commitment_signed message which should be sent */ -void UnsignedNodeAnnouncement_free(struct LDKUnsignedNodeAnnouncement this_obj); +void CommitmentUpdate_set_commitment_signed(struct LDKCommitmentUpdate *NONNULL_PTR this_ptr, struct LDKCommitmentSigned val); /** - * The advertised features + * Constructs a new CommitmentUpdate given each field */ -struct LDKNodeFeatures UnsignedNodeAnnouncement_get_features(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCommitmentUpdate CommitmentUpdate_new(struct LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg, struct LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg, struct LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg, struct LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg, struct LDKUpdateFee update_fee_arg, struct LDKCommitmentSigned commitment_signed_arg); /** - * The advertised features + * Creates a copy of the CommitmentUpdate */ -void UnsignedNodeAnnouncement_set_features(struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKNodeFeatures val); +struct LDKCommitmentUpdate CommitmentUpdate_clone(const struct LDKCommitmentUpdate *NONNULL_PTR orig); /** - * A strictly monotonic announcement counter, with gaps allowed + * Checks if two CommitmentUpdates 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. */ -uint32_t UnsignedNodeAnnouncement_get_timestamp(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr); +bool CommitmentUpdate_eq(const struct LDKCommitmentUpdate *NONNULL_PTR a, const struct LDKCommitmentUpdate *NONNULL_PTR b); /** - * A strictly monotonic announcement counter, with gaps allowed + * Calls the free function if one is set */ -void UnsignedNodeAnnouncement_set_timestamp(struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr, uint32_t val); +void ChannelMessageHandler_free(struct LDKChannelMessageHandler this_ptr); /** - * The node_id this announcement originated from (don't rebroadcast the node_announcement back - * to this node). + * Calls the free function if one is set */ -struct LDKPublicKey UnsignedNodeAnnouncement_get_node_id(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr); +void RoutingMessageHandler_free(struct LDKRoutingMessageHandler this_ptr); /** - * The node_id this announcement originated from (don't rebroadcast the node_announcement back - * to this node). + * Calls the free function if one is set */ -void UnsignedNodeAnnouncement_set_node_id(struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKPublicKey val); +void OnionMessageHandler_free(struct LDKOnionMessageHandler this_ptr); /** - * An RGB color for UI purposes + * Serialize the AcceptChannel object into a byte array which can be read by AcceptChannel_read */ -const uint8_t (*UnsignedNodeAnnouncement_get_rgb(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr))[3]; +struct LDKCVec_u8Z AcceptChannel_write(const struct LDKAcceptChannel *NONNULL_PTR obj); /** - * An RGB color for UI purposes + * Read a AcceptChannel from a byte array, created by AcceptChannel_write */ -void UnsignedNodeAnnouncement_set_rgb(struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKThreeBytes val); +struct LDKCResult_AcceptChannelDecodeErrorZ AcceptChannel_read(struct LDKu8slice ser); /** - * An alias, for UI purposes. This should be sanitized before use. There is no guarantee - * of uniqueness. + * Serialize the AnnouncementSignatures object into a byte array which can be read by AnnouncementSignatures_read */ -const uint8_t (*UnsignedNodeAnnouncement_get_alias(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr))[32]; +struct LDKCVec_u8Z AnnouncementSignatures_write(const struct LDKAnnouncementSignatures *NONNULL_PTR obj); /** - * An alias, for UI purposes. This should be sanitized before use. There is no guarantee - * of uniqueness. + * Read a AnnouncementSignatures from a byte array, created by AnnouncementSignatures_write */ -void UnsignedNodeAnnouncement_set_alias(struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKCResult_AnnouncementSignaturesDecodeErrorZ AnnouncementSignatures_read(struct LDKu8slice ser); /** - * List of addresses on which this node is reachable + * Serialize the ChannelReestablish object into a byte array which can be read by ChannelReestablish_read */ -void UnsignedNodeAnnouncement_set_addresses(struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKCVec_NetAddressZ val); +struct LDKCVec_u8Z ChannelReestablish_write(const struct LDKChannelReestablish *NONNULL_PTR obj); /** - * Creates a copy of the UnsignedNodeAnnouncement + * Read a ChannelReestablish from a byte array, created by ChannelReestablish_write */ -struct LDKUnsignedNodeAnnouncement UnsignedNodeAnnouncement_clone(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR orig); +struct LDKCResult_ChannelReestablishDecodeErrorZ ChannelReestablish_read(struct LDKu8slice ser); /** - * Frees any resources used by the NodeAnnouncement, if is_owned is set and inner is non-NULL. + * Serialize the ClosingSigned object into a byte array which can be read by ClosingSigned_read */ -void NodeAnnouncement_free(struct LDKNodeAnnouncement this_obj); +struct LDKCVec_u8Z ClosingSigned_write(const struct LDKClosingSigned *NONNULL_PTR obj); /** - * The signature by the node key + * Read a ClosingSigned from a byte array, created by ClosingSigned_write */ -struct LDKSignature NodeAnnouncement_get_signature(const struct LDKNodeAnnouncement *NONNULL_PTR this_ptr); +struct LDKCResult_ClosingSignedDecodeErrorZ ClosingSigned_read(struct LDKu8slice ser); /** - * The signature by the node key + * Serialize the ClosingSignedFeeRange object into a byte array which can be read by ClosingSignedFeeRange_read */ -void NodeAnnouncement_set_signature(struct LDKNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKSignature val); +struct LDKCVec_u8Z ClosingSignedFeeRange_write(const struct LDKClosingSignedFeeRange *NONNULL_PTR obj); /** - * The actual content of the announcement + * Read a ClosingSignedFeeRange from a byte array, created by ClosingSignedFeeRange_write */ -struct LDKUnsignedNodeAnnouncement NodeAnnouncement_get_contents(const struct LDKNodeAnnouncement *NONNULL_PTR this_ptr); +struct LDKCResult_ClosingSignedFeeRangeDecodeErrorZ ClosingSignedFeeRange_read(struct LDKu8slice ser); /** - * The actual content of the announcement + * Serialize the CommitmentSigned object into a byte array which can be read by CommitmentSigned_read */ -void NodeAnnouncement_set_contents(struct LDKNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKUnsignedNodeAnnouncement val); +struct LDKCVec_u8Z CommitmentSigned_write(const struct LDKCommitmentSigned *NONNULL_PTR obj); /** - * Constructs a new NodeAnnouncement given each field + * Read a CommitmentSigned from a byte array, created by CommitmentSigned_write */ -MUST_USE_RES struct LDKNodeAnnouncement NodeAnnouncement_new(struct LDKSignature signature_arg, struct LDKUnsignedNodeAnnouncement contents_arg); +struct LDKCResult_CommitmentSignedDecodeErrorZ CommitmentSigned_read(struct LDKu8slice ser); /** - * Creates a copy of the NodeAnnouncement + * Serialize the FundingCreated object into a byte array which can be read by FundingCreated_read */ -struct LDKNodeAnnouncement NodeAnnouncement_clone(const struct LDKNodeAnnouncement *NONNULL_PTR orig); +struct LDKCVec_u8Z FundingCreated_write(const struct LDKFundingCreated *NONNULL_PTR obj); /** - * Frees any resources used by the UnsignedChannelAnnouncement, if is_owned is set and inner is non-NULL. + * Read a FundingCreated from a byte array, created by FundingCreated_write */ -void UnsignedChannelAnnouncement_free(struct LDKUnsignedChannelAnnouncement this_obj); +struct LDKCResult_FundingCreatedDecodeErrorZ FundingCreated_read(struct LDKu8slice ser); /** - * The advertised channel features + * Serialize the FundingSigned object into a byte array which can be read by FundingSigned_read */ -struct LDKChannelFeatures UnsignedChannelAnnouncement_get_features(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z FundingSigned_write(const struct LDKFundingSigned *NONNULL_PTR obj); /** - * The advertised channel features + * Read a FundingSigned from a byte array, created by FundingSigned_write */ -void UnsignedChannelAnnouncement_set_features(struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKChannelFeatures val); +struct LDKCResult_FundingSignedDecodeErrorZ FundingSigned_read(struct LDKu8slice ser); /** - * The genesis hash of the blockchain where the channel is to be opened + * Serialize the ChannelReady object into a byte array which can be read by ChannelReady_read */ -const uint8_t (*UnsignedChannelAnnouncement_get_chain_hash(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr))[32]; +struct LDKCVec_u8Z ChannelReady_write(const struct LDKChannelReady *NONNULL_PTR obj); /** - * The genesis hash of the blockchain where the channel is to be opened + * Read a ChannelReady from a byte array, created by ChannelReady_write */ -void UnsignedChannelAnnouncement_set_chain_hash(struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKCResult_ChannelReadyDecodeErrorZ ChannelReady_read(struct LDKu8slice ser); /** - * The short channel ID + * Serialize the Init object into a byte array which can be read by Init_read */ -uint64_t UnsignedChannelAnnouncement_get_short_channel_id(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z Init_write(const struct LDKInit *NONNULL_PTR obj); /** - * The short channel ID + * Read a Init from a byte array, created by Init_write */ -void UnsignedChannelAnnouncement_set_short_channel_id(struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr, uint64_t val); +struct LDKCResult_InitDecodeErrorZ Init_read(struct LDKu8slice ser); /** - * One of the two node_ids which are endpoints of this channel + * Serialize the OpenChannel object into a byte array which can be read by OpenChannel_read */ -struct LDKPublicKey UnsignedChannelAnnouncement_get_node_id_1(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z OpenChannel_write(const struct LDKOpenChannel *NONNULL_PTR obj); /** - * One of the two node_ids which are endpoints of this channel + * Read a OpenChannel from a byte array, created by OpenChannel_write */ -void UnsignedChannelAnnouncement_set_node_id_1(struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKPublicKey val); +struct LDKCResult_OpenChannelDecodeErrorZ OpenChannel_read(struct LDKu8slice ser); /** - * The other of the two node_ids which are endpoints of this channel + * Serialize the RevokeAndACK object into a byte array which can be read by RevokeAndACK_read */ -struct LDKPublicKey UnsignedChannelAnnouncement_get_node_id_2(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z RevokeAndACK_write(const struct LDKRevokeAndACK *NONNULL_PTR obj); /** - * The other of the two node_ids which are endpoints of this channel + * Read a RevokeAndACK from a byte array, created by RevokeAndACK_write */ -void UnsignedChannelAnnouncement_set_node_id_2(struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKPublicKey val); +struct LDKCResult_RevokeAndACKDecodeErrorZ RevokeAndACK_read(struct LDKu8slice ser); /** - * The funding key for the first node + * Serialize the Shutdown object into a byte array which can be read by Shutdown_read */ -struct LDKPublicKey UnsignedChannelAnnouncement_get_bitcoin_key_1(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z Shutdown_write(const struct LDKShutdown *NONNULL_PTR obj); /** - * The funding key for the first node + * Read a Shutdown from a byte array, created by Shutdown_write */ -void UnsignedChannelAnnouncement_set_bitcoin_key_1(struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKPublicKey val); +struct LDKCResult_ShutdownDecodeErrorZ Shutdown_read(struct LDKu8slice ser); /** - * The funding key for the second node + * Serialize the UpdateFailHTLC object into a byte array which can be read by UpdateFailHTLC_read */ -struct LDKPublicKey UnsignedChannelAnnouncement_get_bitcoin_key_2(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z UpdateFailHTLC_write(const struct LDKUpdateFailHTLC *NONNULL_PTR obj); /** - * The funding key for the second node + * Read a UpdateFailHTLC from a byte array, created by UpdateFailHTLC_write */ -void UnsignedChannelAnnouncement_set_bitcoin_key_2(struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKPublicKey val); +struct LDKCResult_UpdateFailHTLCDecodeErrorZ UpdateFailHTLC_read(struct LDKu8slice ser); /** - * Creates a copy of the UnsignedChannelAnnouncement + * Serialize the UpdateFailMalformedHTLC object into a byte array which can be read by UpdateFailMalformedHTLC_read */ -struct LDKUnsignedChannelAnnouncement UnsignedChannelAnnouncement_clone(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR orig); +struct LDKCVec_u8Z UpdateFailMalformedHTLC_write(const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR obj); /** - * Frees any resources used by the ChannelAnnouncement, if is_owned is set and inner is non-NULL. + * Read a UpdateFailMalformedHTLC from a byte array, created by UpdateFailMalformedHTLC_write */ -void ChannelAnnouncement_free(struct LDKChannelAnnouncement this_obj); +struct LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ UpdateFailMalformedHTLC_read(struct LDKu8slice ser); /** - * Authentication of the announcement by the first public node + * Serialize the UpdateFee object into a byte array which can be read by UpdateFee_read */ -struct LDKSignature ChannelAnnouncement_get_node_signature_1(const struct LDKChannelAnnouncement *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z UpdateFee_write(const struct LDKUpdateFee *NONNULL_PTR obj); /** - * Authentication of the announcement by the first public node + * Read a UpdateFee from a byte array, created by UpdateFee_write */ -void ChannelAnnouncement_set_node_signature_1(struct LDKChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKSignature val); +struct LDKCResult_UpdateFeeDecodeErrorZ UpdateFee_read(struct LDKu8slice ser); /** - * Authentication of the announcement by the second public node + * Serialize the UpdateFulfillHTLC object into a byte array which can be read by UpdateFulfillHTLC_read */ -struct LDKSignature ChannelAnnouncement_get_node_signature_2(const struct LDKChannelAnnouncement *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z UpdateFulfillHTLC_write(const struct LDKUpdateFulfillHTLC *NONNULL_PTR obj); /** - * Authentication of the announcement by the second public node + * Read a UpdateFulfillHTLC from a byte array, created by UpdateFulfillHTLC_write */ -void ChannelAnnouncement_set_node_signature_2(struct LDKChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKSignature val); +struct LDKCResult_UpdateFulfillHTLCDecodeErrorZ UpdateFulfillHTLC_read(struct LDKu8slice ser); /** - * Proof of funding UTXO ownership by the first public node + * Serialize the UpdateAddHTLC object into a byte array which can be read by UpdateAddHTLC_read */ -struct LDKSignature ChannelAnnouncement_get_bitcoin_signature_1(const struct LDKChannelAnnouncement *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z UpdateAddHTLC_write(const struct LDKUpdateAddHTLC *NONNULL_PTR obj); /** - * Proof of funding UTXO ownership by the first public node + * Read a UpdateAddHTLC from a byte array, created by UpdateAddHTLC_write */ -void ChannelAnnouncement_set_bitcoin_signature_1(struct LDKChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKSignature val); +struct LDKCResult_UpdateAddHTLCDecodeErrorZ UpdateAddHTLC_read(struct LDKu8slice ser); /** - * Proof of funding UTXO ownership by the second public node + * Read a OnionMessage from a byte array, created by OnionMessage_write */ -struct LDKSignature ChannelAnnouncement_get_bitcoin_signature_2(const struct LDKChannelAnnouncement *NONNULL_PTR this_ptr); +struct LDKCResult_OnionMessageDecodeErrorZ OnionMessage_read(struct LDKu8slice ser); /** - * Proof of funding UTXO ownership by the second public node + * Serialize the OnionMessage object into a byte array which can be read by OnionMessage_read */ -void ChannelAnnouncement_set_bitcoin_signature_2(struct LDKChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKSignature val); +struct LDKCVec_u8Z OnionMessage_write(const struct LDKOnionMessage *NONNULL_PTR obj); /** - * The actual announcement + * Serialize the Ping object into a byte array which can be read by Ping_read */ -struct LDKUnsignedChannelAnnouncement ChannelAnnouncement_get_contents(const struct LDKChannelAnnouncement *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z Ping_write(const struct LDKPing *NONNULL_PTR obj); /** - * The actual announcement + * Read a Ping from a byte array, created by Ping_write */ -void ChannelAnnouncement_set_contents(struct LDKChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKUnsignedChannelAnnouncement val); +struct LDKCResult_PingDecodeErrorZ Ping_read(struct LDKu8slice ser); /** - * Constructs a new ChannelAnnouncement given each field + * Serialize the Pong object into a byte array which can be read by Pong_read */ -MUST_USE_RES struct LDKChannelAnnouncement ChannelAnnouncement_new(struct LDKSignature node_signature_1_arg, struct LDKSignature node_signature_2_arg, struct LDKSignature bitcoin_signature_1_arg, struct LDKSignature bitcoin_signature_2_arg, struct LDKUnsignedChannelAnnouncement contents_arg); +struct LDKCVec_u8Z Pong_write(const struct LDKPong *NONNULL_PTR obj); /** - * Creates a copy of the ChannelAnnouncement + * Read a Pong from a byte array, created by Pong_write */ -struct LDKChannelAnnouncement ChannelAnnouncement_clone(const struct LDKChannelAnnouncement *NONNULL_PTR orig); +struct LDKCResult_PongDecodeErrorZ Pong_read(struct LDKu8slice ser); /** - * Frees any resources used by the UnsignedChannelUpdate, if is_owned is set and inner is non-NULL. + * Serialize the UnsignedChannelAnnouncement object into a byte array which can be read by UnsignedChannelAnnouncement_read */ -void UnsignedChannelUpdate_free(struct LDKUnsignedChannelUpdate this_obj); +struct LDKCVec_u8Z UnsignedChannelAnnouncement_write(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR obj); /** - * The genesis hash of the blockchain where the channel is to be opened + * Read a UnsignedChannelAnnouncement from a byte array, created by UnsignedChannelAnnouncement_write */ -const uint8_t (*UnsignedChannelUpdate_get_chain_hash(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr))[32]; +struct LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ UnsignedChannelAnnouncement_read(struct LDKu8slice ser); /** - * The genesis hash of the blockchain where the channel is to be opened + * Serialize the ChannelAnnouncement object into a byte array which can be read by ChannelAnnouncement_read */ -void UnsignedChannelUpdate_set_chain_hash(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKCVec_u8Z ChannelAnnouncement_write(const struct LDKChannelAnnouncement *NONNULL_PTR obj); /** - * The short channel ID + * Read a ChannelAnnouncement from a byte array, created by ChannelAnnouncement_write */ -uint64_t UnsignedChannelUpdate_get_short_channel_id(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); +struct LDKCResult_ChannelAnnouncementDecodeErrorZ ChannelAnnouncement_read(struct LDKu8slice ser); /** - * The short channel ID + * Serialize the UnsignedChannelUpdate object into a byte array which can be read by UnsignedChannelUpdate_read */ -void UnsignedChannelUpdate_set_short_channel_id(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint64_t val); +struct LDKCVec_u8Z UnsignedChannelUpdate_write(const struct LDKUnsignedChannelUpdate *NONNULL_PTR obj); /** - * A strictly monotonic announcement counter, with gaps allowed, specific to this channel + * Read a UnsignedChannelUpdate from a byte array, created by UnsignedChannelUpdate_write */ -uint32_t UnsignedChannelUpdate_get_timestamp(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); +struct LDKCResult_UnsignedChannelUpdateDecodeErrorZ UnsignedChannelUpdate_read(struct LDKu8slice ser); /** - * A strictly monotonic announcement counter, with gaps allowed, specific to this channel + * Serialize the ChannelUpdate object into a byte array which can be read by ChannelUpdate_read */ -void UnsignedChannelUpdate_set_timestamp(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint32_t val); +struct LDKCVec_u8Z ChannelUpdate_write(const struct LDKChannelUpdate *NONNULL_PTR obj); /** - * Channel flags + * Read a ChannelUpdate from a byte array, created by ChannelUpdate_write */ -uint8_t UnsignedChannelUpdate_get_flags(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); +struct LDKCResult_ChannelUpdateDecodeErrorZ ChannelUpdate_read(struct LDKu8slice ser); /** - * Channel flags + * Serialize the ErrorMessage object into a byte array which can be read by ErrorMessage_read */ -void UnsignedChannelUpdate_set_flags(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint8_t val); +struct LDKCVec_u8Z ErrorMessage_write(const struct LDKErrorMessage *NONNULL_PTR obj); /** - * The number of blocks such that if: - * `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta` - * then we need to fail the HTLC backwards. When forwarding an HTLC, cltv_expiry_delta determines - * the outgoing HTLC's minimum cltv_expiry value -- so, if an incoming HTLC comes in with a - * cltv_expiry of 100000, and the node we're forwarding to has a cltv_expiry_delta value of 10, - * then we'll check that the outgoing HTLC's cltv_expiry value is at least 100010 before - * forwarding. Note that the HTLC sender is the one who originally sets this value when - * constructing the route. + * Read a ErrorMessage from a byte array, created by ErrorMessage_write */ -uint16_t UnsignedChannelUpdate_get_cltv_expiry_delta(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); +struct LDKCResult_ErrorMessageDecodeErrorZ ErrorMessage_read(struct LDKu8slice ser); /** - * The number of blocks such that if: - * `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta` - * then we need to fail the HTLC backwards. When forwarding an HTLC, cltv_expiry_delta determines - * the outgoing HTLC's minimum cltv_expiry value -- so, if an incoming HTLC comes in with a - * cltv_expiry of 100000, and the node we're forwarding to has a cltv_expiry_delta value of 10, - * then we'll check that the outgoing HTLC's cltv_expiry value is at least 100010 before - * forwarding. Note that the HTLC sender is the one who originally sets this value when - * constructing the route. + * Serialize the WarningMessage object into a byte array which can be read by WarningMessage_read */ -void UnsignedChannelUpdate_set_cltv_expiry_delta(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint16_t val); +struct LDKCVec_u8Z WarningMessage_write(const struct LDKWarningMessage *NONNULL_PTR obj); /** - * The minimum HTLC size incoming to sender, in milli-satoshi + * Read a WarningMessage from a byte array, created by WarningMessage_write */ -uint64_t UnsignedChannelUpdate_get_htlc_minimum_msat(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); +struct LDKCResult_WarningMessageDecodeErrorZ WarningMessage_read(struct LDKu8slice ser); /** - * The minimum HTLC size incoming to sender, in milli-satoshi + * Serialize the UnsignedNodeAnnouncement object into a byte array which can be read by UnsignedNodeAnnouncement_read */ -void UnsignedChannelUpdate_set_htlc_minimum_msat(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint64_t val); +struct LDKCVec_u8Z UnsignedNodeAnnouncement_write(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR obj); /** - * The base HTLC fee charged by sender, in milli-satoshi + * Read a UnsignedNodeAnnouncement from a byte array, created by UnsignedNodeAnnouncement_write */ -uint32_t UnsignedChannelUpdate_get_fee_base_msat(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); +struct LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ UnsignedNodeAnnouncement_read(struct LDKu8slice ser); /** - * The base HTLC fee charged by sender, in milli-satoshi + * Serialize the NodeAnnouncement object into a byte array which can be read by NodeAnnouncement_read */ -void UnsignedChannelUpdate_set_fee_base_msat(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint32_t val); +struct LDKCVec_u8Z NodeAnnouncement_write(const struct LDKNodeAnnouncement *NONNULL_PTR obj); /** - * The amount to fee multiplier, in micro-satoshi + * Read a NodeAnnouncement from a byte array, created by NodeAnnouncement_write */ -uint32_t UnsignedChannelUpdate_get_fee_proportional_millionths(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); +struct LDKCResult_NodeAnnouncementDecodeErrorZ NodeAnnouncement_read(struct LDKu8slice ser); /** - * The amount to fee multiplier, in micro-satoshi + * Read a QueryShortChannelIds from a byte array, created by QueryShortChannelIds_write */ -void UnsignedChannelUpdate_set_fee_proportional_millionths(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint32_t val); +struct LDKCResult_QueryShortChannelIdsDecodeErrorZ QueryShortChannelIds_read(struct LDKu8slice ser); /** - * Creates a copy of the UnsignedChannelUpdate + * Serialize the QueryShortChannelIds object into a byte array which can be read by QueryShortChannelIds_read */ -struct LDKUnsignedChannelUpdate UnsignedChannelUpdate_clone(const struct LDKUnsignedChannelUpdate *NONNULL_PTR orig); +struct LDKCVec_u8Z QueryShortChannelIds_write(const struct LDKQueryShortChannelIds *NONNULL_PTR obj); /** - * Frees any resources used by the ChannelUpdate, if is_owned is set and inner is non-NULL. + * Serialize the ReplyShortChannelIdsEnd object into a byte array which can be read by ReplyShortChannelIdsEnd_read */ -void ChannelUpdate_free(struct LDKChannelUpdate this_obj); +struct LDKCVec_u8Z ReplyShortChannelIdsEnd_write(const struct LDKReplyShortChannelIdsEnd *NONNULL_PTR obj); /** - * A signature of the channel update + * Read a ReplyShortChannelIdsEnd from a byte array, created by ReplyShortChannelIdsEnd_write */ -struct LDKSignature ChannelUpdate_get_signature(const struct LDKChannelUpdate *NONNULL_PTR this_ptr); +struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ ReplyShortChannelIdsEnd_read(struct LDKu8slice ser); /** - * A signature of the channel update + *\n\t * Calculates the overflow safe ending block height for the query.\n\t * Overflow returns `0xffffffff`, otherwise returns `first_blocknum + number_of_blocks`\n\t */ -void ChannelUpdate_set_signature(struct LDKChannelUpdate *NONNULL_PTR this_ptr, struct LDKSignature val); +MUST_USE_RES uint32_t QueryChannelRange_end_blocknum(const struct LDKQueryChannelRange *NONNULL_PTR this_arg); /** - * The actual channel update + * Serialize the QueryChannelRange object into a byte array which can be read by QueryChannelRange_read */ -struct LDKUnsignedChannelUpdate ChannelUpdate_get_contents(const struct LDKChannelUpdate *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z QueryChannelRange_write(const struct LDKQueryChannelRange *NONNULL_PTR obj); /** - * The actual channel update + * Read a QueryChannelRange from a byte array, created by QueryChannelRange_write */ -void ChannelUpdate_set_contents(struct LDKChannelUpdate *NONNULL_PTR this_ptr, struct LDKUnsignedChannelUpdate val); +struct LDKCResult_QueryChannelRangeDecodeErrorZ QueryChannelRange_read(struct LDKu8slice ser); /** - * Constructs a new ChannelUpdate given each field + * Read a ReplyChannelRange from a byte array, created by ReplyChannelRange_write */ -MUST_USE_RES struct LDKChannelUpdate ChannelUpdate_new(struct LDKSignature signature_arg, struct LDKUnsignedChannelUpdate contents_arg); +struct LDKCResult_ReplyChannelRangeDecodeErrorZ ReplyChannelRange_read(struct LDKu8slice ser); /** - * Creates a copy of the ChannelUpdate + * Serialize the ReplyChannelRange object into a byte array which can be read by ReplyChannelRange_read */ -struct LDKChannelUpdate ChannelUpdate_clone(const struct LDKChannelUpdate *NONNULL_PTR orig); +struct LDKCVec_u8Z ReplyChannelRange_write(const struct LDKReplyChannelRange *NONNULL_PTR obj); /** - * Frees any resources used by the QueryChannelRange, if is_owned is set and inner is non-NULL. + * Serialize the GossipTimestampFilter object into a byte array which can be read by GossipTimestampFilter_read */ -void QueryChannelRange_free(struct LDKQueryChannelRange this_obj); +struct LDKCVec_u8Z GossipTimestampFilter_write(const struct LDKGossipTimestampFilter *NONNULL_PTR obj); /** - * The genesis hash of the blockchain being queried + * Read a GossipTimestampFilter from a byte array, created by GossipTimestampFilter_write */ -const uint8_t (*QueryChannelRange_get_chain_hash(const struct LDKQueryChannelRange *NONNULL_PTR this_ptr))[32]; +struct LDKCResult_GossipTimestampFilterDecodeErrorZ GossipTimestampFilter_read(struct LDKu8slice ser); /** - * The genesis hash of the blockchain being queried + * Calls the free function if one is set */ -void QueryChannelRange_set_chain_hash(struct LDKQueryChannelRange *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void CustomMessageHandler_free(struct LDKCustomMessageHandler this_ptr); /** - * The height of the first block for the channel UTXOs being queried + * Frees any resources used by the IgnoringMessageHandler, if is_owned is set and inner is non-NULL. */ -uint32_t QueryChannelRange_get_first_blocknum(const struct LDKQueryChannelRange *NONNULL_PTR this_ptr); +void IgnoringMessageHandler_free(struct LDKIgnoringMessageHandler this_obj); /** - * The height of the first block for the channel UTXOs being queried + * Constructs a new IgnoringMessageHandler given each field */ -void QueryChannelRange_set_first_blocknum(struct LDKQueryChannelRange *NONNULL_PTR this_ptr, uint32_t val); +MUST_USE_RES struct LDKIgnoringMessageHandler IgnoringMessageHandler_new(void); /** - * The number of blocks to include in the query results + * Constructs a new MessageSendEventsProvider which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned MessageSendEventsProvider must be freed before this_arg is */ -uint32_t QueryChannelRange_get_number_of_blocks(const struct LDKQueryChannelRange *NONNULL_PTR this_ptr); +struct LDKMessageSendEventsProvider IgnoringMessageHandler_as_MessageSendEventsProvider(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); /** - * The number of blocks to include in the query results + * Constructs a new RoutingMessageHandler which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned RoutingMessageHandler must be freed before this_arg is */ -void QueryChannelRange_set_number_of_blocks(struct LDKQueryChannelRange *NONNULL_PTR this_ptr, uint32_t val); +struct LDKRoutingMessageHandler IgnoringMessageHandler_as_RoutingMessageHandler(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); /** - * Constructs a new QueryChannelRange given each field + * Constructs a new OnionMessageProvider which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned OnionMessageProvider must be freed before this_arg is */ -MUST_USE_RES struct LDKQueryChannelRange QueryChannelRange_new(struct LDKThirtyTwoBytes chain_hash_arg, uint32_t first_blocknum_arg, uint32_t number_of_blocks_arg); +struct LDKOnionMessageProvider IgnoringMessageHandler_as_OnionMessageProvider(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); /** - * Creates a copy of the QueryChannelRange + * Constructs a new OnionMessageHandler which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned OnionMessageHandler must be freed before this_arg is */ -struct LDKQueryChannelRange QueryChannelRange_clone(const struct LDKQueryChannelRange *NONNULL_PTR orig); +struct LDKOnionMessageHandler IgnoringMessageHandler_as_OnionMessageHandler(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); /** - * Frees any resources used by the ReplyChannelRange, if is_owned is set and inner is non-NULL. + * Constructs a new CustomOnionMessageHandler which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned CustomOnionMessageHandler must be freed before this_arg is */ -void ReplyChannelRange_free(struct LDKReplyChannelRange this_obj); +struct LDKCustomOnionMessageHandler IgnoringMessageHandler_as_CustomOnionMessageHandler(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); /** - * The genesis hash of the blockchain being queried + * Constructs a new CustomMessageReader which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned CustomMessageReader must be freed before this_arg is */ -const uint8_t (*ReplyChannelRange_get_chain_hash(const struct LDKReplyChannelRange *NONNULL_PTR this_ptr))[32]; +struct LDKCustomMessageReader IgnoringMessageHandler_as_CustomMessageReader(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); /** - * The genesis hash of the blockchain being queried + * Constructs a new CustomMessageHandler which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned CustomMessageHandler must be freed before this_arg is */ -void ReplyChannelRange_set_chain_hash(struct LDKReplyChannelRange *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKCustomMessageHandler IgnoringMessageHandler_as_CustomMessageHandler(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); /** - * The height of the first block in the range of the reply + * Frees any resources used by the ErroringMessageHandler, if is_owned is set and inner is non-NULL. */ -uint32_t ReplyChannelRange_get_first_blocknum(const struct LDKReplyChannelRange *NONNULL_PTR this_ptr); +void ErroringMessageHandler_free(struct LDKErroringMessageHandler this_obj); /** - * The height of the first block in the range of the reply + * Constructs a new ErroringMessageHandler */ -void ReplyChannelRange_set_first_blocknum(struct LDKReplyChannelRange *NONNULL_PTR this_ptr, uint32_t val); +MUST_USE_RES struct LDKErroringMessageHandler ErroringMessageHandler_new(void); /** - * The number of blocks included in the range of the reply + * Constructs a new MessageSendEventsProvider which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned MessageSendEventsProvider must be freed before this_arg is */ -uint32_t ReplyChannelRange_get_number_of_blocks(const struct LDKReplyChannelRange *NONNULL_PTR this_ptr); +struct LDKMessageSendEventsProvider ErroringMessageHandler_as_MessageSendEventsProvider(const struct LDKErroringMessageHandler *NONNULL_PTR this_arg); /** - * The number of blocks included in the range of the reply + * 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 */ -void ReplyChannelRange_set_number_of_blocks(struct LDKReplyChannelRange *NONNULL_PTR this_ptr, uint32_t val); +struct LDKChannelMessageHandler ErroringMessageHandler_as_ChannelMessageHandler(const struct LDKErroringMessageHandler *NONNULL_PTR this_arg); /** - * True when this is the final reply for a query + * Frees any resources used by the MessageHandler, if is_owned is set and inner is non-NULL. */ -bool ReplyChannelRange_get_sync_complete(const struct LDKReplyChannelRange *NONNULL_PTR this_ptr); +void MessageHandler_free(struct LDKMessageHandler this_obj); /** - * True when this is the final reply for a query + * A message handler which handles messages specific to channels. Usually this is just a + * [`ChannelManager`] object or an [`ErroringMessageHandler`]. + * + * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager */ -void ReplyChannelRange_set_sync_complete(struct LDKReplyChannelRange *NONNULL_PTR this_ptr, bool val); +const struct LDKChannelMessageHandler *MessageHandler_get_chan_handler(const struct LDKMessageHandler *NONNULL_PTR this_ptr); /** - * The short_channel_ids in the channel range + * A message handler which handles messages specific to channels. Usually this is just a + * [`ChannelManager`] object or an [`ErroringMessageHandler`]. + * + * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager */ -void ReplyChannelRange_set_short_channel_ids(struct LDKReplyChannelRange *NONNULL_PTR this_ptr, struct LDKCVec_u64Z val); +void MessageHandler_set_chan_handler(struct LDKMessageHandler *NONNULL_PTR this_ptr, struct LDKChannelMessageHandler val); /** - * Constructs a new ReplyChannelRange given each field + * A message handler which handles messages updating our knowledge of the network channel + * graph. Usually this is just a [`P2PGossipSync`] object or an [`IgnoringMessageHandler`]. + * + * [`P2PGossipSync`]: crate::routing::gossip::P2PGossipSync */ -MUST_USE_RES struct LDKReplyChannelRange ReplyChannelRange_new(struct LDKThirtyTwoBytes chain_hash_arg, uint32_t first_blocknum_arg, uint32_t number_of_blocks_arg, bool sync_complete_arg, struct LDKCVec_u64Z short_channel_ids_arg); +const struct LDKRoutingMessageHandler *MessageHandler_get_route_handler(const struct LDKMessageHandler *NONNULL_PTR this_ptr); /** - * Creates a copy of the ReplyChannelRange + * A message handler which handles messages updating our knowledge of the network channel + * graph. Usually this is just a [`P2PGossipSync`] object or an [`IgnoringMessageHandler`]. + * + * [`P2PGossipSync`]: crate::routing::gossip::P2PGossipSync */ -struct LDKReplyChannelRange ReplyChannelRange_clone(const struct LDKReplyChannelRange *NONNULL_PTR orig); +void MessageHandler_set_route_handler(struct LDKMessageHandler *NONNULL_PTR this_ptr, struct LDKRoutingMessageHandler val); /** - * Frees any resources used by the QueryShortChannelIds, if is_owned is set and inner is non-NULL. + * A message handler which handles onion messages. For now, this can only be an + * [`IgnoringMessageHandler`]. */ -void QueryShortChannelIds_free(struct LDKQueryShortChannelIds this_obj); +const struct LDKOnionMessageHandler *MessageHandler_get_onion_message_handler(const struct LDKMessageHandler *NONNULL_PTR this_ptr); /** - * The genesis hash of the blockchain being queried + * A message handler which handles onion messages. For now, this can only be an + * [`IgnoringMessageHandler`]. */ -const uint8_t (*QueryShortChannelIds_get_chain_hash(const struct LDKQueryShortChannelIds *NONNULL_PTR this_ptr))[32]; +void MessageHandler_set_onion_message_handler(struct LDKMessageHandler *NONNULL_PTR this_ptr, struct LDKOnionMessageHandler val); /** - * The genesis hash of the blockchain being queried + * Constructs a new MessageHandler given each field */ -void QueryShortChannelIds_set_chain_hash(struct LDKQueryShortChannelIds *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +MUST_USE_RES struct LDKMessageHandler MessageHandler_new(struct LDKChannelMessageHandler chan_handler_arg, struct LDKRoutingMessageHandler route_handler_arg, struct LDKOnionMessageHandler onion_message_handler_arg); /** - * The short_channel_ids that are being queried + * Creates a copy of a SocketDescriptor */ -void QueryShortChannelIds_set_short_channel_ids(struct LDKQueryShortChannelIds *NONNULL_PTR this_ptr, struct LDKCVec_u64Z val); +struct LDKSocketDescriptor SocketDescriptor_clone(const struct LDKSocketDescriptor *NONNULL_PTR orig); /** - * Constructs a new QueryShortChannelIds given each field + * Calls the free function if one is set */ -MUST_USE_RES struct LDKQueryShortChannelIds QueryShortChannelIds_new(struct LDKThirtyTwoBytes chain_hash_arg, struct LDKCVec_u64Z short_channel_ids_arg); +void SocketDescriptor_free(struct LDKSocketDescriptor this_ptr); /** - * Creates a copy of the QueryShortChannelIds + * Frees any resources used by the PeerHandleError, if is_owned is set and inner is non-NULL. */ -struct LDKQueryShortChannelIds QueryShortChannelIds_clone(const struct LDKQueryShortChannelIds *NONNULL_PTR orig); +void PeerHandleError_free(struct LDKPeerHandleError this_obj); /** - * Frees any resources used by the ReplyShortChannelIdsEnd, if is_owned is set and inner is non-NULL. + * Used to indicate that we probably can't make any future connections to this peer (e.g. + * because we required features that our peer was missing, or vice versa). + * + * While LDK's [`ChannelManager`] will not do it automatically, you likely wish to force-close + * any channels with this peer or check for new versions of LDK. + * + * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager */ -void ReplyShortChannelIdsEnd_free(struct LDKReplyShortChannelIdsEnd this_obj); +bool PeerHandleError_get_no_connection_possible(const struct LDKPeerHandleError *NONNULL_PTR this_ptr); /** - * The genesis hash of the blockchain that was queried + * Used to indicate that we probably can't make any future connections to this peer (e.g. + * because we required features that our peer was missing, or vice versa). + * + * While LDK's [`ChannelManager`] will not do it automatically, you likely wish to force-close + * any channels with this peer or check for new versions of LDK. + * + * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager */ -const uint8_t (*ReplyShortChannelIdsEnd_get_chain_hash(const struct LDKReplyShortChannelIdsEnd *NONNULL_PTR this_ptr))[32]; +void PeerHandleError_set_no_connection_possible(struct LDKPeerHandleError *NONNULL_PTR this_ptr, bool val); /** - * The genesis hash of the blockchain that was queried + * Constructs a new PeerHandleError given each field */ -void ReplyShortChannelIdsEnd_set_chain_hash(struct LDKReplyShortChannelIdsEnd *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +MUST_USE_RES struct LDKPeerHandleError PeerHandleError_new(bool no_connection_possible_arg); /** - * Indicates if the query recipient maintains up-to-date channel - * information for the chain_hash + * Creates a copy of the PeerHandleError */ -bool ReplyShortChannelIdsEnd_get_full_information(const struct LDKReplyShortChannelIdsEnd *NONNULL_PTR this_ptr); +struct LDKPeerHandleError PeerHandleError_clone(const struct LDKPeerHandleError *NONNULL_PTR orig); /** - * Indicates if the query recipient maintains up-to-date channel - * information for the chain_hash + * Frees any resources used by the PeerManager, if is_owned is set and inner is non-NULL. */ -void ReplyShortChannelIdsEnd_set_full_information(struct LDKReplyShortChannelIdsEnd *NONNULL_PTR this_ptr, bool val); +void PeerManager_free(struct LDKPeerManager this_obj); /** - * Constructs a new ReplyShortChannelIdsEnd given each field + * Constructs a new PeerManager with the given message handlers and node_id secret key + * ephemeral_random_data is used to derive per-connection ephemeral keys and must be + * cryptographically secure random bytes. + * + * `current_time` is used as an always-increasing counter that survives across restarts and is + * incremented irregularly internally. In general it is best to simply use the current UNIX + * timestamp, however if it is not available a persistent counter that increases once per + * minute should suffice. */ -MUST_USE_RES struct LDKReplyShortChannelIdsEnd ReplyShortChannelIdsEnd_new(struct LDKThirtyTwoBytes chain_hash_arg, bool full_information_arg); +MUST_USE_RES struct LDKPeerManager PeerManager_new(struct LDKMessageHandler message_handler, struct LDKSecretKey our_node_secret, uint32_t current_time, const uint8_t (*ephemeral_random_data)[32], struct LDKLogger logger, struct LDKCustomMessageHandler custom_message_handler); /** - * Creates a copy of the ReplyShortChannelIdsEnd + * Get the list of node ids for peers which have completed the initial handshake. + * + * For outbound connections, this will be the same as the their_node_id parameter passed in to + * new_outbound_connection, however entries will only appear once the initial handshake has + * completed and we are sure the remote peer has the private key for the given node_id. */ -struct LDKReplyShortChannelIdsEnd ReplyShortChannelIdsEnd_clone(const struct LDKReplyShortChannelIdsEnd *NONNULL_PTR orig); +MUST_USE_RES struct LDKCVec_PublicKeyZ PeerManager_get_peer_node_ids(const struct LDKPeerManager *NONNULL_PTR this_arg); /** - * Frees any resources used by the GossipTimestampFilter, if is_owned is set and inner is non-NULL. + * 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. + * + * If an `Err` is returned here you must disconnect the connection immediately. + * + * Returns a small number of bytes to send to the remote node (currently always 50). + * + * Panics if descriptor is duplicative with some other descriptor which has not yet been + * [`socket_disconnected()`]. + * + * [`socket_disconnected()`]: PeerManager::socket_disconnected */ -void GossipTimestampFilter_free(struct LDKGossipTimestampFilter this_obj); +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); /** - * The genesis hash of the blockchain for channel and node information + * 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). If an `Err` is returned here you must disconnect + * the connection immediately. + * + * Panics if descriptor is duplicative with some other descriptor which has not yet been + * [`socket_disconnected()`]. + * + * [`socket_disconnected()`]: PeerManager::socket_disconnected */ -const uint8_t (*GossipTimestampFilter_get_chain_hash(const struct LDKGossipTimestampFilter *NONNULL_PTR this_ptr))[32]; +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); /** - * The genesis hash of the blockchain for channel and node information + * Indicates that there is room to write data to the given socket descriptor. + * + * May return an Err to indicate that the connection should be closed. + * + * May call [`send_data`] on the descriptor passed in (or an equal descriptor) before + * returning. Thus, be very careful with reentrancy issues! The invariants around calling + * [`write_buffer_space_avail`] in case a write did not fully complete must still hold - be + * ready to call `[write_buffer_space_avail`] again if a write call generated here isn't + * sufficient! + * + * [`send_data`]: SocketDescriptor::send_data + * [`write_buffer_space_avail`]: PeerManager::write_buffer_space_avail */ -void GossipTimestampFilter_set_chain_hash(struct LDKGossipTimestampFilter *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +MUST_USE_RES struct LDKCResult_NonePeerHandleErrorZ PeerManager_write_buffer_space_avail(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKSocketDescriptor *NONNULL_PTR descriptor); /** - * The starting unix timestamp + * Indicates that data was read from the given socket descriptor. + * + * May return an Err to indicate that the connection should be closed. + * + * Will *not* call back into [`send_data`] on any descriptors to avoid reentrancy complexity. + * Thus, however, you should call [`process_events`] after any `read_event` to generate + * [`send_data`] calls to handle responses. + * + * If `Ok(true)` is returned, further read_events should not be triggered until a + * [`send_data`] call on this descriptor has `resume_read` set (preventing DoS issues in the + * send buffer). + * + * [`send_data`]: SocketDescriptor::send_data + * [`process_events`]: PeerManager::process_events */ -uint32_t GossipTimestampFilter_get_first_timestamp(const struct LDKGossipTimestampFilter *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCResult_boolPeerHandleErrorZ PeerManager_read_event(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKSocketDescriptor *NONNULL_PTR peer_descriptor, struct LDKu8slice data); /** - * The starting unix timestamp + * Checks for any events generated by our handlers and processes them. Includes sending most + * response messages as well as messages generated by calls to handler functions directly (eg + * functions like [`ChannelManager::process_pending_htlc_forwards`] or [`send_payment`]). + * + * May call [`send_data`] on [`SocketDescriptor`]s. Thus, be very careful with reentrancy + * issues! + * + * You don't have to call this function explicitly if you are using [`lightning-net-tokio`] + * or one of the other clients provided in our language bindings. + * + * Note that if there are any other calls to this function waiting on lock(s) this may return + * without doing any work. All available events that need handling will be handled before the + * other calls return. + * + * [`send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment + * [`ChannelManager::process_pending_htlc_forwards`]: crate::ln::channelmanager::ChannelManager::process_pending_htlc_forwards + * [`send_data`]: SocketDescriptor::send_data */ -void GossipTimestampFilter_set_first_timestamp(struct LDKGossipTimestampFilter *NONNULL_PTR this_ptr, uint32_t val); +void PeerManager_process_events(const struct LDKPeerManager *NONNULL_PTR this_arg); /** - * The range of information in seconds + * Indicates that the given socket descriptor's connection is now closed. */ -uint32_t GossipTimestampFilter_get_timestamp_range(const struct LDKGossipTimestampFilter *NONNULL_PTR this_ptr); +void PeerManager_socket_disconnected(const struct LDKPeerManager *NONNULL_PTR this_arg, const struct LDKSocketDescriptor *NONNULL_PTR descriptor); /** - * The range of information in seconds + * Disconnect a peer given its node id. + * + * Set `no_connection_possible` to true to prevent any further connection with this peer, + * force-closing any channels we have with it. + * + * If a peer is connected, this will call [`disconnect_socket`] on the descriptor for the + * peer. Thus, be very careful about reentrancy issues. + * + * [`disconnect_socket`]: SocketDescriptor::disconnect_socket */ -void GossipTimestampFilter_set_timestamp_range(struct LDKGossipTimestampFilter *NONNULL_PTR this_ptr, uint32_t val); +void PeerManager_disconnect_by_node_id(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKPublicKey node_id, bool no_connection_possible); /** - * Constructs a new GossipTimestampFilter given each field + * Disconnects all currently-connected peers. This is useful on platforms where there may be + * an indication that TCP sockets have stalled even if we weren't around to time them out + * using regular ping/pongs. */ -MUST_USE_RES struct LDKGossipTimestampFilter GossipTimestampFilter_new(struct LDKThirtyTwoBytes chain_hash_arg, uint32_t first_timestamp_arg, uint32_t timestamp_range_arg); +void PeerManager_disconnect_all_peers(const struct LDKPeerManager *NONNULL_PTR this_arg); /** - * Creates a copy of the GossipTimestampFilter + * 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 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! + * + * [`send_data`]: SocketDescriptor::send_data */ -struct LDKGossipTimestampFilter GossipTimestampFilter_clone(const struct LDKGossipTimestampFilter *NONNULL_PTR orig); +void PeerManager_timer_tick_occurred(const struct LDKPeerManager *NONNULL_PTR this_arg); /** - * Frees any resources used by the ErrorAction + * Generates a signed node_announcement from the given arguments, sending it to all connected + * peers. Note that peers will likely ignore this message unless we have at least one public + * channel which has at least six confirmations on-chain. + * + * `rgb` is a node \"color\" and `alias` is a printable human-readable string to describe this + * node to humans. They carry no in-protocol meaning. + * + * `addresses` represent the set (possibly empty) of socket addresses on which this node + * accepts incoming connections. These will be included in the node_announcement, publicly + * tying these addresses together and to this node. If you wish to preserve user privacy, + * addresses should likely contain only Tor Onion addresses. + * + * Panics if `addresses` is absurdly large (more than 100). + * + * [`get_and_clear_pending_msg_events`]: MessageSendEventsProvider::get_and_clear_pending_msg_events */ -void ErrorAction_free(struct LDKErrorAction this_ptr); +void PeerManager_broadcast_node_announcement(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKThreeBytes rgb, struct LDKThirtyTwoBytes alias, struct LDKCVec_NetAddressZ addresses); /** - * Creates a copy of the ErrorAction + * Gets the weight for an HTLC-Success transaction. */ -struct LDKErrorAction ErrorAction_clone(const struct LDKErrorAction *NONNULL_PTR orig); +uint64_t htlc_success_tx_weight(bool opt_anchors); /** - * Utility method to constructs a new DisconnectPeer-variant ErrorAction + * Gets the weight for an HTLC-Timeout transaction. */ -struct LDKErrorAction ErrorAction_disconnect_peer(struct LDKErrorMessage msg); +uint64_t htlc_timeout_tx_weight(bool opt_anchors); /** - * Utility method to constructs a new IgnoreError-variant ErrorAction + * Build the commitment secret from the seed and the commitment number */ -struct LDKErrorAction ErrorAction_ignore_error(void); +struct LDKThirtyTwoBytes build_commitment_secret(const uint8_t (*commitment_seed)[32], uint64_t idx); /** - * Utility method to constructs a new IgnoreAndLog-variant ErrorAction + * Build a closing transaction */ -struct LDKErrorAction ErrorAction_ignore_and_log(enum LDKLevel a); +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); /** - * Utility method to constructs a new IgnoreDuplicateGossip-variant ErrorAction + * Frees any resources used by the CounterpartyCommitmentSecrets, if is_owned is set and inner is non-NULL. */ -struct LDKErrorAction ErrorAction_ignore_duplicate_gossip(void); +void CounterpartyCommitmentSecrets_free(struct LDKCounterpartyCommitmentSecrets this_obj); /** - * Utility method to constructs a new SendErrorMessage-variant ErrorAction + * Creates a copy of the CounterpartyCommitmentSecrets */ -struct LDKErrorAction ErrorAction_send_error_message(struct LDKErrorMessage msg); +struct LDKCounterpartyCommitmentSecrets CounterpartyCommitmentSecrets_clone(const struct LDKCounterpartyCommitmentSecrets *NONNULL_PTR orig); /** - * Utility method to constructs a new SendWarningMessage-variant ErrorAction + * Creates a new empty `CounterpartyCommitmentSecrets` structure. */ -struct LDKErrorAction ErrorAction_send_warning_message(struct LDKWarningMessage msg, enum LDKLevel log_level); +MUST_USE_RES struct LDKCounterpartyCommitmentSecrets CounterpartyCommitmentSecrets_new(void); /** - * Frees any resources used by the LightningError, if is_owned is set and inner is non-NULL. + * Returns the minimum index of all stored secrets. Note that indexes start + * at 1 << 48 and get decremented by one for each new secret. */ -void LightningError_free(struct LDKLightningError this_obj); +MUST_USE_RES uint64_t CounterpartyCommitmentSecrets_get_min_seen_secret(const struct LDKCounterpartyCommitmentSecrets *NONNULL_PTR this_arg); /** - * A human-readable message describing the error + * Inserts the `secret` at `idx`. Returns `Ok(())` if the secret + * was generated in accordance with BOLT 3 and is consistent with previous secrets. */ -struct LDKStr LightningError_get_err(const struct LDKLightningError *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCResult_NoneNoneZ CounterpartyCommitmentSecrets_provide_secret(struct LDKCounterpartyCommitmentSecrets *NONNULL_PTR this_arg, uint64_t idx, struct LDKThirtyTwoBytes secret); /** - * A human-readable message describing the error + * 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 */ -void LightningError_set_err(struct LDKLightningError *NONNULL_PTR this_ptr, struct LDKStr val); +MUST_USE_RES struct LDKThirtyTwoBytes CounterpartyCommitmentSecrets_get_secret(const struct LDKCounterpartyCommitmentSecrets *NONNULL_PTR this_arg, uint64_t idx); /** - * The action which should be taken against the offending peer. + * Serialize the CounterpartyCommitmentSecrets object into a byte array which can be read by CounterpartyCommitmentSecrets_read */ -struct LDKErrorAction LightningError_get_action(const struct LDKLightningError *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z CounterpartyCommitmentSecrets_write(const struct LDKCounterpartyCommitmentSecrets *NONNULL_PTR obj); /** - * The action which should be taken against the offending peer. + * Read a CounterpartyCommitmentSecrets from a byte array, created by CounterpartyCommitmentSecrets_write */ -void LightningError_set_action(struct LDKLightningError *NONNULL_PTR this_ptr, struct LDKErrorAction val); +struct LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ CounterpartyCommitmentSecrets_read(struct LDKu8slice ser); /** - * Constructs a new LightningError given each field + * Derives a per-commitment-transaction private key (eg an htlc key or delayed_payment key) + * from the base secret and the per_commitment_point. + * + * Note that this is infallible iff we trust that at least one of the two input keys are randomly + * generated (ie our own). */ -MUST_USE_RES struct LDKLightningError LightningError_new(struct LDKStr err_arg, struct LDKErrorAction action_arg); +struct LDKCResult_SecretKeyErrorZ derive_private_key(struct LDKPublicKey per_commitment_point, const uint8_t (*base_secret)[32]); /** - * Creates a copy of the LightningError + * Derives a per-commitment-transaction public key (eg an htlc key or a delayed_payment key) + * from the base point and the per_commitment_key. This is the public equivalent of + * derive_private_key - using only public keys to derive a public key instead of private keys. + * + * Note that this is infallible iff we trust that at least one of the two input keys are randomly + * generated (ie our own). */ -struct LDKLightningError LightningError_clone(const struct LDKLightningError *NONNULL_PTR orig); +struct LDKCResult_PublicKeyErrorZ derive_public_key(struct LDKPublicKey per_commitment_point, struct LDKPublicKey base_point); /** - * Frees any resources used by the CommitmentUpdate, if is_owned is set and inner is non-NULL. + * Derives a per-commitment-transaction revocation key from its constituent parts. + * + * Only the cheating participant owns a valid witness to propagate a revoked + * commitment transaction, thus per_commitment_secret always come from cheater + * and revocation_base_secret always come from punisher, which is the broadcaster + * of the transaction spending with this key knowledge. + * + * Note that this is infallible iff we trust that at least one of the two input keys are randomly + * generated (ie our own). */ -void CommitmentUpdate_free(struct LDKCommitmentUpdate this_obj); +struct LDKCResult_SecretKeyErrorZ derive_private_revocation_key(const uint8_t (*per_commitment_secret)[32], const uint8_t (*countersignatory_revocation_base_secret)[32]); /** - * update_add_htlc messages which should be sent + * Derives a per-commitment-transaction revocation public key from its constituent parts. This is + * the public equivalend of derive_private_revocation_key - using only public keys to derive a + * public key instead of private keys. + * + * Only the cheating participant owns a valid witness to propagate a revoked + * commitment transaction, thus per_commitment_point always come from cheater + * and revocation_base_point always come from punisher, which is the broadcaster + * of the transaction spending with this key knowledge. + * + * Note that this is infallible iff we trust that at least one of the two input keys are randomly + * generated (ie our own). */ -struct LDKCVec_UpdateAddHTLCZ CommitmentUpdate_get_update_add_htlcs(const struct LDKCommitmentUpdate *NONNULL_PTR this_ptr); +struct LDKCResult_PublicKeyErrorZ derive_public_revocation_key(struct LDKPublicKey per_commitment_point, struct LDKPublicKey countersignatory_revocation_base_point); /** - * update_add_htlc messages which should be sent + * Frees any resources used by the TxCreationKeys, if is_owned is set and inner is non-NULL. */ -void CommitmentUpdate_set_update_add_htlcs(struct LDKCommitmentUpdate *NONNULL_PTR this_ptr, struct LDKCVec_UpdateAddHTLCZ val); +void TxCreationKeys_free(struct LDKTxCreationKeys this_obj); /** - * update_fulfill_htlc messages which should be sent + * The broadcaster's per-commitment public key which was used to derive the other keys. */ -struct LDKCVec_UpdateFulfillHTLCZ CommitmentUpdate_get_update_fulfill_htlcs(const struct LDKCommitmentUpdate *NONNULL_PTR this_ptr); +struct LDKPublicKey TxCreationKeys_get_per_commitment_point(const struct LDKTxCreationKeys *NONNULL_PTR this_ptr); /** - * update_fulfill_htlc messages which should be sent + * The broadcaster's per-commitment public key which was used to derive the other keys. */ -void CommitmentUpdate_set_update_fulfill_htlcs(struct LDKCommitmentUpdate *NONNULL_PTR this_ptr, struct LDKCVec_UpdateFulfillHTLCZ val); +void TxCreationKeys_set_per_commitment_point(struct LDKTxCreationKeys *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * update_fail_htlc messages which should be sent + * The revocation key which is used to allow the broadcaster of the commitment + * transaction to provide their counterparty the ability to punish them if they broadcast + * an old state. */ -struct LDKCVec_UpdateFailHTLCZ CommitmentUpdate_get_update_fail_htlcs(const struct LDKCommitmentUpdate *NONNULL_PTR this_ptr); +struct LDKPublicKey TxCreationKeys_get_revocation_key(const struct LDKTxCreationKeys *NONNULL_PTR this_ptr); /** - * update_fail_htlc messages which should be sent + * The revocation key which is used to allow the broadcaster of the commitment + * transaction to provide their counterparty the ability to punish them if they broadcast + * an old state. */ -void CommitmentUpdate_set_update_fail_htlcs(struct LDKCommitmentUpdate *NONNULL_PTR this_ptr, struct LDKCVec_UpdateFailHTLCZ val); +void TxCreationKeys_set_revocation_key(struct LDKTxCreationKeys *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * update_fail_malformed_htlc messages which should be sent + * Broadcaster's HTLC Key */ -struct LDKCVec_UpdateFailMalformedHTLCZ CommitmentUpdate_get_update_fail_malformed_htlcs(const struct LDKCommitmentUpdate *NONNULL_PTR this_ptr); +struct LDKPublicKey TxCreationKeys_get_broadcaster_htlc_key(const struct LDKTxCreationKeys *NONNULL_PTR this_ptr); /** - * update_fail_malformed_htlc messages which should be sent + * Broadcaster's HTLC Key */ -void CommitmentUpdate_set_update_fail_malformed_htlcs(struct LDKCommitmentUpdate *NONNULL_PTR this_ptr, struct LDKCVec_UpdateFailMalformedHTLCZ val); +void TxCreationKeys_set_broadcaster_htlc_key(struct LDKTxCreationKeys *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * An update_fee message which should be sent - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Countersignatory's HTLC Key */ -struct LDKUpdateFee CommitmentUpdate_get_update_fee(const struct LDKCommitmentUpdate *NONNULL_PTR this_ptr); +struct LDKPublicKey TxCreationKeys_get_countersignatory_htlc_key(const struct LDKTxCreationKeys *NONNULL_PTR this_ptr); /** - * An update_fee message which should be sent - * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + * Countersignatory's HTLC Key */ -void CommitmentUpdate_set_update_fee(struct LDKCommitmentUpdate *NONNULL_PTR this_ptr, struct LDKUpdateFee val); +void TxCreationKeys_set_countersignatory_htlc_key(struct LDKTxCreationKeys *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Finally, the commitment_signed message which should be sent + * Broadcaster's Payment Key (which isn't allowed to be spent from for some delay) */ -struct LDKCommitmentSigned CommitmentUpdate_get_commitment_signed(const struct LDKCommitmentUpdate *NONNULL_PTR this_ptr); +struct LDKPublicKey TxCreationKeys_get_broadcaster_delayed_payment_key(const struct LDKTxCreationKeys *NONNULL_PTR this_ptr); /** - * Finally, the commitment_signed message which should be sent + * Broadcaster's Payment Key (which isn't allowed to be spent from for some delay) */ -void CommitmentUpdate_set_commitment_signed(struct LDKCommitmentUpdate *NONNULL_PTR this_ptr, struct LDKCommitmentSigned val); +void TxCreationKeys_set_broadcaster_delayed_payment_key(struct LDKTxCreationKeys *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Constructs a new CommitmentUpdate given each field + * Constructs a new TxCreationKeys given each field */ -MUST_USE_RES struct LDKCommitmentUpdate CommitmentUpdate_new(struct LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg, struct LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg, struct LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg, struct LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg, struct LDKUpdateFee update_fee_arg, struct LDKCommitmentSigned commitment_signed_arg); +MUST_USE_RES struct LDKTxCreationKeys TxCreationKeys_new(struct LDKPublicKey per_commitment_point_arg, struct LDKPublicKey revocation_key_arg, struct LDKPublicKey broadcaster_htlc_key_arg, struct LDKPublicKey countersignatory_htlc_key_arg, struct LDKPublicKey broadcaster_delayed_payment_key_arg); /** - * Creates a copy of the CommitmentUpdate + * Checks if two TxCreationKeyss contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -struct LDKCommitmentUpdate CommitmentUpdate_clone(const struct LDKCommitmentUpdate *NONNULL_PTR orig); +bool TxCreationKeys_eq(const struct LDKTxCreationKeys *NONNULL_PTR a, const struct LDKTxCreationKeys *NONNULL_PTR b); /** - * Calls the free function if one is set + * Creates a copy of the TxCreationKeys */ -void ChannelMessageHandler_free(struct LDKChannelMessageHandler this_ptr); +struct LDKTxCreationKeys TxCreationKeys_clone(const struct LDKTxCreationKeys *NONNULL_PTR orig); /** - * Calls the free function if one is set + * Serialize the TxCreationKeys object into a byte array which can be read by TxCreationKeys_read */ -void RoutingMessageHandler_free(struct LDKRoutingMessageHandler this_ptr); +struct LDKCVec_u8Z TxCreationKeys_write(const struct LDKTxCreationKeys *NONNULL_PTR obj); /** - * Serialize the AcceptChannel object into a byte array which can be read by AcceptChannel_read + * Read a TxCreationKeys from a byte array, created by TxCreationKeys_write */ -struct LDKCVec_u8Z AcceptChannel_write(const struct LDKAcceptChannel *NONNULL_PTR obj); +struct LDKCResult_TxCreationKeysDecodeErrorZ TxCreationKeys_read(struct LDKu8slice ser); /** - * Read a AcceptChannel from a byte array, created by AcceptChannel_write + * Frees any resources used by the ChannelPublicKeys, if is_owned is set and inner is non-NULL. */ -struct LDKCResult_AcceptChannelDecodeErrorZ AcceptChannel_read(struct LDKu8slice ser); +void ChannelPublicKeys_free(struct LDKChannelPublicKeys this_obj); /** - * Serialize the AnnouncementSignatures object into a byte array which can be read by AnnouncementSignatures_read + * The public key which is used to sign all commitment transactions, as it appears in the + * on-chain channel lock-in 2-of-2 multisig output. */ -struct LDKCVec_u8Z AnnouncementSignatures_write(const struct LDKAnnouncementSignatures *NONNULL_PTR obj); +struct LDKPublicKey ChannelPublicKeys_get_funding_pubkey(const struct LDKChannelPublicKeys *NONNULL_PTR this_ptr); /** - * Read a AnnouncementSignatures from a byte array, created by AnnouncementSignatures_write + * The public key which is used to sign all commitment transactions, as it appears in the + * on-chain channel lock-in 2-of-2 multisig output. */ -struct LDKCResult_AnnouncementSignaturesDecodeErrorZ AnnouncementSignatures_read(struct LDKu8slice ser); +void ChannelPublicKeys_set_funding_pubkey(struct LDKChannelPublicKeys *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Serialize the ChannelReestablish object into a byte array which can be read by ChannelReestablish_read + * The base point which is used (with derive_public_revocation_key) to derive per-commitment + * revocation keys. This is combined with the per-commitment-secret generated by the + * counterparty to create a secret which the counterparty can reveal to revoke previous + * states. */ -struct LDKCVec_u8Z ChannelReestablish_write(const struct LDKChannelReestablish *NONNULL_PTR obj); +struct LDKPublicKey ChannelPublicKeys_get_revocation_basepoint(const struct LDKChannelPublicKeys *NONNULL_PTR this_ptr); /** - * Read a ChannelReestablish from a byte array, created by ChannelReestablish_write + * The base point which is used (with derive_public_revocation_key) to derive per-commitment + * revocation keys. This is combined with the per-commitment-secret generated by the + * counterparty to create a secret which the counterparty can reveal to revoke previous + * states. */ -struct LDKCResult_ChannelReestablishDecodeErrorZ ChannelReestablish_read(struct LDKu8slice ser); +void ChannelPublicKeys_set_revocation_basepoint(struct LDKChannelPublicKeys *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Serialize the ClosingSigned object into a byte array which can be read by ClosingSigned_read + * The public key on which the non-broadcaster (ie the countersignatory) receives an immediately + * spendable primary channel balance on the broadcaster's commitment transaction. This key is + * static across every commitment transaction. */ -struct LDKCVec_u8Z ClosingSigned_write(const struct LDKClosingSigned *NONNULL_PTR obj); +struct LDKPublicKey ChannelPublicKeys_get_payment_point(const struct LDKChannelPublicKeys *NONNULL_PTR this_ptr); /** - * Read a ClosingSigned from a byte array, created by ClosingSigned_write + * The public key on which the non-broadcaster (ie the countersignatory) receives an immediately + * spendable primary channel balance on the broadcaster's commitment transaction. This key is + * static across every commitment transaction. */ -struct LDKCResult_ClosingSignedDecodeErrorZ ClosingSigned_read(struct LDKu8slice ser); +void ChannelPublicKeys_set_payment_point(struct LDKChannelPublicKeys *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Serialize the ClosingSignedFeeRange object into a byte array which can be read by ClosingSignedFeeRange_read + * The base point which is used (with derive_public_key) to derive a per-commitment payment + * public key which receives non-HTLC-encumbered funds which are only available for spending + * after some delay (or can be claimed via the revocation path). */ -struct LDKCVec_u8Z ClosingSignedFeeRange_write(const struct LDKClosingSignedFeeRange *NONNULL_PTR obj); +struct LDKPublicKey ChannelPublicKeys_get_delayed_payment_basepoint(const struct LDKChannelPublicKeys *NONNULL_PTR this_ptr); /** - * Read a ClosingSignedFeeRange from a byte array, created by ClosingSignedFeeRange_write + * The base point which is used (with derive_public_key) to derive a per-commitment payment + * public key which receives non-HTLC-encumbered funds which are only available for spending + * after some delay (or can be claimed via the revocation path). */ -struct LDKCResult_ClosingSignedFeeRangeDecodeErrorZ ClosingSignedFeeRange_read(struct LDKu8slice ser); +void ChannelPublicKeys_set_delayed_payment_basepoint(struct LDKChannelPublicKeys *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Serialize the CommitmentSigned object into a byte array which can be read by CommitmentSigned_read + * The base point which is used (with derive_public_key) to derive a per-commitment public key + * which is used to encumber HTLC-in-flight outputs. */ -struct LDKCVec_u8Z CommitmentSigned_write(const struct LDKCommitmentSigned *NONNULL_PTR obj); +struct LDKPublicKey ChannelPublicKeys_get_htlc_basepoint(const struct LDKChannelPublicKeys *NONNULL_PTR this_ptr); /** - * Read a CommitmentSigned from a byte array, created by CommitmentSigned_write + * The base point which is used (with derive_public_key) to derive a per-commitment public key + * which is used to encumber HTLC-in-flight outputs. */ -struct LDKCResult_CommitmentSignedDecodeErrorZ CommitmentSigned_read(struct LDKu8slice ser); +void ChannelPublicKeys_set_htlc_basepoint(struct LDKChannelPublicKeys *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Serialize the FundingCreated object into a byte array which can be read by FundingCreated_read + * Constructs a new ChannelPublicKeys given each field */ -struct LDKCVec_u8Z FundingCreated_write(const struct LDKFundingCreated *NONNULL_PTR obj); +MUST_USE_RES struct LDKChannelPublicKeys ChannelPublicKeys_new(struct LDKPublicKey funding_pubkey_arg, struct LDKPublicKey revocation_basepoint_arg, struct LDKPublicKey payment_point_arg, struct LDKPublicKey delayed_payment_basepoint_arg, struct LDKPublicKey htlc_basepoint_arg); /** - * Read a FundingCreated from a byte array, created by FundingCreated_write + * Creates a copy of the ChannelPublicKeys */ -struct LDKCResult_FundingCreatedDecodeErrorZ FundingCreated_read(struct LDKu8slice ser); +struct LDKChannelPublicKeys ChannelPublicKeys_clone(const struct LDKChannelPublicKeys *NONNULL_PTR orig); /** - * Serialize the FundingSigned object into a byte array which can be read by FundingSigned_read + * Checks if two ChannelPublicKeyss contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -struct LDKCVec_u8Z FundingSigned_write(const struct LDKFundingSigned *NONNULL_PTR obj); +bool ChannelPublicKeys_eq(const struct LDKChannelPublicKeys *NONNULL_PTR a, const struct LDKChannelPublicKeys *NONNULL_PTR b); /** - * Read a FundingSigned from a byte array, created by FundingSigned_write + * Serialize the ChannelPublicKeys object into a byte array which can be read by ChannelPublicKeys_read */ -struct LDKCResult_FundingSignedDecodeErrorZ FundingSigned_read(struct LDKu8slice ser); +struct LDKCVec_u8Z ChannelPublicKeys_write(const struct LDKChannelPublicKeys *NONNULL_PTR obj); /** - * Serialize the FundingLocked object into a byte array which can be read by FundingLocked_read + * Read a ChannelPublicKeys from a byte array, created by ChannelPublicKeys_write */ -struct LDKCVec_u8Z FundingLocked_write(const struct LDKFundingLocked *NONNULL_PTR obj); +struct LDKCResult_ChannelPublicKeysDecodeErrorZ ChannelPublicKeys_read(struct LDKu8slice ser); /** - * Read a FundingLocked from a byte array, created by FundingLocked_write + * Create per-state keys from channel base points and the per-commitment point. + * Key set is asymmetric and can't be used as part of counter-signatory set of transactions. */ -struct LDKCResult_FundingLockedDecodeErrorZ FundingLocked_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKCResult_TxCreationKeysErrorZ TxCreationKeys_derive_new(struct LDKPublicKey per_commitment_point, struct LDKPublicKey broadcaster_delayed_payment_base, struct LDKPublicKey broadcaster_htlc_base, struct LDKPublicKey countersignatory_revocation_base, struct LDKPublicKey countersignatory_htlc_base); /** - * Serialize the Init object into a byte array which can be read by Init_read + * Generate per-state keys from channel static keys. + * Key set is asymmetric and can't be used as part of counter-signatory set of transactions. */ -struct LDKCVec_u8Z Init_write(const struct LDKInit *NONNULL_PTR obj); +MUST_USE_RES struct LDKCResult_TxCreationKeysErrorZ TxCreationKeys_from_channel_static_keys(struct LDKPublicKey per_commitment_point, const struct LDKChannelPublicKeys *NONNULL_PTR broadcaster_keys, const struct LDKChannelPublicKeys *NONNULL_PTR countersignatory_keys); /** - * Read a Init from a byte array, created by Init_write + * A script either spendable by the revocation + * key or the broadcaster_delayed_payment_key and satisfying the relative-locktime OP_CSV constrain. + * Encumbering a `to_holder` output on a commitment transaction or 2nd-stage HTLC transactions. */ -struct LDKCResult_InitDecodeErrorZ Init_read(struct LDKu8slice ser); +struct LDKCVec_u8Z get_revokeable_redeemscript(struct LDKPublicKey revocation_key, uint16_t contest_delay, struct LDKPublicKey broadcaster_delayed_payment_key); /** - * Serialize the OpenChannel object into a byte array which can be read by OpenChannel_read + * Frees any resources used by the HTLCOutputInCommitment, if is_owned is set and inner is non-NULL. */ -struct LDKCVec_u8Z OpenChannel_write(const struct LDKOpenChannel *NONNULL_PTR obj); +void HTLCOutputInCommitment_free(struct LDKHTLCOutputInCommitment this_obj); /** - * Read a OpenChannel from a byte array, created by OpenChannel_write + * Whether the HTLC was \"offered\" (ie outbound in relation to this commitment transaction). + * Note that this is not the same as whether it is ountbound *from us*. To determine that you + * need to compare this value to whether the commitment transaction in question is that of + * the counterparty or our own. */ -struct LDKCResult_OpenChannelDecodeErrorZ OpenChannel_read(struct LDKu8slice ser); +bool HTLCOutputInCommitment_get_offered(const struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr); /** - * Serialize the RevokeAndACK object into a byte array which can be read by RevokeAndACK_read + * Whether the HTLC was \"offered\" (ie outbound in relation to this commitment transaction). + * Note that this is not the same as whether it is ountbound *from us*. To determine that you + * need to compare this value to whether the commitment transaction in question is that of + * the counterparty or our own. */ -struct LDKCVec_u8Z RevokeAndACK_write(const struct LDKRevokeAndACK *NONNULL_PTR obj); +void HTLCOutputInCommitment_set_offered(struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr, bool val); /** - * Read a RevokeAndACK from a byte array, created by RevokeAndACK_write + * The value, in msat, of the HTLC. The value as it appears in the commitment transaction is + * this divided by 1000. */ -struct LDKCResult_RevokeAndACKDecodeErrorZ RevokeAndACK_read(struct LDKu8slice ser); +uint64_t HTLCOutputInCommitment_get_amount_msat(const struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr); /** - * Serialize the Shutdown object into a byte array which can be read by Shutdown_read + * The value, in msat, of the HTLC. The value as it appears in the commitment transaction is + * this divided by 1000. */ -struct LDKCVec_u8Z Shutdown_write(const struct LDKShutdown *NONNULL_PTR obj); +void HTLCOutputInCommitment_set_amount_msat(struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr, uint64_t val); /** - * Read a Shutdown from a byte array, created by Shutdown_write + * The CLTV lock-time at which this HTLC expires. */ -struct LDKCResult_ShutdownDecodeErrorZ Shutdown_read(struct LDKu8slice ser); +uint32_t HTLCOutputInCommitment_get_cltv_expiry(const struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr); /** - * Serialize the UpdateFailHTLC object into a byte array which can be read by UpdateFailHTLC_read + * The CLTV lock-time at which this HTLC expires. */ -struct LDKCVec_u8Z UpdateFailHTLC_write(const struct LDKUpdateFailHTLC *NONNULL_PTR obj); +void HTLCOutputInCommitment_set_cltv_expiry(struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr, uint32_t val); /** - * Read a UpdateFailHTLC from a byte array, created by UpdateFailHTLC_write + * The hash of the preimage which unlocks this HTLC. */ -struct LDKCResult_UpdateFailHTLCDecodeErrorZ UpdateFailHTLC_read(struct LDKu8slice ser); +const uint8_t (*HTLCOutputInCommitment_get_payment_hash(const struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr))[32]; /** - * Serialize the UpdateFailMalformedHTLC object into a byte array which can be read by UpdateFailMalformedHTLC_read + * The hash of the preimage which unlocks this HTLC. */ -struct LDKCVec_u8Z UpdateFailMalformedHTLC_write(const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR obj); +void HTLCOutputInCommitment_set_payment_hash(struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Read a UpdateFailMalformedHTLC from a byte array, created by UpdateFailMalformedHTLC_write + * The position within the commitment transactions' outputs. This may be None if the value is + * below the dust limit (in which case no output appears in the commitment transaction and the + * value is spent to additional transaction fees). */ -struct LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ UpdateFailMalformedHTLC_read(struct LDKu8slice ser); +struct LDKCOption_u32Z HTLCOutputInCommitment_get_transaction_output_index(const struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr); /** - * Serialize the UpdateFee object into a byte array which can be read by UpdateFee_read + * The position within the commitment transactions' outputs. This may be None if the value is + * below the dust limit (in which case no output appears in the commitment transaction and the + * value is spent to additional transaction fees). */ -struct LDKCVec_u8Z UpdateFee_write(const struct LDKUpdateFee *NONNULL_PTR obj); +void HTLCOutputInCommitment_set_transaction_output_index(struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr, struct LDKCOption_u32Z val); /** - * Read a UpdateFee from a byte array, created by UpdateFee_write + * Constructs a new HTLCOutputInCommitment given each field */ -struct LDKCResult_UpdateFeeDecodeErrorZ UpdateFee_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKHTLCOutputInCommitment HTLCOutputInCommitment_new(bool offered_arg, uint64_t amount_msat_arg, uint32_t cltv_expiry_arg, struct LDKThirtyTwoBytes payment_hash_arg, struct LDKCOption_u32Z transaction_output_index_arg); /** - * Serialize the UpdateFulfillHTLC object into a byte array which can be read by UpdateFulfillHTLC_read + * Creates a copy of the HTLCOutputInCommitment */ -struct LDKCVec_u8Z UpdateFulfillHTLC_write(const struct LDKUpdateFulfillHTLC *NONNULL_PTR obj); +struct LDKHTLCOutputInCommitment HTLCOutputInCommitment_clone(const struct LDKHTLCOutputInCommitment *NONNULL_PTR orig); /** - * Read a UpdateFulfillHTLC from a byte array, created by UpdateFulfillHTLC_write + * Checks if two HTLCOutputInCommitments contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -struct LDKCResult_UpdateFulfillHTLCDecodeErrorZ UpdateFulfillHTLC_read(struct LDKu8slice ser); +bool HTLCOutputInCommitment_eq(const struct LDKHTLCOutputInCommitment *NONNULL_PTR a, const struct LDKHTLCOutputInCommitment *NONNULL_PTR b); /** - * Serialize the UpdateAddHTLC object into a byte array which can be read by UpdateAddHTLC_read + * Serialize the HTLCOutputInCommitment object into a byte array which can be read by HTLCOutputInCommitment_read */ -struct LDKCVec_u8Z UpdateAddHTLC_write(const struct LDKUpdateAddHTLC *NONNULL_PTR obj); +struct LDKCVec_u8Z HTLCOutputInCommitment_write(const struct LDKHTLCOutputInCommitment *NONNULL_PTR obj); /** - * Read a UpdateAddHTLC from a byte array, created by UpdateAddHTLC_write + * Read a HTLCOutputInCommitment from a byte array, created by HTLCOutputInCommitment_write */ -struct LDKCResult_UpdateAddHTLCDecodeErrorZ UpdateAddHTLC_read(struct LDKu8slice ser); +struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ HTLCOutputInCommitment_read(struct LDKu8slice ser); /** - * Serialize the Ping object into a byte array which can be read by Ping_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 Ping_write(const struct LDKPing *NONNULL_PTR obj); +struct LDKCVec_u8Z get_htlc_redeemscript(const struct LDKHTLCOutputInCommitment *NONNULL_PTR htlc, bool opt_anchors, const struct LDKTxCreationKeys *NONNULL_PTR keys); /** - * Read a Ping from a byte array, created by Ping_write + * Gets the redeemscript for a funding output from the two funding public keys. + * Note that the order of funding public keys does not matter. */ -struct LDKCResult_PingDecodeErrorZ Ping_read(struct LDKu8slice ser); +struct LDKCVec_u8Z make_funding_redeemscript(struct LDKPublicKey broadcaster, struct LDKPublicKey countersignatory); /** - * Serialize the Pong object into a byte array which can be read by Pong_read + * Builds an unsigned HTLC-Success or HTLC-Timeout transaction from the given channel and HTLC + * parameters. This is used by [`TrustedCommitmentTransaction::get_htlc_sigs`] to fetch the + * transaction which needs signing, and can be used to construct an HTLC transaction which is + * broadcastable given a counterparty HTLC signature. + * + * Panics if htlc.transaction_output_index.is_none() (as such HTLCs do not appear in the + * commitment transaction). */ -struct LDKCVec_u8Z Pong_write(const struct LDKPong *NONNULL_PTR obj); +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); /** - * Read a Pong from a byte array, created by Pong_write + * 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 LDKCResult_PongDecodeErrorZ Pong_read(struct LDKu8slice ser); +struct LDKCVec_u8Z get_anchor_redeemscript(struct LDKPublicKey funding_pubkey); /** - * Serialize the UnsignedChannelAnnouncement object into a byte array which can be read by UnsignedChannelAnnouncement_read + * Frees any resources used by the ChannelTransactionParameters, if is_owned is set and inner is non-NULL. */ -struct LDKCVec_u8Z UnsignedChannelAnnouncement_write(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR obj); +void ChannelTransactionParameters_free(struct LDKChannelTransactionParameters this_obj); /** - * Read a UnsignedChannelAnnouncement from a byte array, created by UnsignedChannelAnnouncement_write + * Holder public keys */ -struct LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ UnsignedChannelAnnouncement_read(struct LDKu8slice ser); +struct LDKChannelPublicKeys ChannelTransactionParameters_get_holder_pubkeys(const struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr); /** - * Serialize the ChannelAnnouncement object into a byte array which can be read by ChannelAnnouncement_read + * Holder public keys */ -struct LDKCVec_u8Z ChannelAnnouncement_write(const struct LDKChannelAnnouncement *NONNULL_PTR obj); +void ChannelTransactionParameters_set_holder_pubkeys(struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr, struct LDKChannelPublicKeys val); /** - * Read a ChannelAnnouncement from a byte array, created by ChannelAnnouncement_write + * The contest delay selected by the holder, which applies to counterparty-broadcast transactions */ -struct LDKCResult_ChannelAnnouncementDecodeErrorZ ChannelAnnouncement_read(struct LDKu8slice ser); +uint16_t ChannelTransactionParameters_get_holder_selected_contest_delay(const struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr); /** - * Serialize the UnsignedChannelUpdate object into a byte array which can be read by UnsignedChannelUpdate_read + * The contest delay selected by the holder, which applies to counterparty-broadcast transactions */ -struct LDKCVec_u8Z UnsignedChannelUpdate_write(const struct LDKUnsignedChannelUpdate *NONNULL_PTR obj); +void ChannelTransactionParameters_set_holder_selected_contest_delay(struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr, uint16_t val); /** - * Read a UnsignedChannelUpdate from a byte array, created by UnsignedChannelUpdate_write + * Whether the holder is the initiator of this channel. + * This is an input to the commitment number obscure factor computation. */ -struct LDKCResult_UnsignedChannelUpdateDecodeErrorZ UnsignedChannelUpdate_read(struct LDKu8slice ser); +bool ChannelTransactionParameters_get_is_outbound_from_holder(const struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr); /** - * Serialize the ChannelUpdate object into a byte array which can be read by ChannelUpdate_read + * Whether the holder is the initiator of this channel. + * This is an input to the commitment number obscure factor computation. */ -struct LDKCVec_u8Z ChannelUpdate_write(const struct LDKChannelUpdate *NONNULL_PTR obj); +void ChannelTransactionParameters_set_is_outbound_from_holder(struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr, bool val); /** - * Read a ChannelUpdate from a byte array, created by ChannelUpdate_write + * The late-bound counterparty channel transaction parameters. + * These parameters are populated at the point in the protocol where the counterparty provides them. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKCResult_ChannelUpdateDecodeErrorZ ChannelUpdate_read(struct LDKu8slice ser); +struct LDKCounterpartyChannelTransactionParameters ChannelTransactionParameters_get_counterparty_parameters(const struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr); /** - * Serialize the ErrorMessage object into a byte array which can be read by ErrorMessage_read + * The late-bound counterparty channel transaction parameters. + * These parameters are populated at the point in the protocol where the counterparty provides them. + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKCVec_u8Z ErrorMessage_write(const struct LDKErrorMessage *NONNULL_PTR obj); +void ChannelTransactionParameters_set_counterparty_parameters(struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr, struct LDKCounterpartyChannelTransactionParameters val); /** - * Read a ErrorMessage from a byte array, created by ErrorMessage_write + * The late-bound funding outpoint + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKCResult_ErrorMessageDecodeErrorZ ErrorMessage_read(struct LDKu8slice ser); +struct LDKOutPoint ChannelTransactionParameters_get_funding_outpoint(const struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr); /** - * Serialize the WarningMessage object into a byte array which can be read by WarningMessage_read + * The late-bound funding outpoint + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKCVec_u8Z WarningMessage_write(const struct LDKWarningMessage *NONNULL_PTR obj); +void ChannelTransactionParameters_set_funding_outpoint(struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr, struct LDKOutPoint val); /** - * Read a WarningMessage from a byte array, created by WarningMessage_write + * Are anchors (zero fee HTLC transaction variant) used for this channel. Boolean is + * serialization backwards-compatible. */ -struct LDKCResult_WarningMessageDecodeErrorZ WarningMessage_read(struct LDKu8slice ser); +enum LDKCOption_NoneZ ChannelTransactionParameters_get_opt_anchors(const struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr); /** - * Serialize the UnsignedNodeAnnouncement object into a byte array which can be read by UnsignedNodeAnnouncement_read + * Are anchors (zero fee HTLC transaction variant) used for this channel. Boolean is + * serialization backwards-compatible. */ -struct LDKCVec_u8Z UnsignedNodeAnnouncement_write(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR obj); +void ChannelTransactionParameters_set_opt_anchors(struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr, enum LDKCOption_NoneZ val); /** - * Read a UnsignedNodeAnnouncement from a byte array, created by UnsignedNodeAnnouncement_write + * Constructs a new ChannelTransactionParameters given each field */ -struct LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ UnsignedNodeAnnouncement_read(struct LDKu8slice ser); +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); /** - * Serialize the NodeAnnouncement object into a byte array which can be read by NodeAnnouncement_read + * Creates a copy of the ChannelTransactionParameters */ -struct LDKCVec_u8Z NodeAnnouncement_write(const struct LDKNodeAnnouncement *NONNULL_PTR obj); +struct LDKChannelTransactionParameters ChannelTransactionParameters_clone(const struct LDKChannelTransactionParameters *NONNULL_PTR orig); /** - * Read a NodeAnnouncement from a byte array, created by NodeAnnouncement_write + * Frees any resources used by the CounterpartyChannelTransactionParameters, if is_owned is set and inner is non-NULL. */ -struct LDKCResult_NodeAnnouncementDecodeErrorZ NodeAnnouncement_read(struct LDKu8slice ser); +void CounterpartyChannelTransactionParameters_free(struct LDKCounterpartyChannelTransactionParameters this_obj); /** - * Read a QueryShortChannelIds from a byte array, created by QueryShortChannelIds_write + * Counter-party public keys */ -struct LDKCResult_QueryShortChannelIdsDecodeErrorZ QueryShortChannelIds_read(struct LDKu8slice ser); +struct LDKChannelPublicKeys CounterpartyChannelTransactionParameters_get_pubkeys(const struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR this_ptr); /** - * Serialize the QueryShortChannelIds object into a byte array which can be read by QueryShortChannelIds_read + * Counter-party public keys */ -struct LDKCVec_u8Z QueryShortChannelIds_write(const struct LDKQueryShortChannelIds *NONNULL_PTR obj); +void CounterpartyChannelTransactionParameters_set_pubkeys(struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR this_ptr, struct LDKChannelPublicKeys val); /** - * Serialize the ReplyShortChannelIdsEnd object into a byte array which can be read by ReplyShortChannelIdsEnd_read + * The contest delay selected by the counterparty, which applies to holder-broadcast transactions */ -struct LDKCVec_u8Z ReplyShortChannelIdsEnd_write(const struct LDKReplyShortChannelIdsEnd *NONNULL_PTR obj); +uint16_t CounterpartyChannelTransactionParameters_get_selected_contest_delay(const struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR this_ptr); /** - * Read a ReplyShortChannelIdsEnd from a byte array, created by ReplyShortChannelIdsEnd_write + * The contest delay selected by the counterparty, which applies to holder-broadcast transactions */ -struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ ReplyShortChannelIdsEnd_read(struct LDKu8slice ser); +void CounterpartyChannelTransactionParameters_set_selected_contest_delay(struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR this_ptr, uint16_t val); /** - *\n\t * Calculates the overflow safe ending block height for the query.\n\t * Overflow returns `0xffffffff`, otherwise returns `first_blocknum + number_of_blocks`\n\t + * Constructs a new CounterpartyChannelTransactionParameters given each field */ -MUST_USE_RES uint32_t QueryChannelRange_end_blocknum(const struct LDKQueryChannelRange *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCounterpartyChannelTransactionParameters CounterpartyChannelTransactionParameters_new(struct LDKChannelPublicKeys pubkeys_arg, uint16_t selected_contest_delay_arg); /** - * Serialize the QueryChannelRange object into a byte array which can be read by QueryChannelRange_read + * Creates a copy of the CounterpartyChannelTransactionParameters */ -struct LDKCVec_u8Z QueryChannelRange_write(const struct LDKQueryChannelRange *NONNULL_PTR obj); +struct LDKCounterpartyChannelTransactionParameters CounterpartyChannelTransactionParameters_clone(const struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR orig); /** - * Read a QueryChannelRange from a byte array, created by QueryChannelRange_write + * Whether the late bound parameters are populated. */ -struct LDKCResult_QueryChannelRangeDecodeErrorZ QueryChannelRange_read(struct LDKu8slice ser); +MUST_USE_RES bool ChannelTransactionParameters_is_populated(const struct LDKChannelTransactionParameters *NONNULL_PTR this_arg); /** - * Read a ReplyChannelRange from a byte array, created by ReplyChannelRange_write + * Convert the holder/counterparty parameters to broadcaster/countersignatory-organized parameters, + * given that the holder is the broadcaster. + * + * self.is_populated() must be true before calling this function. */ -struct LDKCResult_ReplyChannelRangeDecodeErrorZ ReplyChannelRange_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKDirectedChannelTransactionParameters ChannelTransactionParameters_as_holder_broadcastable(const struct LDKChannelTransactionParameters *NONNULL_PTR this_arg); /** - * Serialize the ReplyChannelRange object into a byte array which can be read by ReplyChannelRange_read + * Convert the holder/counterparty parameters to broadcaster/countersignatory-organized parameters, + * given that the counterparty is the broadcaster. + * + * self.is_populated() must be true before calling this function. */ -struct LDKCVec_u8Z ReplyChannelRange_write(const struct LDKReplyChannelRange *NONNULL_PTR obj); +MUST_USE_RES struct LDKDirectedChannelTransactionParameters ChannelTransactionParameters_as_counterparty_broadcastable(const struct LDKChannelTransactionParameters *NONNULL_PTR this_arg); /** - * Serialize the GossipTimestampFilter object into a byte array which can be read by GossipTimestampFilter_read + * Serialize the CounterpartyChannelTransactionParameters object into a byte array which can be read by CounterpartyChannelTransactionParameters_read */ -struct LDKCVec_u8Z GossipTimestampFilter_write(const struct LDKGossipTimestampFilter *NONNULL_PTR obj); +struct LDKCVec_u8Z CounterpartyChannelTransactionParameters_write(const struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR obj); /** - * Read a GossipTimestampFilter from a byte array, created by GossipTimestampFilter_write + * Read a CounterpartyChannelTransactionParameters from a byte array, created by CounterpartyChannelTransactionParameters_write */ -struct LDKCResult_GossipTimestampFilterDecodeErrorZ GossipTimestampFilter_read(struct LDKu8slice ser); +struct LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ CounterpartyChannelTransactionParameters_read(struct LDKu8slice ser); /** - * Calls the free function if one is set + * Serialize the ChannelTransactionParameters object into a byte array which can be read by ChannelTransactionParameters_read */ -void CustomMessageHandler_free(struct LDKCustomMessageHandler this_ptr); +struct LDKCVec_u8Z ChannelTransactionParameters_write(const struct LDKChannelTransactionParameters *NONNULL_PTR obj); /** - * Frees any resources used by the IgnoringMessageHandler, if is_owned is set and inner is non-NULL. + * Read a ChannelTransactionParameters from a byte array, created by ChannelTransactionParameters_write */ -void IgnoringMessageHandler_free(struct LDKIgnoringMessageHandler this_obj); +struct LDKCResult_ChannelTransactionParametersDecodeErrorZ ChannelTransactionParameters_read(struct LDKu8slice ser); /** - * Constructs a new IgnoringMessageHandler given each field + * Frees any resources used by the DirectedChannelTransactionParameters, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKIgnoringMessageHandler IgnoringMessageHandler_new(void); +void DirectedChannelTransactionParameters_free(struct LDKDirectedChannelTransactionParameters this_obj); /** - * Constructs a new MessageSendEventsProvider which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned MessageSendEventsProvider must be freed before this_arg is + * Get the channel pubkeys for the broadcaster */ -struct LDKMessageSendEventsProvider IgnoringMessageHandler_as_MessageSendEventsProvider(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKChannelPublicKeys DirectedChannelTransactionParameters_broadcaster_pubkeys(const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR this_arg); /** - * Constructs a new RoutingMessageHandler which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned RoutingMessageHandler must be freed before this_arg is + * Get the channel pubkeys for the countersignatory */ -struct LDKRoutingMessageHandler IgnoringMessageHandler_as_RoutingMessageHandler(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKChannelPublicKeys DirectedChannelTransactionParameters_countersignatory_pubkeys(const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR this_arg); /** - * Constructs a new CustomMessageReader which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned CustomMessageReader must be freed before this_arg is + * Get the contest delay applicable to the transactions. + * Note that the contest delay was selected by the countersignatory. */ -struct LDKCustomMessageReader IgnoringMessageHandler_as_CustomMessageReader(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); +MUST_USE_RES uint16_t DirectedChannelTransactionParameters_contest_delay(const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR this_arg); /** - * Constructs a new CustomMessageHandler which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned CustomMessageHandler must be freed before this_arg is + * Whether the channel is outbound from the broadcaster. + * + * The boolean representing the side that initiated the channel is + * an input to the commitment number obscure factor computation. */ -struct LDKCustomMessageHandler IgnoringMessageHandler_as_CustomMessageHandler(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); +MUST_USE_RES bool DirectedChannelTransactionParameters_is_outbound(const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR this_arg); /** - * Frees any resources used by the ErroringMessageHandler, if is_owned is set and inner is non-NULL. + * The funding outpoint */ -void ErroringMessageHandler_free(struct LDKErroringMessageHandler this_obj); +MUST_USE_RES struct LDKOutPoint DirectedChannelTransactionParameters_funding_outpoint(const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR this_arg); /** - * Constructs a new ErroringMessageHandler + * Whether to use anchors for this channel */ -MUST_USE_RES struct LDKErroringMessageHandler ErroringMessageHandler_new(void); +MUST_USE_RES bool DirectedChannelTransactionParameters_opt_anchors(const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR this_arg); /** - * Constructs a new MessageSendEventsProvider which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned MessageSendEventsProvider must be freed before this_arg is + * Frees any resources used by the HolderCommitmentTransaction, if is_owned is set and inner is non-NULL. */ -struct LDKMessageSendEventsProvider ErroringMessageHandler_as_MessageSendEventsProvider(const struct LDKErroringMessageHandler *NONNULL_PTR this_arg); +void HolderCommitmentTransaction_free(struct LDKHolderCommitmentTransaction this_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 + * Our counterparty's signature for the transaction */ -struct LDKChannelMessageHandler ErroringMessageHandler_as_ChannelMessageHandler(const struct LDKErroringMessageHandler *NONNULL_PTR this_arg); +struct LDKSignature HolderCommitmentTransaction_get_counterparty_sig(const struct LDKHolderCommitmentTransaction *NONNULL_PTR this_ptr); /** - * Frees any resources used by the MessageHandler, if is_owned is set and inner is non-NULL. + * Our counterparty's signature for the transaction */ -void MessageHandler_free(struct LDKMessageHandler this_obj); +void HolderCommitmentTransaction_set_counterparty_sig(struct LDKHolderCommitmentTransaction *NONNULL_PTR this_ptr, struct LDKSignature val); /** - * A message handler which handles messages specific to channels. Usually this is just a - * [`ChannelManager`] object or an [`ErroringMessageHandler`]. + * All non-dust counterparty HTLC signatures, in the order they appear in the transaction * - * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager + * Returns a copy of the field. */ -const struct LDKChannelMessageHandler *MessageHandler_get_chan_handler(const struct LDKMessageHandler *NONNULL_PTR this_ptr); +struct LDKCVec_SignatureZ HolderCommitmentTransaction_get_counterparty_htlc_sigs(const struct LDKHolderCommitmentTransaction *NONNULL_PTR this_ptr); /** - * A message handler which handles messages specific to channels. Usually this is just a - * [`ChannelManager`] object or an [`ErroringMessageHandler`]. - * - * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager + * All non-dust counterparty HTLC signatures, in the order they appear in the transaction */ -void MessageHandler_set_chan_handler(struct LDKMessageHandler *NONNULL_PTR this_ptr, struct LDKChannelMessageHandler val); +void HolderCommitmentTransaction_set_counterparty_htlc_sigs(struct LDKHolderCommitmentTransaction *NONNULL_PTR this_ptr, struct LDKCVec_SignatureZ val); /** - * A message handler which handles messages updating our knowledge of the network channel - * graph. Usually this is just a [`NetGraphMsgHandler`] object or an - * [`IgnoringMessageHandler`]. - * - * [`NetGraphMsgHandler`]: crate::routing::network_graph::NetGraphMsgHandler + * Creates a copy of the HolderCommitmentTransaction */ -const struct LDKRoutingMessageHandler *MessageHandler_get_route_handler(const struct LDKMessageHandler *NONNULL_PTR this_ptr); +struct LDKHolderCommitmentTransaction HolderCommitmentTransaction_clone(const struct LDKHolderCommitmentTransaction *NONNULL_PTR orig); /** - * A message handler which handles messages updating our knowledge of the network channel - * graph. Usually this is just a [`NetGraphMsgHandler`] object or an - * [`IgnoringMessageHandler`]. - * - * [`NetGraphMsgHandler`]: crate::routing::network_graph::NetGraphMsgHandler + * Serialize the HolderCommitmentTransaction object into a byte array which can be read by HolderCommitmentTransaction_read */ -void MessageHandler_set_route_handler(struct LDKMessageHandler *NONNULL_PTR this_ptr, struct LDKRoutingMessageHandler val); +struct LDKCVec_u8Z HolderCommitmentTransaction_write(const struct LDKHolderCommitmentTransaction *NONNULL_PTR obj); /** - * Constructs a new MessageHandler given each field + * Read a HolderCommitmentTransaction from a byte array, created by HolderCommitmentTransaction_write */ -MUST_USE_RES struct LDKMessageHandler MessageHandler_new(struct LDKChannelMessageHandler chan_handler_arg, struct LDKRoutingMessageHandler route_handler_arg); +struct LDKCResult_HolderCommitmentTransactionDecodeErrorZ HolderCommitmentTransaction_read(struct LDKu8slice ser); /** - * Creates a copy of a SocketDescriptor + * Create a new holder transaction with the given counterparty signatures. + * The funding keys are used to figure out which signature should go first when building the transaction for broadcast. */ -struct LDKSocketDescriptor SocketDescriptor_clone(const struct LDKSocketDescriptor *NONNULL_PTR orig); +MUST_USE_RES struct LDKHolderCommitmentTransaction HolderCommitmentTransaction_new(struct LDKCommitmentTransaction commitment_tx, struct LDKSignature counterparty_sig, struct LDKCVec_SignatureZ counterparty_htlc_sigs, struct LDKPublicKey holder_funding_key, struct LDKPublicKey counterparty_funding_key); /** - * Calls the free function if one is set + * Frees any resources used by the BuiltCommitmentTransaction, if is_owned is set and inner is non-NULL. */ -void SocketDescriptor_free(struct LDKSocketDescriptor this_ptr); +void BuiltCommitmentTransaction_free(struct LDKBuiltCommitmentTransaction this_obj); /** - * Frees any resources used by the PeerHandleError, if is_owned is set and inner is non-NULL. + * The commitment transaction */ -void PeerHandleError_free(struct LDKPeerHandleError this_obj); +struct LDKTransaction BuiltCommitmentTransaction_get_transaction(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_ptr); /** - * Used to indicate that we probably can't make any future connections to this peer, implying - * we should go ahead and force-close any channels we have with it. + * The commitment transaction */ -bool PeerHandleError_get_no_connection_possible(const struct LDKPeerHandleError *NONNULL_PTR this_ptr); +void BuiltCommitmentTransaction_set_transaction(struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_ptr, struct LDKTransaction val); /** - * Used to indicate that we probably can't make any future connections to this peer, implying - * we should go ahead and force-close any channels we have with it. + * The txid for the commitment transaction. + * + * This is provided as a performance optimization, instead of calling transaction.txid() + * multiple times. */ -void PeerHandleError_set_no_connection_possible(struct LDKPeerHandleError *NONNULL_PTR this_ptr, bool val); +const uint8_t (*BuiltCommitmentTransaction_get_txid(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_ptr))[32]; /** - * Constructs a new PeerHandleError given each field + * The txid for the commitment transaction. + * + * This is provided as a performance optimization, instead of calling transaction.txid() + * multiple times. */ -MUST_USE_RES struct LDKPeerHandleError PeerHandleError_new(bool no_connection_possible_arg); +void BuiltCommitmentTransaction_set_txid(struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Creates a copy of the PeerHandleError + * Constructs a new BuiltCommitmentTransaction given each field */ -struct LDKPeerHandleError PeerHandleError_clone(const struct LDKPeerHandleError *NONNULL_PTR orig); +MUST_USE_RES struct LDKBuiltCommitmentTransaction BuiltCommitmentTransaction_new(struct LDKTransaction transaction_arg, struct LDKThirtyTwoBytes txid_arg); /** - * Frees any resources used by the PeerManager, if is_owned is set and inner is non-NULL. + * Creates a copy of the BuiltCommitmentTransaction */ -void PeerManager_free(struct LDKPeerManager this_obj); +struct LDKBuiltCommitmentTransaction BuiltCommitmentTransaction_clone(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR orig); /** - * Constructs a new PeerManager with the given message handlers and node_id secret key - * ephemeral_random_data is used to derive per-connection ephemeral keys and must be - * cryptographically secure random bytes. + * Serialize the BuiltCommitmentTransaction object into a byte array which can be read by BuiltCommitmentTransaction_read */ -MUST_USE_RES struct LDKPeerManager PeerManager_new(struct LDKMessageHandler message_handler, struct LDKSecretKey our_node_secret, const uint8_t (*ephemeral_random_data)[32], struct LDKLogger logger, struct LDKCustomMessageHandler custom_message_handler); +struct LDKCVec_u8Z BuiltCommitmentTransaction_write(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR obj); /** - * Get the list of node ids for peers which have completed the initial handshake. - * - * For outbound connections, this will be the same as the their_node_id parameter passed in to - * new_outbound_connection, however entries will only appear once the initial handshake has - * completed and we are sure the remote peer has the private key for the given node_id. + * Read a BuiltCommitmentTransaction from a byte array, created by BuiltCommitmentTransaction_write */ -MUST_USE_RES struct LDKCVec_PublicKeyZ PeerManager_get_peer_node_ids(const struct LDKPeerManager *NONNULL_PTR this_arg); +struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ BuiltCommitmentTransaction_read(struct LDKu8slice ser); /** - * Indicates a new outbound connection has been established to a node with the given node_id. - * Note that if an Err is returned here you MUST NOT call socket_disconnected for the new - * descriptor but must disconnect the connection immediately. - * - * Returns a small number of bytes to send to the remote node (currently always 50). - * - * Panics if descriptor is duplicative with some other descriptor which has not yet been - * [`socket_disconnected()`]. + * Get the SIGHASH_ALL sighash value of the transaction. * - * [`socket_disconnected()`]: PeerManager::socket_disconnected + * This can be used to verify a signature. */ -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 LDKThirtyTwoBytes BuiltCommitmentTransaction_get_sighash_all(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_arg, struct LDKu8slice funding_redeemscript, uint64_t channel_value_satoshis); /** - * Indicates a new inbound connection has been established. - * - * 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 - * call socket_disconnected for the new descriptor but must disconnect the connection - * immediately. - * - * Panics if descriptor is duplicative with some other descriptor which has not yet been - * [`socket_disconnected()`]. - * - * [`socket_disconnected()`]: PeerManager::socket_disconnected + * Sign a transaction, either because we are counter-signing the counterparty's transaction or + * because we are about to broadcast a holder transaction. */ -MUST_USE_RES struct LDKCResult_NonePeerHandleErrorZ PeerManager_new_inbound_connection(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKSocketDescriptor descriptor); +MUST_USE_RES struct LDKSignature BuiltCommitmentTransaction_sign(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_arg, const uint8_t (*funding_key)[32], struct LDKu8slice funding_redeemscript, uint64_t channel_value_satoshis); /** - * Indicates that there is room to write data to the given socket descriptor. - * - * May return an Err to indicate that the connection should be closed. - * - * May call [`send_data`] on the descriptor passed in (or an equal descriptor) before - * returning. Thus, be very careful with reentrancy issues! The invariants around calling - * [`write_buffer_space_avail`] in case a write did not fully complete must still hold - be - * ready to call `[write_buffer_space_avail`] again if a write call generated here isn't - * sufficient! - * - * [`send_data`]: SocketDescriptor::send_data - * [`write_buffer_space_avail`]: PeerManager::write_buffer_space_avail + * Frees any resources used by the ClosingTransaction, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKCResult_NonePeerHandleErrorZ PeerManager_write_buffer_space_avail(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKSocketDescriptor *NONNULL_PTR descriptor); +void ClosingTransaction_free(struct LDKClosingTransaction this_obj); /** - * Indicates that data was read from the given socket descriptor. - * - * May return an Err to indicate that the connection should be closed. - * - * Will *not* call back into [`send_data`] on any descriptors to avoid reentrancy complexity. - * Thus, however, you should call [`process_events`] after any `read_event` to generate - * [`send_data`] calls to handle responses. - * - * If `Ok(true)` is returned, further read_events should not be triggered until a - * [`send_data`] call on this descriptor has `resume_read` set (preventing DoS issues in the - * send buffer). - * - * [`send_data`]: SocketDescriptor::send_data - * [`process_events`]: PeerManager::process_events + * Creates a copy of the ClosingTransaction */ -MUST_USE_RES struct LDKCResult_boolPeerHandleErrorZ PeerManager_read_event(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKSocketDescriptor *NONNULL_PTR peer_descriptor, struct LDKu8slice data); +struct LDKClosingTransaction ClosingTransaction_clone(const struct LDKClosingTransaction *NONNULL_PTR orig); /** - * Checks for any events generated by our handlers and processes them. Includes sending most - * response messages as well as messages generated by calls to handler functions directly (eg - * functions like [`ChannelManager::process_pending_htlc_forwards`] or [`send_payment`]). - * - * May call [`send_data`] on [`SocketDescriptor`]s. Thus, be very careful with reentrancy - * issues! - * - * You don't have to call this function explicitly if you are using [`lightning-net-tokio`] - * or one of the other clients provided in our language bindings. - * - * [`send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment - * [`ChannelManager::process_pending_htlc_forwards`]: crate::ln::channelmanager::ChannelManager::process_pending_htlc_forwards - * [`send_data`]: SocketDescriptor::send_data + * Checks if two ClosingTransactions contain equal inner contents. */ -void PeerManager_process_events(const struct LDKPeerManager *NONNULL_PTR this_arg); +uint64_t ClosingTransaction_hash(const struct LDKClosingTransaction *NONNULL_PTR o); /** - * Indicates that the given socket descriptor's connection is now closed. + * Checks if two ClosingTransactions contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void PeerManager_socket_disconnected(const struct LDKPeerManager *NONNULL_PTR this_arg, const struct LDKSocketDescriptor *NONNULL_PTR descriptor); +bool ClosingTransaction_eq(const struct LDKClosingTransaction *NONNULL_PTR a, const struct LDKClosingTransaction *NONNULL_PTR b); /** - * Disconnect a peer given its node id. - * - * Set `no_connection_possible` to true to prevent any further connection with this peer, - * force-closing any channels we have with it. - * - * If a peer is connected, this will call [`disconnect_socket`] on the descriptor for the - * peer. Thus, be very careful about reentrancy issues. - * - * [`disconnect_socket`]: SocketDescriptor::disconnect_socket + * Construct an object of the class */ -void PeerManager_disconnect_by_node_id(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKPublicKey node_id, bool no_connection_possible); +MUST_USE_RES struct LDKClosingTransaction ClosingTransaction_new(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); /** - * Disconnects all currently-connected peers. This is useful on platforms where there may be - * an indication that TCP sockets have stalled even if we weren't around to time them out - * using regular ping/pongs. + * Trust our pre-built transaction. + * + * Applies a wrapper which allows access to the transaction. + * + * This should only be used if you fully trust the builder of this object. It should not + * be used by an external signer - instead use the verify function. */ -void PeerManager_disconnect_all_peers(const struct LDKPeerManager *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKTrustedClosingTransaction ClosingTransaction_trust(const struct LDKClosingTransaction *NONNULL_PTR this_arg); /** - * 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. + * Verify our pre-built transaction. * - * May call [`send_data`] on all [`SocketDescriptor`]s. Thus, be very careful with reentrancy - * issues! + * Applies a wrapper which allows access to the transaction. * - * [`send_data`]: SocketDescriptor::send_data + * An external validating signer must call this method before signing + * or using the built transaction. */ -void PeerManager_timer_tick_occurred(const struct LDKPeerManager *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_TrustedClosingTransactionNoneZ ClosingTransaction_verify(const struct LDKClosingTransaction *NONNULL_PTR this_arg, struct LDKOutPoint funding_outpoint); /** - * Gets the weight for an HTLC-Success transaction. + * The value to be sent to the holder, or zero if the output will be omitted */ -uint64_t htlc_success_tx_weight(bool opt_anchors); +MUST_USE_RES uint64_t ClosingTransaction_to_holder_value_sat(const struct LDKClosingTransaction *NONNULL_PTR this_arg); /** - * Gets the weight for an HTLC-Timeout transaction. + * The value to be sent to the counterparty, or zero if the output will be omitted */ -uint64_t htlc_timeout_tx_weight(bool opt_anchors); +MUST_USE_RES uint64_t ClosingTransaction_to_counterparty_value_sat(const struct LDKClosingTransaction *NONNULL_PTR this_arg); /** - * Build the commitment secret from the seed and the commitment number + * The destination of the holder's output */ -struct LDKThirtyTwoBytes build_commitment_secret(const uint8_t (*commitment_seed)[32], uint64_t idx); +MUST_USE_RES struct LDKu8slice ClosingTransaction_to_holder_script(const struct LDKClosingTransaction *NONNULL_PTR this_arg); /** - * Build a closing transaction + * The destination of the counterparty's output */ -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); +MUST_USE_RES struct LDKu8slice ClosingTransaction_to_counterparty_script(const struct LDKClosingTransaction *NONNULL_PTR this_arg); /** - * Frees any resources used by the CounterpartyCommitmentSecrets, if is_owned is set and inner is non-NULL. + * Frees any resources used by the TrustedClosingTransaction, if is_owned is set and inner is non-NULL. */ -void CounterpartyCommitmentSecrets_free(struct LDKCounterpartyCommitmentSecrets this_obj); +void TrustedClosingTransaction_free(struct LDKTrustedClosingTransaction this_obj); /** - * Creates a copy of the CounterpartyCommitmentSecrets + * The pre-built Bitcoin commitment transaction */ -struct LDKCounterpartyCommitmentSecrets CounterpartyCommitmentSecrets_clone(const struct LDKCounterpartyCommitmentSecrets *NONNULL_PTR orig); +MUST_USE_RES struct LDKTransaction TrustedClosingTransaction_built_transaction(const struct LDKTrustedClosingTransaction *NONNULL_PTR this_arg); /** - * Creates a new empty `CounterpartyCommitmentSecrets` structure. + * Get the SIGHASH_ALL sighash value of the transaction. + * + * This can be used to verify a signature. */ -MUST_USE_RES struct LDKCounterpartyCommitmentSecrets CounterpartyCommitmentSecrets_new(void); +MUST_USE_RES struct LDKThirtyTwoBytes TrustedClosingTransaction_get_sighash_all(const struct LDKTrustedClosingTransaction *NONNULL_PTR this_arg, struct LDKu8slice funding_redeemscript, uint64_t channel_value_satoshis); + +/** + * Sign a transaction, either because we are counter-signing the counterparty's transaction or + * because we are about to broadcast a holder transaction. + */ +MUST_USE_RES struct LDKSignature TrustedClosingTransaction_sign(const struct LDKTrustedClosingTransaction *NONNULL_PTR this_arg, const uint8_t (*funding_key)[32], struct LDKu8slice funding_redeemscript, uint64_t channel_value_satoshis); /** - * Returns the minimum index of all stored secrets. Note that indexes start - * at 1 << 48 and get decremented by one for each new secret. + * Frees any resources used by the CommitmentTransaction, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES uint64_t CounterpartyCommitmentSecrets_get_min_seen_secret(const struct LDKCounterpartyCommitmentSecrets *NONNULL_PTR this_arg); +void CommitmentTransaction_free(struct LDKCommitmentTransaction this_obj); /** - * Inserts the `secret` at `idx`. Returns `Ok(())` if the secret - * was generated in accordance with BOLT 3 and is consistent with previous secrets. + * Creates a copy of the CommitmentTransaction */ -MUST_USE_RES struct LDKCResult_NoneNoneZ CounterpartyCommitmentSecrets_provide_secret(struct LDKCounterpartyCommitmentSecrets *NONNULL_PTR this_arg, uint64_t idx, struct LDKThirtyTwoBytes secret); +struct LDKCommitmentTransaction CommitmentTransaction_clone(const struct LDKCommitmentTransaction *NONNULL_PTR orig); /** - * 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 + * Serialize the CommitmentTransaction object into a byte array which can be read by CommitmentTransaction_read */ -MUST_USE_RES struct LDKThirtyTwoBytes CounterpartyCommitmentSecrets_get_secret(const struct LDKCounterpartyCommitmentSecrets *NONNULL_PTR this_arg, uint64_t idx); +struct LDKCVec_u8Z CommitmentTransaction_write(const struct LDKCommitmentTransaction *NONNULL_PTR obj); /** - * Serialize the CounterpartyCommitmentSecrets object into a byte array which can be read by CounterpartyCommitmentSecrets_read + * Read a CommitmentTransaction from a byte array, created by CommitmentTransaction_write */ -struct LDKCVec_u8Z CounterpartyCommitmentSecrets_write(const struct LDKCounterpartyCommitmentSecrets *NONNULL_PTR obj); +struct LDKCResult_CommitmentTransactionDecodeErrorZ CommitmentTransaction_read(struct LDKu8slice ser); /** - * Read a CounterpartyCommitmentSecrets from a byte array, created by CounterpartyCommitmentSecrets_write + * The backwards-counting commitment number */ -struct LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ CounterpartyCommitmentSecrets_read(struct LDKu8slice ser); +MUST_USE_RES uint64_t CommitmentTransaction_commitment_number(const struct LDKCommitmentTransaction *NONNULL_PTR this_arg); /** - * Derives a per-commitment-transaction private key (eg an htlc key or delayed_payment key) - * from the base secret and the per_commitment_point. - * - * Note that this is infallible iff we trust that at least one of the two input keys are randomly - * generated (ie our own). + * The value to be sent to the broadcaster */ -struct LDKCResult_SecretKeyErrorZ derive_private_key(struct LDKPublicKey per_commitment_point, const uint8_t (*base_secret)[32]); +MUST_USE_RES uint64_t CommitmentTransaction_to_broadcaster_value_sat(const struct LDKCommitmentTransaction *NONNULL_PTR this_arg); /** - * Derives a per-commitment-transaction public key (eg an htlc key or a delayed_payment key) - * from the base point and the per_commitment_key. This is the public equivalent of - * derive_private_key - using only public keys to derive a public key instead of private keys. - * - * Note that this is infallible iff we trust that at least one of the two input keys are randomly - * generated (ie our own). + * The value to be sent to the counterparty */ -struct LDKCResult_PublicKeyErrorZ derive_public_key(struct LDKPublicKey per_commitment_point, struct LDKPublicKey base_point); +MUST_USE_RES uint64_t CommitmentTransaction_to_countersignatory_value_sat(const struct LDKCommitmentTransaction *NONNULL_PTR this_arg); /** - * Derives a per-commitment-transaction revocation key from its constituent parts. - * - * Only the cheating participant owns a valid witness to propagate a revoked - * commitment transaction, thus per_commitment_secret always come from cheater - * and revocation_base_secret always come from punisher, which is the broadcaster - * of the transaction spending with this key knowledge. - * - * Note that this is infallible iff we trust that at least one of the two input keys are randomly - * generated (ie our own). + * The feerate paid per 1000-weight-unit in this commitment transaction. */ -struct LDKCResult_SecretKeyErrorZ derive_private_revocation_key(const uint8_t (*per_commitment_secret)[32], const uint8_t (*countersignatory_revocation_base_secret)[32]); +MUST_USE_RES uint32_t CommitmentTransaction_feerate_per_kw(const struct LDKCommitmentTransaction *NONNULL_PTR this_arg); /** - * Derives a per-commitment-transaction revocation public key from its constituent parts. This is - * the public equivalend of derive_private_revocation_key - using only public keys to derive a - * public key instead of private keys. + * Trust our pre-built transaction and derived transaction creation public keys. * - * Only the cheating participant owns a valid witness to propagate a revoked - * commitment transaction, thus per_commitment_point always come from cheater - * and revocation_base_point always come from punisher, which is the broadcaster - * of the transaction spending with this key knowledge. + * Applies a wrapper which allows access to these fields. * - * Note that this is infallible iff we trust that at least one of the two input keys are randomly - * generated (ie our own). + * This should only be used if you fully trust the builder of this object. It should not + * be used by an external signer - instead use the verify function. */ -struct LDKCResult_PublicKeyErrorZ derive_public_revocation_key(struct LDKPublicKey per_commitment_point, struct LDKPublicKey countersignatory_revocation_base_point); +MUST_USE_RES struct LDKTrustedCommitmentTransaction CommitmentTransaction_trust(const struct LDKCommitmentTransaction *NONNULL_PTR this_arg); /** - * Frees any resources used by the TxCreationKeys, if is_owned is set and inner is non-NULL. + * Verify our pre-built transaction and derived transaction creation public keys. + * + * Applies a wrapper which allows access to these fields. + * + * An external validating signer must call this method before signing + * or using the built transaction. */ -void TxCreationKeys_free(struct LDKTxCreationKeys this_obj); +MUST_USE_RES struct LDKCResult_TrustedCommitmentTransactionNoneZ CommitmentTransaction_verify(const struct LDKCommitmentTransaction *NONNULL_PTR this_arg, const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR channel_parameters, const struct LDKChannelPublicKeys *NONNULL_PTR broadcaster_keys, const struct LDKChannelPublicKeys *NONNULL_PTR countersignatory_keys); /** - * The broadcaster's per-commitment public key which was used to derive the other keys. + * Frees any resources used by the TrustedCommitmentTransaction, if is_owned is set and inner is non-NULL. */ -struct LDKPublicKey TxCreationKeys_get_per_commitment_point(const struct LDKTxCreationKeys *NONNULL_PTR this_ptr); +void TrustedCommitmentTransaction_free(struct LDKTrustedCommitmentTransaction this_obj); /** - * The broadcaster's per-commitment public key which was used to derive the other keys. + * The transaction ID of the built Bitcoin transaction */ -void TxCreationKeys_set_per_commitment_point(struct LDKTxCreationKeys *NONNULL_PTR this_ptr, struct LDKPublicKey val); +MUST_USE_RES struct LDKThirtyTwoBytes TrustedCommitmentTransaction_txid(const struct LDKTrustedCommitmentTransaction *NONNULL_PTR this_arg); /** - * The revocation key which is used to allow the broadcaster of the commitment - * transaction to provide their counterparty the ability to punish them if they broadcast - * an old state. + * The pre-built Bitcoin commitment transaction */ -struct LDKPublicKey TxCreationKeys_get_revocation_key(const struct LDKTxCreationKeys *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKBuiltCommitmentTransaction TrustedCommitmentTransaction_built_transaction(const struct LDKTrustedCommitmentTransaction *NONNULL_PTR this_arg); /** - * The revocation key which is used to allow the broadcaster of the commitment - * transaction to provide their counterparty the ability to punish them if they broadcast - * an old state. + * The pre-calculated transaction creation public keys. */ -void TxCreationKeys_set_revocation_key(struct LDKTxCreationKeys *NONNULL_PTR this_ptr, struct LDKPublicKey val); +MUST_USE_RES struct LDKTxCreationKeys TrustedCommitmentTransaction_keys(const struct LDKTrustedCommitmentTransaction *NONNULL_PTR this_arg); /** - * Broadcaster's HTLC Key + * Should anchors be used. */ -struct LDKPublicKey TxCreationKeys_get_broadcaster_htlc_key(const struct LDKTxCreationKeys *NONNULL_PTR this_ptr); +MUST_USE_RES bool TrustedCommitmentTransaction_opt_anchors(const struct LDKTrustedCommitmentTransaction *NONNULL_PTR this_arg); /** - * Broadcaster's HTLC Key + * 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 EcdsaSighashType::All. */ -void TxCreationKeys_set_broadcaster_htlc_key(struct LDKTxCreationKeys *NONNULL_PTR this_ptr, struct LDKPublicKey val); +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); /** - * Countersignatory's HTLC Key + * Commitment transaction numbers which appear in the transactions themselves are XOR'd with a + * shared secret first. This prevents on-chain observers from discovering how many commitment + * transactions occurred in a channel before it was closed. + * + * This function gets the shared secret from relevant channel public keys and can be used to + * \"decrypt\" the commitment transaction number given a commitment transaction on-chain. */ -struct LDKPublicKey TxCreationKeys_get_countersignatory_htlc_key(const struct LDKTxCreationKeys *NONNULL_PTR this_ptr); +uint64_t get_commitment_transaction_number_obscure_factor(struct LDKPublicKey broadcaster_payment_basepoint, struct LDKPublicKey countersignatory_payment_basepoint, bool outbound_from_broadcaster); /** - * Countersignatory's HTLC Key + * Checks if two InitFeaturess contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void TxCreationKeys_set_countersignatory_htlc_key(struct LDKTxCreationKeys *NONNULL_PTR this_ptr, struct LDKPublicKey val); +bool InitFeatures_eq(const struct LDKInitFeatures *NONNULL_PTR a, const struct LDKInitFeatures *NONNULL_PTR b); /** - * Broadcaster's Payment Key (which isn't allowed to be spent from for some delay) + * Checks if two NodeFeaturess contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -struct LDKPublicKey TxCreationKeys_get_broadcaster_delayed_payment_key(const struct LDKTxCreationKeys *NONNULL_PTR this_ptr); +bool NodeFeatures_eq(const struct LDKNodeFeatures *NONNULL_PTR a, const struct LDKNodeFeatures *NONNULL_PTR b); /** - * Broadcaster's Payment Key (which isn't allowed to be spent from for some delay) + * Checks if two ChannelFeaturess contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void TxCreationKeys_set_broadcaster_delayed_payment_key(struct LDKTxCreationKeys *NONNULL_PTR this_ptr, struct LDKPublicKey val); +bool ChannelFeatures_eq(const struct LDKChannelFeatures *NONNULL_PTR a, const struct LDKChannelFeatures *NONNULL_PTR b); /** - * Constructs a new TxCreationKeys given each field + * Checks if two InvoiceFeaturess contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -MUST_USE_RES struct LDKTxCreationKeys TxCreationKeys_new(struct LDKPublicKey per_commitment_point_arg, struct LDKPublicKey revocation_key_arg, struct LDKPublicKey broadcaster_htlc_key_arg, struct LDKPublicKey countersignatory_htlc_key_arg, struct LDKPublicKey broadcaster_delayed_payment_key_arg); +bool InvoiceFeatures_eq(const struct LDKInvoiceFeatures *NONNULL_PTR a, const struct LDKInvoiceFeatures *NONNULL_PTR b); /** - * Creates a copy of the TxCreationKeys + * Checks if two ChannelTypeFeaturess contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -struct LDKTxCreationKeys TxCreationKeys_clone(const struct LDKTxCreationKeys *NONNULL_PTR orig); +bool ChannelTypeFeatures_eq(const struct LDKChannelTypeFeatures *NONNULL_PTR a, const struct LDKChannelTypeFeatures *NONNULL_PTR b); /** - * Serialize the TxCreationKeys object into a byte array which can be read by TxCreationKeys_read + * Creates a copy of the InitFeatures */ -struct LDKCVec_u8Z TxCreationKeys_write(const struct LDKTxCreationKeys *NONNULL_PTR obj); +struct LDKInitFeatures InitFeatures_clone(const struct LDKInitFeatures *NONNULL_PTR orig); /** - * Read a TxCreationKeys from a byte array, created by TxCreationKeys_write + * Creates a copy of the NodeFeatures */ -struct LDKCResult_TxCreationKeysDecodeErrorZ TxCreationKeys_read(struct LDKu8slice ser); +struct LDKNodeFeatures NodeFeatures_clone(const struct LDKNodeFeatures *NONNULL_PTR orig); /** - * Frees any resources used by the ChannelPublicKeys, if is_owned is set and inner is non-NULL. + * Creates a copy of the ChannelFeatures */ -void ChannelPublicKeys_free(struct LDKChannelPublicKeys this_obj); +struct LDKChannelFeatures ChannelFeatures_clone(const struct LDKChannelFeatures *NONNULL_PTR orig); /** - * The public key which is used to sign all commitment transactions, as it appears in the - * on-chain channel lock-in 2-of-2 multisig output. + * Creates a copy of the InvoiceFeatures */ -struct LDKPublicKey ChannelPublicKeys_get_funding_pubkey(const struct LDKChannelPublicKeys *NONNULL_PTR this_ptr); +struct LDKInvoiceFeatures InvoiceFeatures_clone(const struct LDKInvoiceFeatures *NONNULL_PTR orig); /** - * The public key which is used to sign all commitment transactions, as it appears in the - * on-chain channel lock-in 2-of-2 multisig output. + * Creates a copy of the ChannelTypeFeatures */ -void ChannelPublicKeys_set_funding_pubkey(struct LDKChannelPublicKeys *NONNULL_PTR this_ptr, struct LDKPublicKey val); +struct LDKChannelTypeFeatures ChannelTypeFeatures_clone(const struct LDKChannelTypeFeatures *NONNULL_PTR orig); /** - * The base point which is used (with derive_public_revocation_key) to derive per-commitment - * revocation keys. This is combined with the per-commitment-secret generated by the - * counterparty to create a secret which the counterparty can reveal to revoke previous - * states. + * Frees any resources used by the InitFeatures, if is_owned is set and inner is non-NULL. */ -struct LDKPublicKey ChannelPublicKeys_get_revocation_basepoint(const struct LDKChannelPublicKeys *NONNULL_PTR this_ptr); +void InitFeatures_free(struct LDKInitFeatures this_obj); /** - * The base point which is used (with derive_public_revocation_key) to derive per-commitment - * revocation keys. This is combined with the per-commitment-secret generated by the - * counterparty to create a secret which the counterparty can reveal to revoke previous - * states. + * Frees any resources used by the NodeFeatures, if is_owned is set and inner is non-NULL. */ -void ChannelPublicKeys_set_revocation_basepoint(struct LDKChannelPublicKeys *NONNULL_PTR this_ptr, struct LDKPublicKey val); +void NodeFeatures_free(struct LDKNodeFeatures this_obj); /** - * The public key on which the non-broadcaster (ie the countersignatory) receives an immediately - * spendable primary channel balance on the broadcaster's commitment transaction. This key is - * static across every commitment transaction. + * Frees any resources used by the ChannelFeatures, if is_owned is set and inner is non-NULL. */ -struct LDKPublicKey ChannelPublicKeys_get_payment_point(const struct LDKChannelPublicKeys *NONNULL_PTR this_ptr); +void ChannelFeatures_free(struct LDKChannelFeatures this_obj); /** - * The public key on which the non-broadcaster (ie the countersignatory) receives an immediately - * spendable primary channel balance on the broadcaster's commitment transaction. This key is - * static across every commitment transaction. + * Frees any resources used by the InvoiceFeatures, if is_owned is set and inner is non-NULL. */ -void ChannelPublicKeys_set_payment_point(struct LDKChannelPublicKeys *NONNULL_PTR this_ptr, struct LDKPublicKey val); +void InvoiceFeatures_free(struct LDKInvoiceFeatures this_obj); /** - * The base point which is used (with derive_public_key) to derive a per-commitment payment - * public key which receives non-HTLC-encumbered funds which are only available for spending - * after some delay (or can be claimed via the revocation path). + * Frees any resources used by the ChannelTypeFeatures, if is_owned is set and inner is non-NULL. */ -struct LDKPublicKey ChannelPublicKeys_get_delayed_payment_basepoint(const struct LDKChannelPublicKeys *NONNULL_PTR this_ptr); +void ChannelTypeFeatures_free(struct LDKChannelTypeFeatures this_obj); /** - * The base point which is used (with derive_public_key) to derive a per-commitment payment - * public key which receives non-HTLC-encumbered funds which are only available for spending - * after some delay (or can be claimed via the revocation path). + * Create a blank Features with no features set */ -void ChannelPublicKeys_set_delayed_payment_basepoint(struct LDKChannelPublicKeys *NONNULL_PTR this_ptr, struct LDKPublicKey val); +MUST_USE_RES struct LDKInitFeatures InitFeatures_empty(void); /** - * The base point which is used (with derive_public_key) to derive a per-commitment public key - * which is used to encumber HTLC-in-flight outputs. + * Returns true if this `Features` object contains unknown feature flags which are set as + * \"required\". */ -struct LDKPublicKey ChannelPublicKeys_get_htlc_basepoint(const struct LDKChannelPublicKeys *NONNULL_PTR this_ptr); +MUST_USE_RES bool InitFeatures_requires_unknown_bits(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * The base point which is used (with derive_public_key) to derive a per-commitment public key - * which is used to encumber HTLC-in-flight outputs. + * Create a blank Features with no features set */ -void ChannelPublicKeys_set_htlc_basepoint(struct LDKChannelPublicKeys *NONNULL_PTR this_ptr, struct LDKPublicKey val); +MUST_USE_RES struct LDKNodeFeatures NodeFeatures_empty(void); /** - * Constructs a new ChannelPublicKeys given each field + * Returns true if this `Features` object contains unknown feature flags which are set as + * \"required\". */ -MUST_USE_RES struct LDKChannelPublicKeys ChannelPublicKeys_new(struct LDKPublicKey funding_pubkey_arg, struct LDKPublicKey revocation_basepoint_arg, struct LDKPublicKey payment_point_arg, struct LDKPublicKey delayed_payment_basepoint_arg, struct LDKPublicKey htlc_basepoint_arg); +MUST_USE_RES bool NodeFeatures_requires_unknown_bits(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the ChannelPublicKeys + * Create a blank Features with no features set */ -struct LDKChannelPublicKeys ChannelPublicKeys_clone(const struct LDKChannelPublicKeys *NONNULL_PTR orig); +MUST_USE_RES struct LDKChannelFeatures ChannelFeatures_empty(void); /** - * Serialize the ChannelPublicKeys object into a byte array which can be read by ChannelPublicKeys_read + * Returns true if this `Features` object contains unknown feature flags which are set as + * \"required\". */ -struct LDKCVec_u8Z ChannelPublicKeys_write(const struct LDKChannelPublicKeys *NONNULL_PTR obj); +MUST_USE_RES bool ChannelFeatures_requires_unknown_bits(const struct LDKChannelFeatures *NONNULL_PTR this_arg); /** - * Read a ChannelPublicKeys from a byte array, created by ChannelPublicKeys_write + * Create a blank Features with no features set */ -struct LDKCResult_ChannelPublicKeysDecodeErrorZ ChannelPublicKeys_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKInvoiceFeatures InvoiceFeatures_empty(void); /** - * Create per-state keys from channel base points and the per-commitment point. - * Key set is asymmetric and can't be used as part of counter-signatory set of transactions. + * Returns true if this `Features` object contains unknown feature flags which are set as + * \"required\". */ -MUST_USE_RES struct LDKCResult_TxCreationKeysErrorZ TxCreationKeys_derive_new(struct LDKPublicKey per_commitment_point, struct LDKPublicKey broadcaster_delayed_payment_base, struct LDKPublicKey broadcaster_htlc_base, struct LDKPublicKey countersignatory_revocation_base, struct LDKPublicKey countersignatory_htlc_base); +MUST_USE_RES bool InvoiceFeatures_requires_unknown_bits(const struct LDKInvoiceFeatures *NONNULL_PTR this_arg); /** - * Generate per-state keys from channel static keys. - * Key set is asymmetric and can't be used as part of counter-signatory set of transactions. + * Create a blank Features with no features set */ -MUST_USE_RES struct LDKCResult_TxCreationKeysErrorZ TxCreationKeys_from_channel_static_keys(struct LDKPublicKey per_commitment_point, const struct LDKChannelPublicKeys *NONNULL_PTR broadcaster_keys, const struct LDKChannelPublicKeys *NONNULL_PTR countersignatory_keys); +MUST_USE_RES struct LDKChannelTypeFeatures ChannelTypeFeatures_empty(void); /** - * A script either spendable by the revocation - * key or the broadcaster_delayed_payment_key and satisfying the relative-locktime OP_CSV constrain. - * Encumbering a `to_holder` output on a commitment transaction or 2nd-stage HTLC transactions. + * Returns true if this `Features` object contains unknown feature flags which are set as + * \"required\". */ -struct LDKCVec_u8Z get_revokeable_redeemscript(struct LDKPublicKey revocation_key, uint16_t contest_delay, struct LDKPublicKey broadcaster_delayed_payment_key); +MUST_USE_RES bool ChannelTypeFeatures_requires_unknown_bits(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the HTLCOutputInCommitment, if is_owned is set and inner is non-NULL. + * Serialize the InitFeatures object into a byte array which can be read by InitFeatures_read */ -void HTLCOutputInCommitment_free(struct LDKHTLCOutputInCommitment this_obj); +struct LDKCVec_u8Z InitFeatures_write(const struct LDKInitFeatures *NONNULL_PTR obj); /** - * Whether the HTLC was \"offered\" (ie outbound in relation to this commitment transaction). - * Note that this is not the same as whether it is ountbound *from us*. To determine that you - * need to compare this value to whether the commitment transaction in question is that of - * the counterparty or our own. + * Read a InitFeatures from a byte array, created by InitFeatures_write */ -bool HTLCOutputInCommitment_get_offered(const struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr); +struct LDKCResult_InitFeaturesDecodeErrorZ InitFeatures_read(struct LDKu8slice ser); /** - * Whether the HTLC was \"offered\" (ie outbound in relation to this commitment transaction). - * Note that this is not the same as whether it is ountbound *from us*. To determine that you - * need to compare this value to whether the commitment transaction in question is that of - * the counterparty or our own. + * Serialize the ChannelFeatures object into a byte array which can be read by ChannelFeatures_read */ -void HTLCOutputInCommitment_set_offered(struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr, bool val); +struct LDKCVec_u8Z ChannelFeatures_write(const struct LDKChannelFeatures *NONNULL_PTR obj); /** - * The value, in msat, of the HTLC. The value as it appears in the commitment transaction is - * this divided by 1000. + * Read a ChannelFeatures from a byte array, created by ChannelFeatures_write */ -uint64_t HTLCOutputInCommitment_get_amount_msat(const struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr); +struct LDKCResult_ChannelFeaturesDecodeErrorZ ChannelFeatures_read(struct LDKu8slice ser); /** - * The value, in msat, of the HTLC. The value as it appears in the commitment transaction is - * this divided by 1000. + * Serialize the NodeFeatures object into a byte array which can be read by NodeFeatures_read */ -void HTLCOutputInCommitment_set_amount_msat(struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr, uint64_t val); +struct LDKCVec_u8Z NodeFeatures_write(const struct LDKNodeFeatures *NONNULL_PTR obj); /** - * The CLTV lock-time at which this HTLC expires. + * Read a NodeFeatures from a byte array, created by NodeFeatures_write */ -uint32_t HTLCOutputInCommitment_get_cltv_expiry(const struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr); +struct LDKCResult_NodeFeaturesDecodeErrorZ NodeFeatures_read(struct LDKu8slice ser); /** - * The CLTV lock-time at which this HTLC expires. + * Serialize the InvoiceFeatures object into a byte array which can be read by InvoiceFeatures_read */ -void HTLCOutputInCommitment_set_cltv_expiry(struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr, uint32_t val); +struct LDKCVec_u8Z InvoiceFeatures_write(const struct LDKInvoiceFeatures *NONNULL_PTR obj); /** - * The hash of the preimage which unlocks this HTLC. + * Read a InvoiceFeatures from a byte array, created by InvoiceFeatures_write */ -const uint8_t (*HTLCOutputInCommitment_get_payment_hash(const struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr))[32]; +struct LDKCResult_InvoiceFeaturesDecodeErrorZ InvoiceFeatures_read(struct LDKu8slice ser); /** - * The hash of the preimage which unlocks this HTLC. + * Serialize the ChannelTypeFeatures object into a byte array which can be read by ChannelTypeFeatures_read */ -void HTLCOutputInCommitment_set_payment_hash(struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKCVec_u8Z ChannelTypeFeatures_write(const struct LDKChannelTypeFeatures *NONNULL_PTR obj); /** - * The position within the commitment transactions' outputs. This may be None if the value is - * below the dust limit (in which case no output appears in the commitment transaction and the - * value is spent to additional transaction fees). + * Read a ChannelTypeFeatures from a byte array, created by ChannelTypeFeatures_write */ -struct LDKCOption_u32Z HTLCOutputInCommitment_get_transaction_output_index(const struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr); +struct LDKCResult_ChannelTypeFeaturesDecodeErrorZ ChannelTypeFeatures_read(struct LDKu8slice ser); /** - * The position within the commitment transactions' outputs. This may be None if the value is - * below the dust limit (in which case no output appears in the commitment transaction and the - * value is spent to additional transaction fees). + * Set this feature as optional. */ -void HTLCOutputInCommitment_set_transaction_output_index(struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr, struct LDKCOption_u32Z val); +void InitFeatures_set_data_loss_protect_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Constructs a new HTLCOutputInCommitment given each field + * Set this feature as required. */ -MUST_USE_RES struct LDKHTLCOutputInCommitment HTLCOutputInCommitment_new(bool offered_arg, uint64_t amount_msat_arg, uint32_t cltv_expiry_arg, struct LDKThirtyTwoBytes payment_hash_arg, struct LDKCOption_u32Z transaction_output_index_arg); +void InitFeatures_set_data_loss_protect_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the HTLCOutputInCommitment + * Checks if this feature is supported. */ -struct LDKHTLCOutputInCommitment HTLCOutputInCommitment_clone(const struct LDKHTLCOutputInCommitment *NONNULL_PTR orig); +MUST_USE_RES bool InitFeatures_supports_data_loss_protect(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Serialize the HTLCOutputInCommitment object into a byte array which can be read by HTLCOutputInCommitment_read + * Set this feature as optional. */ -struct LDKCVec_u8Z HTLCOutputInCommitment_write(const struct LDKHTLCOutputInCommitment *NONNULL_PTR obj); +void NodeFeatures_set_data_loss_protect_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Read a HTLCOutputInCommitment from a byte array, created by HTLCOutputInCommitment_write + * Set this feature as required. */ -struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ HTLCOutputInCommitment_read(struct LDKu8slice ser); +void NodeFeatures_set_data_loss_protect_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * 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. + * Checks if this feature is supported. */ -struct LDKCVec_u8Z get_htlc_redeemscript(const struct LDKHTLCOutputInCommitment *NONNULL_PTR htlc, bool opt_anchors, const struct LDKTxCreationKeys *NONNULL_PTR keys); +MUST_USE_RES bool NodeFeatures_supports_data_loss_protect(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Gets the redeemscript for a funding output from the two funding public keys. - * Note that the order of funding public keys does not matter. + * Checks if this feature is required. */ -struct LDKCVec_u8Z make_funding_redeemscript(struct LDKPublicKey broadcaster, struct LDKPublicKey countersignatory); +MUST_USE_RES bool InitFeatures_requires_data_loss_protect(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Builds an unsigned HTLC-Success or HTLC-Timeout transaction from the given channel and HTLC - * parameters. This is used by [`TrustedCommitmentTransaction::get_htlc_sigs`] to fetch the - * transaction which needs signing, and can be used to construct an HTLC transaction which is - * broadcastable given a counterparty HTLC signature. - * - * Panics if htlc.transaction_output_index.is_none() (as such HTLCs do not appear in the - * commitment transaction). + * Checks if this feature is required. */ -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); +MUST_USE_RES bool NodeFeatures_requires_data_loss_protect(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * 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) + * Set this feature as optional. */ -struct LDKCVec_u8Z get_anchor_redeemscript(struct LDKPublicKey funding_pubkey); +void InitFeatures_set_initial_routing_sync_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the ChannelTransactionParameters, if is_owned is set and inner is non-NULL. + * Set this feature as required. */ -void ChannelTransactionParameters_free(struct LDKChannelTransactionParameters this_obj); +void InitFeatures_set_initial_routing_sync_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Holder public keys + * Checks if this feature is supported. */ -struct LDKChannelPublicKeys ChannelTransactionParameters_get_holder_pubkeys(const struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr); +MUST_USE_RES bool InitFeatures_initial_routing_sync(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Holder public keys + * Set this feature as optional. */ -void ChannelTransactionParameters_set_holder_pubkeys(struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr, struct LDKChannelPublicKeys val); +void InitFeatures_set_upfront_shutdown_script_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * The contest delay selected by the holder, which applies to counterparty-broadcast transactions + * Set this feature as required. */ -uint16_t ChannelTransactionParameters_get_holder_selected_contest_delay(const struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr); +void InitFeatures_set_upfront_shutdown_script_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * The contest delay selected by the holder, which applies to counterparty-broadcast transactions + * Checks if this feature is supported. */ -void ChannelTransactionParameters_set_holder_selected_contest_delay(struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr, uint16_t val); +MUST_USE_RES bool InitFeatures_supports_upfront_shutdown_script(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Whether the holder is the initiator of this channel. - * This is an input to the commitment number obscure factor computation. + * Set this feature as optional. */ -bool ChannelTransactionParameters_get_is_outbound_from_holder(const struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr); +void NodeFeatures_set_upfront_shutdown_script_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Whether the holder is the initiator of this channel. - * This is an input to the commitment number obscure factor computation. + * Set this feature as required. */ -void ChannelTransactionParameters_set_is_outbound_from_holder(struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr, bool val); +void NodeFeatures_set_upfront_shutdown_script_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * The late-bound counterparty channel transaction parameters. - * These parameters are populated at the point in the protocol where the counterparty provides them. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Checks if this feature is supported. */ -struct LDKCounterpartyChannelTransactionParameters ChannelTransactionParameters_get_counterparty_parameters(const struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr); +MUST_USE_RES bool NodeFeatures_supports_upfront_shutdown_script(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * The late-bound counterparty channel transaction parameters. - * These parameters are populated at the point in the protocol where the counterparty provides them. - * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + * Checks if this feature is required. */ -void ChannelTransactionParameters_set_counterparty_parameters(struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr, struct LDKCounterpartyChannelTransactionParameters val); +MUST_USE_RES bool InitFeatures_requires_upfront_shutdown_script(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * The late-bound funding outpoint - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Checks if this feature is required. */ -struct LDKOutPoint ChannelTransactionParameters_get_funding_outpoint(const struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr); +MUST_USE_RES bool NodeFeatures_requires_upfront_shutdown_script(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * The late-bound funding outpoint - * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + * Set this feature as optional. */ -void ChannelTransactionParameters_set_funding_outpoint(struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr, struct LDKOutPoint val); +void InitFeatures_set_gossip_queries_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Are anchors used for this channel. Boolean is serialization backwards-compatible + * Set this feature as required. */ -enum LDKCOption_NoneZ ChannelTransactionParameters_get_opt_anchors(const struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr); +void InitFeatures_set_gossip_queries_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Are anchors used for this channel. Boolean is serialization backwards-compatible + * Checks if this feature is supported. */ -void ChannelTransactionParameters_set_opt_anchors(struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr, enum LDKCOption_NoneZ val); +MUST_USE_RES bool InitFeatures_supports_gossip_queries(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Constructs a new ChannelTransactionParameters given each field + * Set this feature as optional. */ -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); +void NodeFeatures_set_gossip_queries_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the ChannelTransactionParameters + * Set this feature as required. */ -struct LDKChannelTransactionParameters ChannelTransactionParameters_clone(const struct LDKChannelTransactionParameters *NONNULL_PTR orig); +void NodeFeatures_set_gossip_queries_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the CounterpartyChannelTransactionParameters, if is_owned is set and inner is non-NULL. + * Checks if this feature is supported. */ -void CounterpartyChannelTransactionParameters_free(struct LDKCounterpartyChannelTransactionParameters this_obj); +MUST_USE_RES bool NodeFeatures_supports_gossip_queries(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Counter-party public keys + * Checks if this feature is required. */ -struct LDKChannelPublicKeys CounterpartyChannelTransactionParameters_get_pubkeys(const struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR this_ptr); +MUST_USE_RES bool InitFeatures_requires_gossip_queries(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Counter-party public keys + * Checks if this feature is required. */ -void CounterpartyChannelTransactionParameters_set_pubkeys(struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR this_ptr, struct LDKChannelPublicKeys val); +MUST_USE_RES bool NodeFeatures_requires_gossip_queries(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * The contest delay selected by the counterparty, which applies to holder-broadcast transactions + * Set this feature as optional. */ -uint16_t CounterpartyChannelTransactionParameters_get_selected_contest_delay(const struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR this_ptr); +void InitFeatures_set_variable_length_onion_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * The contest delay selected by the counterparty, which applies to holder-broadcast transactions + * Set this feature as required. */ -void CounterpartyChannelTransactionParameters_set_selected_contest_delay(struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR this_ptr, uint16_t val); +void InitFeatures_set_variable_length_onion_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Constructs a new CounterpartyChannelTransactionParameters given each field + * Checks if this feature is supported. */ -MUST_USE_RES struct LDKCounterpartyChannelTransactionParameters CounterpartyChannelTransactionParameters_new(struct LDKChannelPublicKeys pubkeys_arg, uint16_t selected_contest_delay_arg); +MUST_USE_RES bool InitFeatures_supports_variable_length_onion(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the CounterpartyChannelTransactionParameters + * Set this feature as optional. */ -struct LDKCounterpartyChannelTransactionParameters CounterpartyChannelTransactionParameters_clone(const struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR orig); +void NodeFeatures_set_variable_length_onion_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Whether the late bound parameters are populated. + * Set this feature as required. */ -MUST_USE_RES bool ChannelTransactionParameters_is_populated(const struct LDKChannelTransactionParameters *NONNULL_PTR this_arg); +void NodeFeatures_set_variable_length_onion_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Convert the holder/counterparty parameters to broadcaster/countersignatory-organized parameters, - * given that the holder is the broadcaster. - * - * self.is_populated() must be true before calling this function. + * Checks if this feature is supported. */ -MUST_USE_RES struct LDKDirectedChannelTransactionParameters ChannelTransactionParameters_as_holder_broadcastable(const struct LDKChannelTransactionParameters *NONNULL_PTR this_arg); +MUST_USE_RES bool NodeFeatures_supports_variable_length_onion(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Convert the holder/counterparty parameters to broadcaster/countersignatory-organized parameters, - * given that the counterparty is the broadcaster. - * - * self.is_populated() must be true before calling this function. + * Set this feature as optional. */ -MUST_USE_RES struct LDKDirectedChannelTransactionParameters ChannelTransactionParameters_as_counterparty_broadcastable(const struct LDKChannelTransactionParameters *NONNULL_PTR this_arg); +void InvoiceFeatures_set_variable_length_onion_optional(struct LDKInvoiceFeatures *NONNULL_PTR this_arg); /** - * Serialize the CounterpartyChannelTransactionParameters object into a byte array which can be read by CounterpartyChannelTransactionParameters_read + * Set this feature as required. */ -struct LDKCVec_u8Z CounterpartyChannelTransactionParameters_write(const struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR obj); +void InvoiceFeatures_set_variable_length_onion_required(struct LDKInvoiceFeatures *NONNULL_PTR this_arg); /** - * Read a CounterpartyChannelTransactionParameters from a byte array, created by CounterpartyChannelTransactionParameters_write + * Checks if this feature is supported. */ -struct LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ CounterpartyChannelTransactionParameters_read(struct LDKu8slice ser); +MUST_USE_RES bool InvoiceFeatures_supports_variable_length_onion(const struct LDKInvoiceFeatures *NONNULL_PTR this_arg); /** - * Serialize the ChannelTransactionParameters object into a byte array which can be read by ChannelTransactionParameters_read + * Checks if this feature is required. */ -struct LDKCVec_u8Z ChannelTransactionParameters_write(const struct LDKChannelTransactionParameters *NONNULL_PTR obj); +MUST_USE_RES bool InitFeatures_requires_variable_length_onion(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Read a ChannelTransactionParameters from a byte array, created by ChannelTransactionParameters_write + * Checks if this feature is required. */ -struct LDKCResult_ChannelTransactionParametersDecodeErrorZ ChannelTransactionParameters_read(struct LDKu8slice ser); +MUST_USE_RES bool NodeFeatures_requires_variable_length_onion(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the DirectedChannelTransactionParameters, if is_owned is set and inner is non-NULL. + * Checks if this feature is required. */ -void DirectedChannelTransactionParameters_free(struct LDKDirectedChannelTransactionParameters this_obj); +MUST_USE_RES bool InvoiceFeatures_requires_variable_length_onion(const struct LDKInvoiceFeatures *NONNULL_PTR this_arg); /** - * Get the channel pubkeys for the broadcaster + * Set this feature as optional. */ -MUST_USE_RES struct LDKChannelPublicKeys DirectedChannelTransactionParameters_broadcaster_pubkeys(const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR this_arg); +void InitFeatures_set_static_remote_key_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Get the channel pubkeys for the countersignatory + * Set this feature as required. */ -MUST_USE_RES struct LDKChannelPublicKeys DirectedChannelTransactionParameters_countersignatory_pubkeys(const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR this_arg); +void InitFeatures_set_static_remote_key_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Get the contest delay applicable to the transactions. - * Note that the contest delay was selected by the countersignatory. + * Checks if this feature is supported. */ -MUST_USE_RES uint16_t DirectedChannelTransactionParameters_contest_delay(const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR this_arg); +MUST_USE_RES bool InitFeatures_supports_static_remote_key(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Whether the channel is outbound from the broadcaster. - * - * The boolean representing the side that initiated the channel is - * an input to the commitment number obscure factor computation. + * Set this feature as optional. */ -MUST_USE_RES bool DirectedChannelTransactionParameters_is_outbound(const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR this_arg); +void NodeFeatures_set_static_remote_key_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * The funding outpoint + * Set this feature as required. */ -MUST_USE_RES struct LDKOutPoint DirectedChannelTransactionParameters_funding_outpoint(const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR this_arg); +void NodeFeatures_set_static_remote_key_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Whether to use anchors for this channel + * Checks if this feature is supported. */ -MUST_USE_RES bool DirectedChannelTransactionParameters_opt_anchors(const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR this_arg); +MUST_USE_RES bool NodeFeatures_supports_static_remote_key(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the HolderCommitmentTransaction, if is_owned is set and inner is non-NULL. + * Set this feature as optional. */ -void HolderCommitmentTransaction_free(struct LDKHolderCommitmentTransaction this_obj); +void ChannelTypeFeatures_set_static_remote_key_optional(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Our counterparty's signature for the transaction + * Set this feature as required. */ -struct LDKSignature HolderCommitmentTransaction_get_counterparty_sig(const struct LDKHolderCommitmentTransaction *NONNULL_PTR this_ptr); +void ChannelTypeFeatures_set_static_remote_key_required(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Our counterparty's signature for the transaction + * Checks if this feature is supported. */ -void HolderCommitmentTransaction_set_counterparty_sig(struct LDKHolderCommitmentTransaction *NONNULL_PTR this_ptr, struct LDKSignature val); +MUST_USE_RES bool ChannelTypeFeatures_supports_static_remote_key(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * All non-dust counterparty HTLC signatures, in the order they appear in the transaction + * Checks if this feature is required. */ -void HolderCommitmentTransaction_set_counterparty_htlc_sigs(struct LDKHolderCommitmentTransaction *NONNULL_PTR this_ptr, struct LDKCVec_SignatureZ val); +MUST_USE_RES bool InitFeatures_requires_static_remote_key(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the HolderCommitmentTransaction + * Checks if this feature is required. */ -struct LDKHolderCommitmentTransaction HolderCommitmentTransaction_clone(const struct LDKHolderCommitmentTransaction *NONNULL_PTR orig); +MUST_USE_RES bool NodeFeatures_requires_static_remote_key(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Serialize the HolderCommitmentTransaction object into a byte array which can be read by HolderCommitmentTransaction_read + * Checks if this feature is required. */ -struct LDKCVec_u8Z HolderCommitmentTransaction_write(const struct LDKHolderCommitmentTransaction *NONNULL_PTR obj); +MUST_USE_RES bool ChannelTypeFeatures_requires_static_remote_key(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Read a HolderCommitmentTransaction from a byte array, created by HolderCommitmentTransaction_write + * Set this feature as optional. */ -struct LDKCResult_HolderCommitmentTransactionDecodeErrorZ HolderCommitmentTransaction_read(struct LDKu8slice ser); +void InitFeatures_set_payment_secret_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Create a new holder transaction with the given counterparty signatures. - * The funding keys are used to figure out which signature should go first when building the transaction for broadcast. + * Set this feature as required. */ -MUST_USE_RES struct LDKHolderCommitmentTransaction HolderCommitmentTransaction_new(struct LDKCommitmentTransaction commitment_tx, struct LDKSignature counterparty_sig, struct LDKCVec_SignatureZ counterparty_htlc_sigs, struct LDKPublicKey holder_funding_key, struct LDKPublicKey counterparty_funding_key); +void InitFeatures_set_payment_secret_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the BuiltCommitmentTransaction, if is_owned is set and inner is non-NULL. + * Checks if this feature is supported. */ -void BuiltCommitmentTransaction_free(struct LDKBuiltCommitmentTransaction this_obj); +MUST_USE_RES bool InitFeatures_supports_payment_secret(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * The commitment transaction + * Set this feature as optional. */ -struct LDKTransaction BuiltCommitmentTransaction_get_transaction(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_ptr); +void NodeFeatures_set_payment_secret_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * The commitment transaction + * Set this feature as required. */ -void BuiltCommitmentTransaction_set_transaction(struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_ptr, struct LDKTransaction val); +void NodeFeatures_set_payment_secret_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * The txid for the commitment transaction. - * - * This is provided as a performance optimization, instead of calling transaction.txid() - * multiple times. + * Checks if this feature is supported. */ -const uint8_t (*BuiltCommitmentTransaction_get_txid(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_ptr))[32]; +MUST_USE_RES bool NodeFeatures_supports_payment_secret(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * The txid for the commitment transaction. - * - * This is provided as a performance optimization, instead of calling transaction.txid() - * multiple times. + * Set this feature as optional. */ -void BuiltCommitmentTransaction_set_txid(struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void InvoiceFeatures_set_payment_secret_optional(struct LDKInvoiceFeatures *NONNULL_PTR this_arg); /** - * Constructs a new BuiltCommitmentTransaction given each field + * Set this feature as required. */ -MUST_USE_RES struct LDKBuiltCommitmentTransaction BuiltCommitmentTransaction_new(struct LDKTransaction transaction_arg, struct LDKThirtyTwoBytes txid_arg); +void InvoiceFeatures_set_payment_secret_required(struct LDKInvoiceFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the BuiltCommitmentTransaction + * Checks if this feature is supported. */ -struct LDKBuiltCommitmentTransaction BuiltCommitmentTransaction_clone(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR orig); +MUST_USE_RES bool InvoiceFeatures_supports_payment_secret(const struct LDKInvoiceFeatures *NONNULL_PTR this_arg); /** - * Serialize the BuiltCommitmentTransaction object into a byte array which can be read by BuiltCommitmentTransaction_read + * Checks if this feature is required. */ -struct LDKCVec_u8Z BuiltCommitmentTransaction_write(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR obj); +MUST_USE_RES bool InitFeatures_requires_payment_secret(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Read a BuiltCommitmentTransaction from a byte array, created by BuiltCommitmentTransaction_write + * Checks if this feature is required. */ -struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ BuiltCommitmentTransaction_read(struct LDKu8slice ser); +MUST_USE_RES bool NodeFeatures_requires_payment_secret(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Get the SIGHASH_ALL sighash value of the transaction. - * - * This can be used to verify a signature. + * Checks if this feature is required. */ -MUST_USE_RES struct LDKThirtyTwoBytes BuiltCommitmentTransaction_get_sighash_all(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_arg, struct LDKu8slice funding_redeemscript, uint64_t channel_value_satoshis); +MUST_USE_RES bool InvoiceFeatures_requires_payment_secret(const struct LDKInvoiceFeatures *NONNULL_PTR this_arg); /** - * Sign a transaction, either because we are counter-signing the counterparty's transaction or - * because we are about to broadcast a holder transaction. + * Set this feature as optional. */ -MUST_USE_RES struct LDKSignature BuiltCommitmentTransaction_sign(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_arg, const uint8_t (*funding_key)[32], struct LDKu8slice funding_redeemscript, uint64_t channel_value_satoshis); +void InitFeatures_set_basic_mpp_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the ClosingTransaction, if is_owned is set and inner is non-NULL. + * Set this feature as required. */ -void ClosingTransaction_free(struct LDKClosingTransaction this_obj); +void InitFeatures_set_basic_mpp_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the ClosingTransaction + * Checks if this feature is supported. */ -struct LDKClosingTransaction ClosingTransaction_clone(const struct LDKClosingTransaction *NONNULL_PTR orig); +MUST_USE_RES bool InitFeatures_supports_basic_mpp(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Checks if two ClosingTransactions contain equal inner contents. + * Set this feature as optional. */ -uint64_t ClosingTransaction_hash(const struct LDKClosingTransaction *NONNULL_PTR o); +void NodeFeatures_set_basic_mpp_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Construct an object of the class + * Set this feature as required. */ -MUST_USE_RES struct LDKClosingTransaction ClosingTransaction_new(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); +void NodeFeatures_set_basic_mpp_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Trust our pre-built transaction. - * - * Applies a wrapper which allows access to the transaction. - * - * This should only be used if you fully trust the builder of this object. It should not - * be used by an external signer - instead use the verify function. + * Checks if this feature is supported. */ -MUST_USE_RES struct LDKTrustedClosingTransaction ClosingTransaction_trust(const struct LDKClosingTransaction *NONNULL_PTR this_arg); +MUST_USE_RES bool NodeFeatures_supports_basic_mpp(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Verify our pre-built transaction. - * - * Applies a wrapper which allows access to the transaction. - * - * An external validating signer must call this method before signing - * or using the built transaction. + * Set this feature as optional. */ -MUST_USE_RES struct LDKCResult_TrustedClosingTransactionNoneZ ClosingTransaction_verify(const struct LDKClosingTransaction *NONNULL_PTR this_arg, struct LDKOutPoint funding_outpoint); +void InvoiceFeatures_set_basic_mpp_optional(struct LDKInvoiceFeatures *NONNULL_PTR this_arg); /** - * The value to be sent to the holder, or zero if the output will be omitted + * Set this feature as required. */ -MUST_USE_RES uint64_t ClosingTransaction_to_holder_value_sat(const struct LDKClosingTransaction *NONNULL_PTR this_arg); +void InvoiceFeatures_set_basic_mpp_required(struct LDKInvoiceFeatures *NONNULL_PTR this_arg); /** - * The value to be sent to the counterparty, or zero if the output will be omitted + * Checks if this feature is supported. */ -MUST_USE_RES uint64_t ClosingTransaction_to_counterparty_value_sat(const struct LDKClosingTransaction *NONNULL_PTR this_arg); +MUST_USE_RES bool InvoiceFeatures_supports_basic_mpp(const struct LDKInvoiceFeatures *NONNULL_PTR this_arg); /** - * The destination of the holder's output + * Checks if this feature is required. */ -MUST_USE_RES struct LDKu8slice ClosingTransaction_to_holder_script(const struct LDKClosingTransaction *NONNULL_PTR this_arg); +MUST_USE_RES bool InitFeatures_requires_basic_mpp(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * The destination of the counterparty's output + * Checks if this feature is required. */ -MUST_USE_RES struct LDKu8slice ClosingTransaction_to_counterparty_script(const struct LDKClosingTransaction *NONNULL_PTR this_arg); +MUST_USE_RES bool NodeFeatures_requires_basic_mpp(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the TrustedClosingTransaction, if is_owned is set and inner is non-NULL. + * Checks if this feature is required. */ -void TrustedClosingTransaction_free(struct LDKTrustedClosingTransaction this_obj); +MUST_USE_RES bool InvoiceFeatures_requires_basic_mpp(const struct LDKInvoiceFeatures *NONNULL_PTR this_arg); /** - * The pre-built Bitcoin commitment transaction + * Set this feature as optional. */ -MUST_USE_RES struct LDKTransaction TrustedClosingTransaction_built_transaction(const struct LDKTrustedClosingTransaction *NONNULL_PTR this_arg); +void InitFeatures_set_wumbo_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Get the SIGHASH_ALL sighash value of the transaction. - * - * This can be used to verify a signature. + * Set this feature as required. */ -MUST_USE_RES struct LDKThirtyTwoBytes TrustedClosingTransaction_get_sighash_all(const struct LDKTrustedClosingTransaction *NONNULL_PTR this_arg, struct LDKu8slice funding_redeemscript, uint64_t channel_value_satoshis); +void InitFeatures_set_wumbo_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Sign a transaction, either because we are counter-signing the counterparty's transaction or - * because we are about to broadcast a holder transaction. + * Checks if this feature is supported. */ -MUST_USE_RES struct LDKSignature TrustedClosingTransaction_sign(const struct LDKTrustedClosingTransaction *NONNULL_PTR this_arg, const uint8_t (*funding_key)[32], struct LDKu8slice funding_redeemscript, uint64_t channel_value_satoshis); +MUST_USE_RES bool InitFeatures_supports_wumbo(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the CommitmentTransaction, if is_owned is set and inner is non-NULL. + * Set this feature as optional. */ -void CommitmentTransaction_free(struct LDKCommitmentTransaction this_obj); +void NodeFeatures_set_wumbo_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the CommitmentTransaction + * Set this feature as required. */ -struct LDKCommitmentTransaction CommitmentTransaction_clone(const struct LDKCommitmentTransaction *NONNULL_PTR orig); +void NodeFeatures_set_wumbo_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Serialize the CommitmentTransaction object into a byte array which can be read by CommitmentTransaction_read + * Checks if this feature is supported. */ -struct LDKCVec_u8Z CommitmentTransaction_write(const struct LDKCommitmentTransaction *NONNULL_PTR obj); +MUST_USE_RES bool NodeFeatures_supports_wumbo(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Read a CommitmentTransaction from a byte array, created by CommitmentTransaction_write + * Checks if this feature is required. */ -struct LDKCResult_CommitmentTransactionDecodeErrorZ CommitmentTransaction_read(struct LDKu8slice ser); +MUST_USE_RES bool InitFeatures_requires_wumbo(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * The backwards-counting commitment number + * Checks if this feature is required. */ -MUST_USE_RES uint64_t CommitmentTransaction_commitment_number(const struct LDKCommitmentTransaction *NONNULL_PTR this_arg); +MUST_USE_RES bool NodeFeatures_requires_wumbo(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * The value to be sent to the broadcaster + * Set this feature as optional. */ -MUST_USE_RES uint64_t CommitmentTransaction_to_broadcaster_value_sat(const struct LDKCommitmentTransaction *NONNULL_PTR this_arg); +void InitFeatures_set_shutdown_any_segwit_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * The value to be sent to the counterparty + * Set this feature as required. */ -MUST_USE_RES uint64_t CommitmentTransaction_to_countersignatory_value_sat(const struct LDKCommitmentTransaction *NONNULL_PTR this_arg); +void InitFeatures_set_shutdown_any_segwit_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * The feerate paid per 1000-weight-unit in this commitment transaction. + * Checks if this feature is supported. */ -MUST_USE_RES uint32_t CommitmentTransaction_feerate_per_kw(const struct LDKCommitmentTransaction *NONNULL_PTR this_arg); +MUST_USE_RES bool InitFeatures_supports_shutdown_anysegwit(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Trust our pre-built transaction and derived transaction creation public keys. - * - * Applies a wrapper which allows access to these fields. - * - * This should only be used if you fully trust the builder of this object. It should not - * be used by an external signer - instead use the verify function. + * Set this feature as optional. */ -MUST_USE_RES struct LDKTrustedCommitmentTransaction CommitmentTransaction_trust(const struct LDKCommitmentTransaction *NONNULL_PTR this_arg); +void NodeFeatures_set_shutdown_any_segwit_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Verify our pre-built transaction and derived transaction creation public keys. - * - * Applies a wrapper which allows access to these fields. - * - * An external validating signer must call this method before signing - * or using the built transaction. + * Set this feature as required. */ -MUST_USE_RES struct LDKCResult_TrustedCommitmentTransactionNoneZ CommitmentTransaction_verify(const struct LDKCommitmentTransaction *NONNULL_PTR this_arg, const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR channel_parameters, const struct LDKChannelPublicKeys *NONNULL_PTR broadcaster_keys, const struct LDKChannelPublicKeys *NONNULL_PTR countersignatory_keys); +void NodeFeatures_set_shutdown_any_segwit_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the TrustedCommitmentTransaction, if is_owned is set and inner is non-NULL. + * Checks if this feature is supported. */ -void TrustedCommitmentTransaction_free(struct LDKTrustedCommitmentTransaction this_obj); +MUST_USE_RES bool NodeFeatures_supports_shutdown_anysegwit(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * The transaction ID of the built Bitcoin transaction + * Checks if this feature is required. */ -MUST_USE_RES struct LDKThirtyTwoBytes TrustedCommitmentTransaction_txid(const struct LDKTrustedCommitmentTransaction *NONNULL_PTR this_arg); +MUST_USE_RES bool InitFeatures_requires_shutdown_anysegwit(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * The pre-built Bitcoin commitment transaction + * Checks if this feature is required. */ -MUST_USE_RES struct LDKBuiltCommitmentTransaction TrustedCommitmentTransaction_built_transaction(const struct LDKTrustedCommitmentTransaction *NONNULL_PTR this_arg); +MUST_USE_RES bool NodeFeatures_requires_shutdown_anysegwit(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * The pre-calculated transaction creation public keys. + * Set this feature as optional. */ -MUST_USE_RES struct LDKTxCreationKeys TrustedCommitmentTransaction_keys(const struct LDKTrustedCommitmentTransaction *NONNULL_PTR this_arg); +void InitFeatures_set_onion_messages_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Should anchors be used. + * Set this feature as required. */ -MUST_USE_RES bool TrustedCommitmentTransaction_opt_anchors(const struct LDKTrustedCommitmentTransaction *NONNULL_PTR this_arg); +void InitFeatures_set_onion_messages_required(struct LDKInitFeatures *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. + * Checks if this feature is supported. */ -MUST_USE_RES struct LDKCResult_CVec_SignatureZNoneZ TrustedCommitmentTransaction_get_htlc_sigs(const struct LDKTrustedCommitmentTransaction *NONNULL_PTR this_arg, const uint8_t (*htlc_base_key)[32], const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR channel_parameters); +MUST_USE_RES bool InitFeatures_supports_onion_messages(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Commitment transaction numbers which appear in the transactions themselves are XOR'd with a - * shared secret first. This prevents on-chain observers from discovering how many commitment - * transactions occurred in a channel before it was closed. - * - * This function gets the shared secret from relevant channel public keys and can be used to - * \"decrypt\" the commitment transaction number given a commitment transaction on-chain. + * Set this feature as optional. */ -uint64_t get_commitment_transaction_number_obscure_factor(struct LDKPublicKey broadcaster_payment_basepoint, struct LDKPublicKey countersignatory_payment_basepoint, bool outbound_from_broadcaster); +void NodeFeatures_set_onion_messages_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Checks if two InitFeaturess contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Set this feature as required. */ -bool InitFeatures_eq(const struct LDKInitFeatures *NONNULL_PTR a, const struct LDKInitFeatures *NONNULL_PTR b); +void NodeFeatures_set_onion_messages_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Checks if two NodeFeaturess contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Checks if this feature is supported. */ -bool NodeFeatures_eq(const struct LDKNodeFeatures *NONNULL_PTR a, const struct LDKNodeFeatures *NONNULL_PTR b); +MUST_USE_RES bool NodeFeatures_supports_onion_messages(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Checks if two ChannelFeaturess contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Checks if this feature is required. */ -bool ChannelFeatures_eq(const struct LDKChannelFeatures *NONNULL_PTR a, const struct LDKChannelFeatures *NONNULL_PTR b); +MUST_USE_RES bool InitFeatures_requires_onion_messages(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Checks if two InvoiceFeaturess contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Checks if this feature is required. */ -bool InvoiceFeatures_eq(const struct LDKInvoiceFeatures *NONNULL_PTR a, const struct LDKInvoiceFeatures *NONNULL_PTR b); +MUST_USE_RES bool NodeFeatures_requires_onion_messages(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * 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. + * Set this feature as optional. */ -bool ChannelTypeFeatures_eq(const struct LDKChannelTypeFeatures *NONNULL_PTR a, const struct LDKChannelTypeFeatures *NONNULL_PTR b); +void InitFeatures_set_channel_type_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the InitFeatures + * Set this feature as required. */ -struct LDKInitFeatures InitFeatures_clone(const struct LDKInitFeatures *NONNULL_PTR orig); +void InitFeatures_set_channel_type_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the NodeFeatures + * Checks if this feature is supported. */ -struct LDKNodeFeatures NodeFeatures_clone(const struct LDKNodeFeatures *NONNULL_PTR orig); +MUST_USE_RES bool InitFeatures_supports_channel_type(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the ChannelFeatures + * Set this feature as optional. */ -struct LDKChannelFeatures ChannelFeatures_clone(const struct LDKChannelFeatures *NONNULL_PTR orig); +void NodeFeatures_set_channel_type_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the InvoiceFeatures + * Set this feature as required. */ -struct LDKInvoiceFeatures InvoiceFeatures_clone(const struct LDKInvoiceFeatures *NONNULL_PTR orig); +void NodeFeatures_set_channel_type_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the ChannelTypeFeatures + * Checks if this feature is supported. */ -struct LDKChannelTypeFeatures ChannelTypeFeatures_clone(const struct LDKChannelTypeFeatures *NONNULL_PTR orig); +MUST_USE_RES bool NodeFeatures_supports_channel_type(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the InitFeatures, if is_owned is set and inner is non-NULL. + * Checks if this feature is required. */ -void InitFeatures_free(struct LDKInitFeatures this_obj); +MUST_USE_RES bool InitFeatures_requires_channel_type(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the NodeFeatures, if is_owned is set and inner is non-NULL. + * Checks if this feature is required. */ -void NodeFeatures_free(struct LDKNodeFeatures this_obj); +MUST_USE_RES bool NodeFeatures_requires_channel_type(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the ChannelFeatures, if is_owned is set and inner is non-NULL. + * Set this feature as optional. */ -void ChannelFeatures_free(struct LDKChannelFeatures this_obj); +void InitFeatures_set_scid_privacy_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the InvoiceFeatures, if is_owned is set and inner is non-NULL. + * Set this feature as required. */ -void InvoiceFeatures_free(struct LDKInvoiceFeatures this_obj); +void InitFeatures_set_scid_privacy_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the ChannelTypeFeatures, if is_owned is set and inner is non-NULL. + * Checks if this feature is supported. */ -void ChannelTypeFeatures_free(struct LDKChannelTypeFeatures this_obj); +MUST_USE_RES bool InitFeatures_supports_scid_privacy(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Create a blank Features with no features set + * Set this feature as optional. */ -MUST_USE_RES struct LDKInitFeatures InitFeatures_empty(void); +void NodeFeatures_set_scid_privacy_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Creates a Features with the bits set which are known by the implementation + * Set this feature as required. */ -MUST_USE_RES struct LDKInitFeatures InitFeatures_known(void); +void NodeFeatures_set_scid_privacy_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Returns true if this `Features` object contains unknown feature flags which are set as - * \"required\". + * Checks if this feature is supported. */ -MUST_USE_RES bool InitFeatures_requires_unknown_bits(const struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES bool NodeFeatures_supports_scid_privacy(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Create a blank Features with no features set + * Set this feature as optional. */ -MUST_USE_RES struct LDKNodeFeatures NodeFeatures_empty(void); +void ChannelTypeFeatures_set_scid_privacy_optional(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Creates a Features with the bits set which are known by the implementation + * Set this feature as required. */ -MUST_USE_RES struct LDKNodeFeatures NodeFeatures_known(void); +void ChannelTypeFeatures_set_scid_privacy_required(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Returns true if this `Features` object contains unknown feature flags which are set as - * \"required\". + * Checks if this feature is supported. */ -MUST_USE_RES bool NodeFeatures_requires_unknown_bits(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES bool ChannelTypeFeatures_supports_scid_privacy(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Create a blank Features with no features set + * Checks if this feature is required. */ -MUST_USE_RES struct LDKChannelFeatures ChannelFeatures_empty(void); +MUST_USE_RES bool InitFeatures_requires_scid_privacy(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Creates a Features with the bits set which are known by the implementation + * Checks if this feature is required. */ -MUST_USE_RES struct LDKChannelFeatures ChannelFeatures_known(void); +MUST_USE_RES bool NodeFeatures_requires_scid_privacy(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Returns true if this `Features` object contains unknown feature flags which are set as - * \"required\". + * Checks if this feature is required. */ -MUST_USE_RES bool ChannelFeatures_requires_unknown_bits(const struct LDKChannelFeatures *NONNULL_PTR this_arg); +MUST_USE_RES bool ChannelTypeFeatures_requires_scid_privacy(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Create a blank Features with no features set + * Set this feature as optional. */ -MUST_USE_RES struct LDKInvoiceFeatures InvoiceFeatures_empty(void); +void InitFeatures_set_zero_conf_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Creates a Features with the bits set which are known by the implementation + * Set this feature as required. */ -MUST_USE_RES struct LDKInvoiceFeatures InvoiceFeatures_known(void); +void InitFeatures_set_zero_conf_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Returns true if this `Features` object contains unknown feature flags which are set as - * \"required\". + * Checks if this feature is supported. */ -MUST_USE_RES bool InvoiceFeatures_requires_unknown_bits(const struct LDKInvoiceFeatures *NONNULL_PTR this_arg); +MUST_USE_RES bool InitFeatures_supports_zero_conf(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Create a blank Features with no features set + * Set this feature as optional. */ -MUST_USE_RES struct LDKChannelTypeFeatures ChannelTypeFeatures_empty(void); +void NodeFeatures_set_zero_conf_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Creates a Features with the bits set which are known by the implementation + * Set this feature as required. */ -MUST_USE_RES struct LDKChannelTypeFeatures ChannelTypeFeatures_known(void); +void NodeFeatures_set_zero_conf_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Returns true if this `Features` object contains unknown feature flags which are set as - * \"required\". + * Checks if this feature is supported. */ -MUST_USE_RES bool ChannelTypeFeatures_requires_unknown_bits(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES bool NodeFeatures_supports_zero_conf(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Serialize the InitFeatures object into a byte array which can be read by InitFeatures_read + * Set this feature as optional. */ -struct LDKCVec_u8Z InitFeatures_write(const struct LDKInitFeatures *NONNULL_PTR obj); +void ChannelTypeFeatures_set_zero_conf_optional(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Read a InitFeatures from a byte array, created by InitFeatures_write + * Set this feature as required. */ -struct LDKCResult_InitFeaturesDecodeErrorZ InitFeatures_read(struct LDKu8slice ser); +void ChannelTypeFeatures_set_zero_conf_required(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Serialize the ChannelFeatures object into a byte array which can be read by ChannelFeatures_read + * Checks if this feature is supported. */ -struct LDKCVec_u8Z ChannelFeatures_write(const struct LDKChannelFeatures *NONNULL_PTR obj); +MUST_USE_RES bool ChannelTypeFeatures_supports_zero_conf(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Read a ChannelFeatures from a byte array, created by ChannelFeatures_write + * Checks if this feature is required. */ -struct LDKCResult_ChannelFeaturesDecodeErrorZ ChannelFeatures_read(struct LDKu8slice ser); +MUST_USE_RES bool InitFeatures_requires_zero_conf(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Serialize the NodeFeatures object into a byte array which can be read by NodeFeatures_read + * Checks if this feature is required. */ -struct LDKCVec_u8Z NodeFeatures_write(const struct LDKNodeFeatures *NONNULL_PTR obj); +MUST_USE_RES bool NodeFeatures_requires_zero_conf(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Read a NodeFeatures from a byte array, created by NodeFeatures_write + * Checks if this feature is required. */ -struct LDKCResult_NodeFeaturesDecodeErrorZ NodeFeatures_read(struct LDKu8slice ser); +MUST_USE_RES bool ChannelTypeFeatures_requires_zero_conf(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Serialize the InvoiceFeatures object into a byte array which can be read by InvoiceFeatures_read + * Set this feature as optional. */ -struct LDKCVec_u8Z InvoiceFeatures_write(const struct LDKInvoiceFeatures *NONNULL_PTR obj); +void NodeFeatures_set_keysend_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Read a InvoiceFeatures from a byte array, created by InvoiceFeatures_write + * Set this feature as required. */ -struct LDKCResult_InvoiceFeaturesDecodeErrorZ InvoiceFeatures_read(struct LDKu8slice ser); +void NodeFeatures_set_keysend_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Serialize the ChannelTypeFeatures object into a byte array which can be read by ChannelTypeFeatures_read + * Checks if this feature is supported. */ -struct LDKCVec_u8Z ChannelTypeFeatures_write(const struct LDKChannelTypeFeatures *NONNULL_PTR obj); +MUST_USE_RES bool NodeFeatures_supports_keysend(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Read a ChannelTypeFeatures from a byte array, created by ChannelTypeFeatures_write + * Checks if this feature is required. */ -struct LDKCResult_ChannelTypeFeaturesDecodeErrorZ ChannelTypeFeatures_read(struct LDKu8slice ser); +MUST_USE_RES bool NodeFeatures_requires_keysend(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** * Frees any resources used by the ShutdownScript, if is_owned is set and inner is non-NULL. @@ -23765,6 +28040,13 @@ void ShutdownScript_free(struct LDKShutdownScript this_obj); */ struct LDKShutdownScript ShutdownScript_clone(const struct LDKShutdownScript *NONNULL_PTR orig); +/** + * Checks if two ShutdownScripts contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. + */ +bool ShutdownScript_eq(const struct LDKShutdownScript *NONNULL_PTR a, const struct LDKShutdownScript *NONNULL_PTR b); + /** * Frees any resources used by the InvalidShutdownScript, if is_owned is set and inner is non-NULL. */ @@ -23773,14 +28055,14 @@ void InvalidShutdownScript_free(struct LDKInvalidShutdownScript this_obj); /** * The script that did not meet the requirements from [BOLT #2]. * - * [BOLT #2]: https://github.com/lightningnetwork/lightning-rfc/blob/master/02-peer-protocol.md + * [BOLT #2]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md */ struct LDKu8slice InvalidShutdownScript_get_script(const struct LDKInvalidShutdownScript *NONNULL_PTR this_ptr); /** * The script that did not meet the requirements from [BOLT #2]. * - * [BOLT #2]: https://github.com/lightningnetwork/lightning-rfc/blob/master/02-peer-protocol.md + * [BOLT #2]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md */ void InvalidShutdownScript_set_script(struct LDKInvalidShutdownScript *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val); @@ -23824,7 +28106,7 @@ MUST_USE_RES struct LDKShutdownScript ShutdownScript_new_p2wsh(const uint8_t (*s * * This function may return an error if `program` is invalid for the segwit `version`. */ -MUST_USE_RES struct LDKCResult_ShutdownScriptInvalidShutdownScriptZ ShutdownScript_new_witness_program(uint8_t version, struct LDKu8slice program); +MUST_USE_RES struct LDKCResult_ShutdownScriptInvalidShutdownScriptZ ShutdownScript_new_witness_program(struct LDKWitnessVersion version, struct LDKu8slice program); /** * Converts the shutdown script into the underlying [`Script`]. @@ -23895,11 +28177,6 @@ struct LDKCResult_NodeIdDecodeErrorZ NodeId_read(struct LDKu8slice ser); */ void NetworkGraph_free(struct LDKNetworkGraph this_obj); -/** - * Creates a copy of the NetworkGraph - */ -struct LDKNetworkGraph NetworkGraph_clone(const struct LDKNetworkGraph *NONNULL_PTR orig); - /** * Frees any resources used by the ReadOnlyNetworkGraph, if is_owned is set and inner is non-NULL. */ @@ -23921,15 +28198,21 @@ struct LDKNetworkUpdate NetworkUpdate_clone(const struct LDKNetworkUpdate *NONNU struct LDKNetworkUpdate NetworkUpdate_channel_update_message(struct LDKChannelUpdate msg); /** - * Utility method to constructs a new ChannelClosed-variant NetworkUpdate + * Utility method to constructs a new ChannelFailure-variant NetworkUpdate */ -struct LDKNetworkUpdate NetworkUpdate_channel_closed(uint64_t short_channel_id, bool is_permanent); +struct LDKNetworkUpdate NetworkUpdate_channel_failure(uint64_t short_channel_id, bool is_permanent); /** * Utility method to constructs a new NodeFailure-variant NetworkUpdate */ struct LDKNetworkUpdate NetworkUpdate_node_failure(struct LDKPublicKey node_id, bool is_permanent); +/** + * Checks if two NetworkUpdates contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + */ +bool NetworkUpdate_eq(const struct LDKNetworkUpdate *NONNULL_PTR a, const struct LDKNetworkUpdate *NONNULL_PTR b); + /** * Serialize the NetworkUpdate object into a byte array which can be read by NetworkUpdate_read */ @@ -23941,15 +28224,9 @@ struct LDKCVec_u8Z NetworkUpdate_write(const struct LDKNetworkUpdate *NONNULL_PT 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 - */ -struct LDKEventHandler NetGraphMsgHandler_as_EventHandler(const struct LDKNetGraphMsgHandler *NONNULL_PTR this_arg); - -/** - * Frees any resources used by the NetGraphMsgHandler, if is_owned is set and inner is non-NULL. + * Frees any resources used by the P2PGossipSync, if is_owned is set and inner is non-NULL. */ -void NetGraphMsgHandler_free(struct LDKNetGraphMsgHandler this_obj); +void P2PGossipSync_free(struct LDKP2PGossipSync this_obj); /** * Creates a new tracker of the actual state of the network of channels and nodes, @@ -23958,26 +28235,32 @@ void NetGraphMsgHandler_free(struct LDKNetGraphMsgHandler this_obj); * channel data is correct, and that the announcement is signed with * channel owners' keys. */ -MUST_USE_RES struct LDKNetGraphMsgHandler NetGraphMsgHandler_new(const struct LDKNetworkGraph *NONNULL_PTR network_graph, struct LDKCOption_AccessZ chain_access, struct LDKLogger logger); +MUST_USE_RES struct LDKP2PGossipSync P2PGossipSync_new(const struct LDKNetworkGraph *NONNULL_PTR network_graph, struct LDKCOption_AccessZ chain_access, struct LDKLogger logger); /** * Adds a provider used to check new announcements. Does not affect * existing announcements unless they are updated. * Add, update or remove the provider would replace the current one. */ -void NetGraphMsgHandler_add_chain_access(struct LDKNetGraphMsgHandler *NONNULL_PTR this_arg, struct LDKCOption_AccessZ chain_access); +void P2PGossipSync_add_chain_access(struct LDKP2PGossipSync *NONNULL_PTR this_arg, struct LDKCOption_AccessZ chain_access); + +/** + * 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 + */ +struct LDKEventHandler NetworkGraph_as_EventHandler(const struct LDKNetworkGraph *NONNULL_PTR this_arg); /** * Constructs a new RoutingMessageHandler which calls the relevant methods on this_arg. * This copies the `inner` pointer in this_arg and thus the returned RoutingMessageHandler must be freed before this_arg is */ -struct LDKRoutingMessageHandler NetGraphMsgHandler_as_RoutingMessageHandler(const struct LDKNetGraphMsgHandler *NONNULL_PTR this_arg); +struct LDKRoutingMessageHandler P2PGossipSync_as_RoutingMessageHandler(const struct LDKP2PGossipSync *NONNULL_PTR this_arg); /** * Constructs a new MessageSendEventsProvider which calls the relevant methods on this_arg. * This copies the `inner` pointer in this_arg and thus the returned MessageSendEventsProvider must be freed before this_arg is */ -struct LDKMessageSendEventsProvider NetGraphMsgHandler_as_MessageSendEventsProvider(const struct LDKNetGraphMsgHandler *NONNULL_PTR this_arg); +struct LDKMessageSendEventsProvider P2PGossipSync_as_MessageSendEventsProvider(const struct LDKP2PGossipSync *NONNULL_PTR this_arg); /** * Frees any resources used by the ChannelUpdateInfo, if is_owned is set and inner is non-NULL. @@ -24029,12 +28312,12 @@ void ChannelUpdateInfo_set_htlc_minimum_msat(struct LDKChannelUpdateInfo *NONNUL /** * The maximum value which may be relayed to the next hop via the channel. */ -struct LDKCOption_u64Z ChannelUpdateInfo_get_htlc_maximum_msat(const struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr); +uint64_t 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 ChannelUpdateInfo_set_htlc_maximum_msat(struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); +void ChannelUpdateInfo_set_htlc_maximum_msat(struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr, uint64_t val); /** * Fees charged when the channel is used for routing @@ -24069,13 +28352,20 @@ void ChannelUpdateInfo_set_last_update_message(struct LDKChannelUpdateInfo *NONN /** * Constructs a new ChannelUpdateInfo given each field */ -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); +MUST_USE_RES struct LDKChannelUpdateInfo ChannelUpdateInfo_new(uint32_t last_update_arg, bool enabled_arg, uint16_t cltv_expiry_delta_arg, uint64_t htlc_minimum_msat_arg, uint64_t htlc_maximum_msat_arg, struct LDKRoutingFees fees_arg, struct LDKChannelUpdate last_update_message_arg); /** * Creates a copy of the ChannelUpdateInfo */ struct LDKChannelUpdateInfo ChannelUpdateInfo_clone(const struct LDKChannelUpdateInfo *NONNULL_PTR orig); +/** + * Checks if two ChannelUpdateInfos contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. + */ +bool ChannelUpdateInfo_eq(const struct LDKChannelUpdateInfo *NONNULL_PTR a, const struct LDKChannelUpdateInfo *NONNULL_PTR b); + /** * Serialize the ChannelUpdateInfo object into a byte array which can be read by ChannelUpdateInfo_read */ @@ -24184,6 +28474,20 @@ void ChannelInfo_set_announcement_message(struct LDKChannelInfo *NONNULL_PTR thi */ struct LDKChannelInfo ChannelInfo_clone(const struct LDKChannelInfo *NONNULL_PTR orig); +/** + * Checks if two ChannelInfos contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. + */ +bool ChannelInfo_eq(const struct LDKChannelInfo *NONNULL_PTR a, const struct LDKChannelInfo *NONNULL_PTR b); + +/** + * Returns a [`ChannelUpdateInfo`] based on the direction implied by the channel_flag. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +MUST_USE_RES struct LDKChannelUpdateInfo ChannelInfo_get_directional_info(const struct LDKChannelInfo *NONNULL_PTR this_arg, uint8_t channel_flags); + /** * Serialize the ChannelInfo object into a byte array which can be read by ChannelInfo_read */ @@ -24216,12 +28520,17 @@ MUST_USE_RES struct LDKChannelInfo DirectedChannelInfo_channel(const struct LDKD */ MUST_USE_RES struct LDKChannelUpdateInfo DirectedChannelInfo_direction(const struct LDKDirectedChannelInfo *NONNULL_PTR this_arg); +/** + * Returns the maximum HTLC amount allowed over the channel in the direction. + */ +MUST_USE_RES uint64_t DirectedChannelInfo_htlc_maximum_msat(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. + * otherwise. */ MUST_USE_RES struct LDKEffectiveCapacity DirectedChannelInfo_effective_capacity(const struct LDKDirectedChannelInfo *NONNULL_PTR this_arg); @@ -24248,7 +28557,7 @@ struct LDKEffectiveCapacity EffectiveCapacity_maximum_htlc(uint64_t amount_msat) /** * Utility method to constructs a new Total-variant EffectiveCapacity */ -struct LDKEffectiveCapacity EffectiveCapacity_total(uint64_t capacity_msat); +struct LDKEffectiveCapacity EffectiveCapacity_total(uint64_t capacity_msat, struct LDKCOption_u64Z htlc_maximum_msat); /** * Utility method to constructs a new Infinite-variant EffectiveCapacity @@ -24366,14 +28675,21 @@ void NodeAnnouncementInfo_set_rgb(struct LDKNodeAnnouncementInfo *NONNULL_PTR th * May be invalid or malicious (eg control chars), * should not be exposed to the user. */ -const uint8_t (*NodeAnnouncementInfo_get_alias(const struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr))[32]; +struct LDKNodeAlias NodeAnnouncementInfo_get_alias(const struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr); /** * Moniker assigned to the node. * May be invalid or malicious (eg control chars), * should not be exposed to the user. */ -void NodeAnnouncementInfo_set_alias(struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void NodeAnnouncementInfo_set_alias(struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr, struct LDKNodeAlias val); + +/** + * Internet-level addresses via which one can connect to the node + * + * Returns a copy of the field. + */ +struct LDKCVec_NetAddressZ NodeAnnouncementInfo_get_addresses(const struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr); /** * Internet-level addresses via which one can connect to the node @@ -24403,13 +28719,20 @@ void NodeAnnouncementInfo_set_announcement_message(struct LDKNodeAnnouncementInf /** * Constructs a new NodeAnnouncementInfo given each field */ -MUST_USE_RES struct LDKNodeAnnouncementInfo NodeAnnouncementInfo_new(struct LDKNodeFeatures features_arg, uint32_t last_update_arg, struct LDKThreeBytes rgb_arg, struct LDKThirtyTwoBytes alias_arg, struct LDKCVec_NetAddressZ addresses_arg, struct LDKNodeAnnouncement announcement_message_arg); +MUST_USE_RES struct LDKNodeAnnouncementInfo NodeAnnouncementInfo_new(struct LDKNodeFeatures features_arg, uint32_t last_update_arg, struct LDKThreeBytes rgb_arg, struct LDKNodeAlias alias_arg, struct LDKCVec_NetAddressZ addresses_arg, struct LDKNodeAnnouncement announcement_message_arg); /** * Creates a copy of the NodeAnnouncementInfo */ struct LDKNodeAnnouncementInfo NodeAnnouncementInfo_clone(const struct LDKNodeAnnouncementInfo *NONNULL_PTR orig); +/** + * Checks if two NodeAnnouncementInfos contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. + */ +bool NodeAnnouncementInfo_eq(const struct LDKNodeAnnouncementInfo *NONNULL_PTR a, const struct LDKNodeAnnouncementInfo *NONNULL_PTR b); + /** * Serialize the NodeAnnouncementInfo object into a byte array which can be read by NodeAnnouncementInfo_read */ @@ -24420,11 +28743,54 @@ struct LDKCVec_u8Z NodeAnnouncementInfo_write(const struct LDKNodeAnnouncementIn */ struct LDKCResult_NodeAnnouncementInfoDecodeErrorZ NodeAnnouncementInfo_read(struct LDKu8slice ser); +/** + * Frees any resources used by the NodeAlias, if is_owned is set and inner is non-NULL. + */ +void NodeAlias_free(struct LDKNodeAlias this_obj); + +const uint8_t (*NodeAlias_get_a(const struct LDKNodeAlias *NONNULL_PTR this_ptr))[32]; + +void NodeAlias_set_a(struct LDKNodeAlias *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); + +/** + * Constructs a new NodeAlias given each field + */ +MUST_USE_RES struct LDKNodeAlias NodeAlias_new(struct LDKThirtyTwoBytes a_arg); + +/** + * Creates a copy of the NodeAlias + */ +struct LDKNodeAlias NodeAlias_clone(const struct LDKNodeAlias *NONNULL_PTR orig); + +/** + * Checks if two NodeAliass contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. + */ +bool NodeAlias_eq(const struct LDKNodeAlias *NONNULL_PTR a, const struct LDKNodeAlias *NONNULL_PTR b); + +/** + * Serialize the NodeAlias object into a byte array which can be read by NodeAlias_read + */ +struct LDKCVec_u8Z NodeAlias_write(const struct LDKNodeAlias *NONNULL_PTR obj); + +/** + * Read a NodeAlias from a byte array, created by NodeAlias_write + */ +struct LDKCResult_NodeAliasDecodeErrorZ NodeAlias_read(struct LDKu8slice ser); + /** * Frees any resources used by the NodeInfo, if is_owned is set and inner is non-NULL. */ void NodeInfo_free(struct LDKNodeInfo this_obj); +/** + * All valid channels a node has announced + * + * Returns a copy of the field. + */ +struct LDKCVec_u64Z NodeInfo_get_channels(const struct LDKNodeInfo *NONNULL_PTR this_ptr); + /** * All valid channels a node has announced */ @@ -24476,6 +28842,13 @@ MUST_USE_RES struct LDKNodeInfo NodeInfo_new(struct LDKCVec_u64Z channels_arg, s */ struct LDKNodeInfo NodeInfo_clone(const struct LDKNodeInfo *NONNULL_PTR orig); +/** + * Checks if two NodeInfos contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. + */ +bool NodeInfo_eq(const struct LDKNodeInfo *NONNULL_PTR a, const struct LDKNodeInfo *NONNULL_PTR b); + /** * Serialize the NodeInfo object into a byte array which can be read by NodeInfo_read */ @@ -24494,23 +28867,35 @@ struct LDKCVec_u8Z NetworkGraph_write(const struct LDKNetworkGraph *NONNULL_PTR /** * Read a NetworkGraph from a byte array, created by NetworkGraph_write */ -struct LDKCResult_NetworkGraphDecodeErrorZ NetworkGraph_read(struct LDKu8slice ser); +struct LDKCResult_NetworkGraphDecodeErrorZ NetworkGraph_read(struct LDKu8slice ser, struct LDKLogger arg); /** * Creates a new, empty, network graph. */ -MUST_USE_RES struct LDKNetworkGraph NetworkGraph_new(struct LDKThirtyTwoBytes genesis_hash); +MUST_USE_RES struct LDKNetworkGraph NetworkGraph_new(struct LDKThirtyTwoBytes genesis_hash, struct LDKLogger logger); /** * Returns a read-only view of the network graph. */ MUST_USE_RES struct LDKReadOnlyNetworkGraph NetworkGraph_read_only(const struct LDKNetworkGraph *NONNULL_PTR this_arg); +/** + * The unix timestamp provided by the most recent rapid gossip sync. + * It will be set by the rapid sync process after every sync completion. + */ +MUST_USE_RES struct LDKCOption_u32Z NetworkGraph_get_last_rapid_gossip_sync_timestamp(const struct LDKNetworkGraph *NONNULL_PTR this_arg); + +/** + * Update the unix timestamp provided by the most recent rapid gossip sync. + * This should be done automatically by the rapid sync process after every sync completion. + */ +void NetworkGraph_set_last_rapid_gossip_sync_timestamp(const struct LDKNetworkGraph *NONNULL_PTR this_arg, uint32_t last_rapid_gossip_sync_timestamp); + /** * For an already known node (from channel announcements), update its stored properties from a * given node announcement. * - * You probably don't want to call this directly, instead relying on a NetGraphMsgHandler's + * You probably don't want to call this directly, instead relying on a P2PGossipSync's * RoutingMessageHandler implementation to call it indirectly. This may be useful to accept * routing messages from a source using a protocol other than the lightning P2P protocol. */ @@ -24527,7 +28912,7 @@ MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_node_from /** * Store or update channel info from a channel announcement. * - * You probably don't want to call this directly, instead relying on a NetGraphMsgHandler's + * You probably don't want to call this directly, instead relying on a P2PGossipSync's * RoutingMessageHandler implementation to call it indirectly. This may be useful to accept * routing messages from a source using a protocol other than the lightning P2P protocol. * @@ -24547,17 +28932,28 @@ MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel_f MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel_from_unsigned_announcement(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR msg, struct LDKCOption_AccessZ chain_access); /** - * Close a channel if a corresponding HTLC fail was sent. + * Update channel from partial announcement data received via rapid gossip sync + * + * `timestamp: u64`: Timestamp emulating the backdated original announcement receipt (by the + * rapid gossip sync server) + * + * All other parameters as used in [`msgs::UnsignedChannelAnnouncement`] fields. + */ +MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_add_channel_from_partial_announcement(const struct LDKNetworkGraph *NONNULL_PTR this_arg, uint64_t short_channel_id, uint64_t timestamp, struct LDKChannelFeatures features, struct LDKPublicKey node_id_1, struct LDKPublicKey node_id_2); + +/** + * Marks a channel in the graph as failed if a corresponding HTLC fail was sent. * If permanent, removes a channel from the local storage. * May cause the removal of nodes too, if this was their last channel. * If not permanent, makes channels unavailable for routing. */ -void NetworkGraph_close_channel_from_update(const struct LDKNetworkGraph *NONNULL_PTR this_arg, uint64_t short_channel_id, bool is_permanent); +void NetworkGraph_channel_failed(const struct LDKNetworkGraph *NONNULL_PTR this_arg, uint64_t short_channel_id, bool is_permanent); /** - * Marks a node in the graph as failed. + * Marks a node in the graph as permanently failed, effectively removing it and its channels + * from local storage. */ -void NetworkGraph_fail_node(const struct LDKNetworkGraph *NONNULL_PTR this_arg, struct LDKPublicKey _node_id, bool is_permanent); +void NetworkGraph_node_failed_permanent(const struct LDKNetworkGraph *NONNULL_PTR this_arg, struct LDKPublicKey node_id); /** * Removes information about channels that we haven't heard any updates about in some time. @@ -24571,10 +28967,13 @@ void NetworkGraph_fail_node(const struct LDKNetworkGraph *NONNULL_PTR this_arg, * Note that for users of the `lightning-background-processor` crate this method may be * automatically called regularly for you. * + * This method will also cause us to stop tracking removed nodes and channels if they have been + * in the map for a while so that these can be resynced from gossip in the future. + * * This method is only available with the `std` feature. See - * [`NetworkGraph::remove_stale_channels_with_time`] for `no-std` use. + * [`NetworkGraph::remove_stale_channels_and_tracking_with_time`] for `no-std` use. */ -void NetworkGraph_remove_stale_channels(const struct LDKNetworkGraph *NONNULL_PTR this_arg); +void NetworkGraph_remove_stale_channels_and_tracking(const struct LDKNetworkGraph *NONNULL_PTR this_arg); /** * Removes information about channels that we haven't heard any updates about in some time. @@ -24585,16 +28984,19 @@ void NetworkGraph_remove_stale_channels(const struct LDKNetworkGraph *NONNULL_PT * updates every two weeks, the non-normative section of BOLT 7 currently suggests that * pruning occur for updates which are at least two weeks old, which we implement here. * + * This method will also cause us to stop tracking removed nodes and channels if they have been + * in the map for a while so that these can be resynced from gossip in the future. + * * This function takes the current unix time as an argument. For users with the `std` feature - * enabled, [`NetworkGraph::remove_stale_channels`] may be preferable. + * enabled, [`NetworkGraph::remove_stale_channels_and_tracking`] may be preferable. */ -void NetworkGraph_remove_stale_channels_with_time(const struct LDKNetworkGraph *NONNULL_PTR this_arg, uint64_t current_time_unix); +void NetworkGraph_remove_stale_channels_and_tracking_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. * - * You probably don't want to call this directly, instead relying on a NetGraphMsgHandler's + * You probably don't want to call this directly, instead relying on a P2PGossipSync's * RoutingMessageHandler implementation to call it indirectly. This may be useful to accept * routing messages from a source using a protocol other than the lightning P2P protocol. * @@ -24611,7 +29013,31 @@ MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel(c * 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); +MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel_unsigned(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKUnsignedChannelUpdate *NONNULL_PTR msg); + +/** + * Returns information on a channel with the given id. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +MUST_USE_RES struct LDKChannelInfo ReadOnlyNetworkGraph_channel(const struct LDKReadOnlyNetworkGraph *NONNULL_PTR this_arg, uint64_t short_channel_id); + +/** + * Returns the list of channels in the graph + */ +MUST_USE_RES struct LDKCVec_u64Z ReadOnlyNetworkGraph_list_channels(const struct LDKReadOnlyNetworkGraph *NONNULL_PTR this_arg); + +/** + * Returns information on a node with the given id. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +MUST_USE_RES struct LDKNodeInfo ReadOnlyNetworkGraph_node(const struct LDKReadOnlyNetworkGraph *NONNULL_PTR this_arg, const struct LDKNodeId *NONNULL_PTR node_id); + +/** + * Returns the list of nodes in the graph + */ +MUST_USE_RES struct LDKCVec_NodeIdZ ReadOnlyNetworkGraph_list_nodes(const struct LDKReadOnlyNetworkGraph *NONNULL_PTR this_arg); /** * Get network addresses by node id. @@ -24734,21 +29160,19 @@ void Route_free(struct LDKRoute this_obj); /** * The list of routes taken for a single (potentially-)multi-part payment. The pubkey of the - * last RouteHop in each path must be the same. - * Each entry represents a list of hops, NOT INCLUDING our own, where the last hop is the - * destination. Thus, this must always be at least length one. While the maximum length of any - * given path is variable, keeping the length of any path to less than 20 should currently - * ensure it is viable. + * last RouteHop in each path must be the same. Each entry represents a list of hops, NOT + * INCLUDING our own, where the last hop is the destination. Thus, this must always be at + * least length one. While the maximum length of any given path is variable, keeping the length + * of any path less or equal to 19 should currently ensure it is viable. */ struct LDKCVec_CVec_RouteHopZZ Route_get_paths(const struct LDKRoute *NONNULL_PTR this_ptr); /** * The list of routes taken for a single (potentially-)multi-part payment. The pubkey of the - * last RouteHop in each path must be the same. - * Each entry represents a list of hops, NOT INCLUDING our own, where the last hop is the - * destination. Thus, this must always be at least length one. While the maximum length of any - * given path is variable, keeping the length of any path to less than 20 should currently - * ensure it is viable. + * last RouteHop in each path must be the same. Each entry represents a list of hops, NOT + * INCLUDING our own, where the last hop is the destination. Thus, this must always be at + * least length one. While the maximum length of any given path is variable, keeping the length + * of any path less or equal to 19 should currently ensure it is viable. */ void Route_set_paths(struct LDKRoute *NONNULL_PTR this_ptr, struct LDKCVec_CVec_RouteHopZZ val); @@ -24935,18 +29359,82 @@ void PaymentParameters_set_expiry_time(struct LDKPaymentParameters *NONNULL_PTR /** * The maximum total CLTV delta we accept for the route. + * Defaults to [`DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA`]. */ uint32_t PaymentParameters_get_max_total_cltv_expiry_delta(const struct LDKPaymentParameters *NONNULL_PTR this_ptr); /** * The maximum total CLTV delta we accept for the route. + * Defaults to [`DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA`]. */ void PaymentParameters_set_max_total_cltv_expiry_delta(struct LDKPaymentParameters *NONNULL_PTR this_ptr, uint32_t val); +/** + * The maximum number of paths that may be used by (MPP) payments. + * Defaults to [`DEFAULT_MAX_PATH_COUNT`]. + */ +uint8_t PaymentParameters_get_max_path_count(const struct LDKPaymentParameters *NONNULL_PTR this_ptr); + +/** + * The maximum number of paths that may be used by (MPP) payments. + * Defaults to [`DEFAULT_MAX_PATH_COUNT`]. + */ +void PaymentParameters_set_max_path_count(struct LDKPaymentParameters *NONNULL_PTR this_ptr, uint8_t val); + +/** + * Selects the maximum share of a channel's total capacity which will be sent over a channel, + * as a power of 1/2. A higher value prefers to send the payment using more MPP parts whereas + * a lower value prefers to send larger MPP parts, potentially saturating channels and + * increasing failure probability for those paths. + * + * Note that this restriction will be relaxed during pathfinding after paths which meet this + * restriction have been found. While paths which meet this criteria will be searched for, it + * is ultimately up to the scorer to select them over other paths. + * + * A value of 0 will allow payments up to and including a channel's total announced usable + * capacity, a value of one will only use up to half its capacity, two 1/4, etc. + * + * Default value: 2 + */ +uint8_t PaymentParameters_get_max_channel_saturation_power_of_half(const struct LDKPaymentParameters *NONNULL_PTR this_ptr); + +/** + * Selects the maximum share of a channel's total capacity which will be sent over a channel, + * as a power of 1/2. A higher value prefers to send the payment using more MPP parts whereas + * a lower value prefers to send larger MPP parts, potentially saturating channels and + * increasing failure probability for those paths. + * + * Note that this restriction will be relaxed during pathfinding after paths which meet this + * restriction have been found. While paths which meet this criteria will be searched for, it + * is ultimately up to the scorer to select them over other paths. + * + * A value of 0 will allow payments up to and including a channel's total announced usable + * capacity, a value of one will only use up to half its capacity, two 1/4, etc. + * + * Default value: 2 + */ +void PaymentParameters_set_max_channel_saturation_power_of_half(struct LDKPaymentParameters *NONNULL_PTR this_ptr, uint8_t val); + +/** + * A list of SCIDs which this payment was previously attempted over and which caused the + * payment to fail. Future attempts for the same payment shouldn't be relayed through any of + * these SCIDs. + * + * Returns a copy of the field. + */ +struct LDKCVec_u64Z PaymentParameters_get_previously_failed_channels(const struct LDKPaymentParameters *NONNULL_PTR this_ptr); + +/** + * A list of SCIDs which this payment was previously attempted over and which caused the + * payment to fail. Future attempts for the same payment shouldn't be relayed through any of + * these SCIDs. + */ +void PaymentParameters_set_previously_failed_channels(struct LDKPaymentParameters *NONNULL_PTR this_ptr, struct LDKCVec_u64Z val); + /** * Constructs a new PaymentParameters given each field */ -MUST_USE_RES struct LDKPaymentParameters PaymentParameters_new(struct LDKPublicKey payee_pubkey_arg, struct LDKInvoiceFeatures features_arg, struct LDKCVec_RouteHintZ route_hints_arg, struct LDKCOption_u64Z expiry_time_arg, uint32_t max_total_cltv_expiry_delta_arg); +MUST_USE_RES struct LDKPaymentParameters PaymentParameters_new(struct LDKPublicKey payee_pubkey_arg, struct LDKInvoiceFeatures features_arg, struct LDKCVec_RouteHintZ route_hints_arg, struct LDKCOption_u64Z expiry_time_arg, uint32_t max_total_cltv_expiry_delta_arg, uint8_t max_path_count_arg, uint8_t max_channel_saturation_power_of_half_arg, struct LDKCVec_u64Z previously_failed_channels_arg); /** * Creates a copy of the PaymentParameters @@ -25132,8 +29620,8 @@ struct LDKCResult_RouteHintHopDecodeErrorZ RouteHintHop_read(struct LDKu8slice s * Private routing paths between a public node and the target may be included in `params.payee`. * * If some channels aren't announced, it may be useful to fill in `first_hops` with the results - * from [`ChannelManager::list_usable_channels`]. If it is filled in, the view of our local - * channels from [`NetworkGraph`] will be ignored, and only those in `first_hops` will be used. + * from [`ChannelManager::list_usable_channels`]. If it is filled in, the view of these channels + * from `network_graph` will be ignored, and only those in `first_hops` will be used. * * The fees on channels from us to the next hop are ignored as they are assumed to all be equal. * However, the enabled/disabled bit on such channels as well as the `htlc_minimum_msat` / @@ -25152,10 +29640,19 @@ struct LDKCResult_RouteHintHopDecodeErrorZ RouteHintHop_read(struct LDKu8slice s * * [`ChannelManager::list_usable_channels`]: crate::ln::channelmanager::ChannelManager::list_usable_channels * [`Event::PaymentPathFailed`]: crate::util::events::Event::PaymentPathFailed + * [`NetworkGraph`]: crate::routing::gossip::NetworkGraph * * Note that first_hops (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKCResult_RouteLightningErrorZ find_route(struct LDKPublicKey our_node_pubkey, const struct LDKRouteParameters *NONNULL_PTR route_params, const struct LDKNetworkGraph *NONNULL_PTR network, 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_graph, struct LDKCVec_ChannelDetailsZ *first_hops, struct LDKLogger logger, const struct LDKScore *NONNULL_PTR scorer, const uint8_t (*random_seed_bytes)[32]); + +/** + * Construct a route from us (payer) to the target node (payee) via the given hops (which should + * exclude the payer, but include the payee). This may be useful, e.g., for probing the chosen path. + * + * Re-uses logic from `find_route`, so the restrictions described there also apply here. + */ +struct LDKCResult_RouteLightningErrorZ build_route_from_hops(struct LDKPublicKey our_node_pubkey, struct LDKCVec_PublicKeyZ hops, const struct LDKRouteParameters *NONNULL_PTR route_params, const struct LDKNetworkGraph *NONNULL_PTR network_graph, struct LDKLogger logger, const uint8_t (*random_seed_bytes)[32]); /** * Calls the free function if one is set @@ -25167,30 +29664,110 @@ void Score_free(struct LDKScore this_ptr); */ void LockableScore_free(struct LDKLockableScore this_ptr); +/** + * Calls the free function if one is set + */ +void WriteableScore_free(struct LDKWriteableScore this_ptr); + /** * Frees any resources used by the MultiThreadedLockableScore, if is_owned is set and inner is non-NULL. */ void MultiThreadedLockableScore_free(struct LDKMultiThreadedLockableScore this_obj); +/** + * Frees any resources used by the MultiThreadedScoreLock, if is_owned is set and inner is non-NULL. + */ +void MultiThreadedScoreLock_free(struct LDKMultiThreadedScoreLock this_obj); + +/** + * 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 MultiThreadedScoreLock_as_Score(const struct LDKMultiThreadedScoreLock *NONNULL_PTR this_arg); + +/** + * Serialize the MultiThreadedScoreLock object into a byte array which can be read by MultiThreadedScoreLock_read + */ +struct LDKCVec_u8Z MultiThreadedScoreLock_write(const struct LDKMultiThreadedScoreLock *NONNULL_PTR obj); + +/** + * Constructs a new LockableScore which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned LockableScore must be freed before this_arg is + */ +struct LDKLockableScore MultiThreadedLockableScore_as_LockableScore(const struct LDKMultiThreadedLockableScore *NONNULL_PTR this_arg); + +/** + * Serialize the MultiThreadedLockableScore object into a byte array which can be read by MultiThreadedLockableScore_read + */ +struct LDKCVec_u8Z MultiThreadedLockableScore_write(const struct LDKMultiThreadedLockableScore *NONNULL_PTR obj); + +/** + * Constructs a new WriteableScore which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned WriteableScore must be freed before this_arg is + */ +struct LDKWriteableScore MultiThreadedLockableScore_as_WriteableScore(const struct LDKMultiThreadedLockableScore *NONNULL_PTR this_arg); + /** * Creates a new [`MultiThreadedLockableScore`] given an underlying [`Score`]. */ MUST_USE_RES struct LDKMultiThreadedLockableScore MultiThreadedLockableScore_new(struct LDKScore score); /** - * Frees any resources used by the FixedPenaltyScorer, if is_owned is set and inner is non-NULL. + * Frees any resources used by the ChannelUsage, if is_owned is set and inner is non-NULL. */ -void FixedPenaltyScorer_free(struct LDKFixedPenaltyScorer this_obj); +void ChannelUsage_free(struct LDKChannelUsage this_obj); /** - * Serialize the FixedPenaltyScorer object into a byte array which can be read by FixedPenaltyScorer_read + * The amount to send through the channel, denominated in millisatoshis. */ -struct LDKCVec_u8Z FixedPenaltyScorer_write(const struct LDKFixedPenaltyScorer *NONNULL_PTR obj); +uint64_t ChannelUsage_get_amount_msat(const struct LDKChannelUsage *NONNULL_PTR this_ptr); /** - * Read a FixedPenaltyScorer from a byte array, created by FixedPenaltyScorer_write + * The amount to send through the channel, denominated in millisatoshis. + */ +void ChannelUsage_set_amount_msat(struct LDKChannelUsage *NONNULL_PTR this_ptr, uint64_t val); + +/** + * Total amount, denominated in millisatoshis, already allocated to send through the channel + * as part of a multi-path payment. */ -struct LDKCResult_FixedPenaltyScorerDecodeErrorZ FixedPenaltyScorer_read(struct LDKu8slice ser); +uint64_t ChannelUsage_get_inflight_htlc_msat(const struct LDKChannelUsage *NONNULL_PTR this_ptr); + +/** + * Total amount, denominated in millisatoshis, already allocated to send through the channel + * as part of a multi-path payment. + */ +void ChannelUsage_set_inflight_htlc_msat(struct LDKChannelUsage *NONNULL_PTR this_ptr, uint64_t val); + +/** + * The effective capacity of the channel. + */ +struct LDKEffectiveCapacity ChannelUsage_get_effective_capacity(const struct LDKChannelUsage *NONNULL_PTR this_ptr); + +/** + * The effective capacity of the channel. + */ +void ChannelUsage_set_effective_capacity(struct LDKChannelUsage *NONNULL_PTR this_ptr, struct LDKEffectiveCapacity val); + +/** + * Constructs a new ChannelUsage given each field + */ +MUST_USE_RES struct LDKChannelUsage ChannelUsage_new(uint64_t amount_msat_arg, uint64_t inflight_htlc_msat_arg, struct LDKEffectiveCapacity effective_capacity_arg); + +/** + * Creates a copy of the ChannelUsage + */ +struct LDKChannelUsage ChannelUsage_clone(const struct LDKChannelUsage *NONNULL_PTR orig); + +/** + * Frees any resources used by the FixedPenaltyScorer, if is_owned is set and inner is non-NULL. + */ +void FixedPenaltyScorer_free(struct LDKFixedPenaltyScorer this_obj); + +/** + * Creates a copy of the FixedPenaltyScorer + */ +struct LDKFixedPenaltyScorer FixedPenaltyScorer_clone(const struct LDKFixedPenaltyScorer *NONNULL_PTR orig); /** * Creates a new scorer using `penalty_msat`. @@ -25204,299 +29781,584 @@ MUST_USE_RES struct LDKFixedPenaltyScorer FixedPenaltyScorer_with_penalty(uint64 struct LDKScore FixedPenaltyScorer_as_Score(const struct LDKFixedPenaltyScorer *NONNULL_PTR this_arg); /** - * Frees any resources used by the Scorer, if is_owned is set and inner is non-NULL. + * Serialize the FixedPenaltyScorer object into a byte array which can be read by FixedPenaltyScorer_read + */ +struct LDKCVec_u8Z FixedPenaltyScorer_write(const struct LDKFixedPenaltyScorer *NONNULL_PTR obj); + +/** + * Read a FixedPenaltyScorer from a byte array, created by FixedPenaltyScorer_write + */ +struct LDKCResult_FixedPenaltyScorerDecodeErrorZ FixedPenaltyScorer_read(struct LDKu8slice ser, uint64_t arg); + +/** + * Frees any resources used by the ProbabilisticScorer, if is_owned is set and inner is non-NULL. */ -void Scorer_free(struct LDKScorer this_obj); +void ProbabilisticScorer_free(struct LDKProbabilisticScorer this_obj); /** - * Frees any resources used by the ScoringParameters, if is_owned is set and inner is non-NULL. + * Frees any resources used by the ProbabilisticScoringParameters, if is_owned is set and inner is non-NULL. */ -void ScoringParameters_free(struct LDKScoringParameters this_obj); +void ProbabilisticScoringParameters_free(struct LDKProbabilisticScoringParameters 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); +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 ScoringParameters_set_base_penalty_msat(struct LDKScoringParameters *NONNULL_PTR this_ptr, uint64_t val); +void ProbabilisticScoringParameters_set_base_penalty_msat(struct LDKProbabilisticScoringParameters *NONNULL_PTR this_ptr, uint64_t val); /** - * A penalty in msats to apply to a channel upon failing to relay a payment. + * A multiplier used with the payment amount to calculate a fixed penalty applied to each + * channel, in excess of the [`base_penalty_msat`]. * - * This accumulates for each failure but may be reduced over time based on - * [`failure_penalty_half_life`] or when successfully routing through a channel. + * The purpose of the amount penalty is to avoid having fees dominate the channel cost (i.e., + * fees plus penalty) for large payments. The penalty is computed as the product of this + * multiplier and `2^30`ths of the payment amount. * - * Default value: 1,024,000 msat + * ie `base_penalty_amount_multiplier_msat * amount_msat / 2^30` * - * [`failure_penalty_half_life`]: Self::failure_penalty_half_life + * Default value: 8,192 msat + * + * [`base_penalty_msat`]: Self::base_penalty_msat */ -uint64_t ScoringParameters_get_failure_penalty_msat(const struct LDKScoringParameters *NONNULL_PTR this_ptr); +uint64_t ProbabilisticScoringParameters_get_base_penalty_amount_multiplier_msat(const struct LDKProbabilisticScoringParameters *NONNULL_PTR this_ptr); /** - * A penalty in msats to apply to a channel upon failing to relay a payment. + * A multiplier used with the payment amount to calculate a fixed penalty applied to each + * channel, in excess of the [`base_penalty_msat`]. + * + * The purpose of the amount penalty is to avoid having fees dominate the channel cost (i.e., + * fees plus penalty) for large payments. The penalty is computed as the product of this + * multiplier and `2^30`ths of the payment amount. * - * This accumulates for each failure but may be reduced over time based on - * [`failure_penalty_half_life`] or when successfully routing through a channel. + * ie `base_penalty_amount_multiplier_msat * amount_msat / 2^30` * - * Default value: 1,024,000 msat + * Default value: 8,192 msat * - * [`failure_penalty_half_life`]: Self::failure_penalty_half_life + * [`base_penalty_msat`]: Self::base_penalty_msat */ -void ScoringParameters_set_failure_penalty_msat(struct LDKScoringParameters *NONNULL_PTR this_ptr, uint64_t val); +void ProbabilisticScoringParameters_set_base_penalty_amount_multiplier_msat(struct LDKProbabilisticScoringParameters *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`]. + * A multiplier used in conjunction with the negative `log10` of the channel's success + * probability for a payment, as determined by our latest estimates of the channel's + * liquidity, to determine the liquidity penalty. + * + * The penalty is based in part on the knowledge learned from prior successful and unsuccessful + * payments. This knowledge is decayed over time based on [`liquidity_offset_half_life`]. The + * penalty is effectively limited to `2 * liquidity_penalty_multiplier_msat` (corresponding to + * lower bounding the success probability to `0.01`) when the amount falls within the + * uncertainty bounds of the channel liquidity balance. Amounts above the upper bound will + * result in a `u64::max_value` penalty, however. + * + * `-log10(success_probability) * liquidity_penalty_multiplier_msat` * - * Default value: 128 1024ths (i.e. begin penalizing when an HTLC uses 1/8th of a channel) + * Default value: 30,000 msat * - * [`overuse_penalty_msat_per_1024th`]: Self::overuse_penalty_msat_per_1024th + * [`liquidity_offset_half_life`]: Self::liquidity_offset_half_life */ -uint16_t ScoringParameters_get_overuse_penalty_start_1024th(const struct LDKScoringParameters *NONNULL_PTR this_ptr); +uint64_t ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat(const struct LDKProbabilisticScoringParameters *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`]. + * A multiplier used in conjunction with the negative `log10` of the channel's success + * probability for a payment, as determined by our latest estimates of the channel's + * liquidity, to determine the liquidity penalty. + * + * The penalty is based in part on the knowledge learned from prior successful and unsuccessful + * payments. This knowledge is decayed over time based on [`liquidity_offset_half_life`]. The + * penalty is effectively limited to `2 * liquidity_penalty_multiplier_msat` (corresponding to + * lower bounding the success probability to `0.01`) when the amount falls within the + * uncertainty bounds of the channel liquidity balance. Amounts above the upper bound will + * result in a `u64::max_value` penalty, however. + * + * `-log10(success_probability) * liquidity_penalty_multiplier_msat` * - * Default value: 128 1024ths (i.e. begin penalizing when an HTLC uses 1/8th of a channel) + * Default value: 30,000 msat * - * [`overuse_penalty_msat_per_1024th`]: Self::overuse_penalty_msat_per_1024th + * [`liquidity_offset_half_life`]: Self::liquidity_offset_half_life */ -void ScoringParameters_set_overuse_penalty_start_1024th(struct LDKScoringParameters *NONNULL_PTR this_ptr, uint16_t val); +void ProbabilisticScoringParameters_set_liquidity_penalty_multiplier_msat(struct LDKProbabilisticScoringParameters *NONNULL_PTR this_ptr, uint64_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. + * Whenever this amount of time elapses since the last update to a channel's liquidity bounds, + * the distance from the bounds to \"zero\" is cut in half. In other words, the lower-bound on + * the available liquidity is halved and the upper-bound moves half-way to the channel's total + * capacity. + * + * Because halving the liquidity bounds grows the uncertainty on the channel's liquidity, + * the penalty for an amount within the new bounds may change. See the [`ProbabilisticScorer`] + * struct documentation for more info on the way the liquidity bounds are used. + * + * For example, if the channel's capacity is 1 million sats, and the current upper and lower + * liquidity bounds are 200,000 sats and 600,000 sats, after this amount of time the upper + * and lower liquidity bounds will be decayed to 100,000 and 800,000 sats. * - * Default value: 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) + * Default value: 6 hours * - * [`overuse_penalty_start_1024th`]: Self::overuse_penalty_start_1024th + * # 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 ScoringParameters_get_overuse_penalty_msat_per_1024th(const struct LDKScoringParameters *NONNULL_PTR this_ptr); +uint64_t ProbabilisticScoringParameters_get_liquidity_offset_half_life(const struct LDKProbabilisticScoringParameters *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. + * Whenever this amount of time elapses since the last update to a channel's liquidity bounds, + * the distance from the bounds to \"zero\" is cut in half. In other words, the lower-bound on + * the available liquidity is halved and the upper-bound moves half-way to the channel's total + * capacity. + * + * Because halving the liquidity bounds grows the uncertainty on the channel's liquidity, + * the penalty for an amount within the new bounds may change. See the [`ProbabilisticScorer`] + * struct documentation for more info on the way the liquidity bounds are used. + * + * For example, if the channel's capacity is 1 million sats, and the current upper and lower + * liquidity bounds are 200,000 sats and 600,000 sats, after this amount of time the upper + * and lower liquidity bounds will be decayed to 100,000 and 800,000 sats. + * + * Default value: 6 hours * - * 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) + * # Note * - * [`overuse_penalty_start_1024th`]: Self::overuse_penalty_start_1024th + * 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 ScoringParameters_set_overuse_penalty_msat_per_1024th(struct LDKScoringParameters *NONNULL_PTR this_ptr, uint64_t val); +void ProbabilisticScoringParameters_set_liquidity_offset_half_life(struct LDKProbabilisticScoringParameters *NONNULL_PTR this_ptr, uint64_t val); /** - * The time required to elapse before any accumulated [`failure_penalty_msat`] penalties are - * cut in half. + * A multiplier used in conjunction with a payment amount and the negative `log10` of the + * channel's success probability for the payment, as determined by our latest estimates of the + * channel's liquidity, to determine the amount penalty. * - * Successfully routing through a channel will immediately cut the penalty in half as well. + * 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. * - * Default value: 1 hour + * `-log10(success_probability) * liquidity_penalty_amount_multiplier_msat * amount_msat / 2^20` * - * # Note + * In practice, this means for 0.1 success probability (`-log10(0.1) == 1`) each `2^20`th of + * the amount will result in a penalty of the multiplier. And, as the success probability + * decreases, the negative `log10` weighting will increase dramatically. For higher success + * probabilities, the multiplier will have a decreasing effect as the negative `log10` will + * fall below `1`. + * + * Default value: 192 msat + */ +uint64_t ProbabilisticScoringParameters_get_liquidity_penalty_amount_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, as determined by our latest estimates of the + * channel's liquidity, to determine the amount penalty. + * + * The purpose of the amount penalty is to avoid having fees dominate the channel cost (i.e., + * fees plus penalty) for large payments. The penalty is computed as the product of this + * multiplier and `2^20`ths of the payment amount, weighted by the negative `log10` of the + * success probability. * - * When built with the `no-std` feature, time will never elapse. Therefore, this penalty will - * never decay. + * `-log10(success_probability) * liquidity_penalty_amount_multiplier_msat * amount_msat / 2^20` * - * [`failure_penalty_msat`]: Self::failure_penalty_msat + * In practice, this means for 0.1 success probability (`-log10(0.1) == 1`) each `2^20`th of + * the amount will result in a penalty of the multiplier. And, as the success probability + * decreases, the negative `log10` weighting will increase dramatically. For higher success + * probabilities, the multiplier will have a decreasing effect as the negative `log10` will + * fall below `1`. + * + * Default value: 192 msat */ -uint64_t ScoringParameters_get_failure_penalty_half_life(const struct LDKScoringParameters *NONNULL_PTR this_ptr); +void ProbabilisticScoringParameters_set_liquidity_penalty_amount_multiplier_msat(struct LDKProbabilisticScoringParameters *NONNULL_PTR this_ptr, uint64_t val); /** - * The time required to elapse before any accumulated [`failure_penalty_msat`] penalties are - * cut in half. + * A multiplier used in conjunction with the negative `log10` of the channel's success + * probability for the payment, as determined based on the history of our estimates of the + * channel's available liquidity, to determine a penalty. * - * Successfully routing through a channel will immediately cut the penalty in half as well. + * This penalty is similar to [`liquidity_penalty_multiplier_msat`], however, instead of using + * only our latest estimate for the current liquidity available in the channel, it estimates + * success probability based on the estimated liquidity available in the channel through + * history. Specifically, every time we update our liquidity bounds on a given channel, we + * track which of several buckets those bounds fall into, exponentially decaying the + * probability of each bucket as new samples are added. * - * Default value: 1 hour + * Default value: 10,000 msat * - * # Note + * [`liquidity_penalty_multiplier_msat`]: Self::liquidity_penalty_multiplier_msat + */ +uint64_t ProbabilisticScoringParameters_get_historical_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 the payment, as determined based on the history of our estimates of the + * channel's available liquidity, to determine a penalty. + * + * This penalty is similar to [`liquidity_penalty_multiplier_msat`], however, instead of using + * only our latest estimate for the current liquidity available in the channel, it estimates + * success probability based on the estimated liquidity available in the channel through + * history. Specifically, every time we update our liquidity bounds on a given channel, we + * track which of several buckets those bounds fall into, exponentially decaying the + * probability of each bucket as new samples are added. + * + * Default value: 10,000 msat + * + * [`liquidity_penalty_multiplier_msat`]: Self::liquidity_penalty_multiplier_msat + */ +void ProbabilisticScoringParameters_set_historical_liquidity_penalty_multiplier_msat(struct LDKProbabilisticScoringParameters *NONNULL_PTR this_ptr, uint64_t val); + +/** + * A multiplier used in conjunction with the payment amount and the negative `log10` of the + * channel's success probability for the payment, as determined based on the history of our + * estimates of the channel's available liquidity, to determine a penalty. + * + * The purpose of the amount penalty is to avoid having fees dominate the channel cost for + * large payments. The penalty is computed as the product of this multiplier and the `2^20`ths + * of the payment amount, weighted by the negative `log10` of the success probability. + * + * This penalty is similar to [`liquidity_penalty_amount_multiplier_msat`], however, instead + * of using only our latest estimate for the current liquidity available in the channel, it + * estimates success probability based on the estimated liquidity available in the channel + * through history. Specifically, every time we update our liquidity bounds on a given + * channel, we track which of several buckets those bounds fall into, exponentially decaying + * the probability of each bucket as new samples are added. + * + * Default value: 64 msat + * + * [`liquidity_penalty_amount_multiplier_msat`]: Self::liquidity_penalty_amount_multiplier_msat + */ +uint64_t ProbabilisticScoringParameters_get_historical_liquidity_penalty_amount_multiplier_msat(const struct LDKProbabilisticScoringParameters *NONNULL_PTR this_ptr); + +/** + * A multiplier used in conjunction with the payment amount and the negative `log10` of the + * channel's success probability for the payment, as determined based on the history of our + * estimates of the channel's available liquidity, to determine a penalty. + * + * The purpose of the amount penalty is to avoid having fees dominate the channel cost for + * large payments. The penalty is computed as the product of this multiplier and the `2^20`ths + * of the payment amount, weighted by the negative `log10` of the success probability. + * + * This penalty is similar to [`liquidity_penalty_amount_multiplier_msat`], however, instead + * of using only our latest estimate for the current liquidity available in the channel, it + * estimates success probability based on the estimated liquidity available in the channel + * through history. Specifically, every time we update our liquidity bounds on a given + * channel, we track which of several buckets those bounds fall into, exponentially decaying + * the probability of each bucket as new samples are added. + * + * Default value: 64 msat + * + * [`liquidity_penalty_amount_multiplier_msat`]: Self::liquidity_penalty_amount_multiplier_msat + */ +void ProbabilisticScoringParameters_set_historical_liquidity_penalty_amount_multiplier_msat(struct LDKProbabilisticScoringParameters *NONNULL_PTR this_ptr, uint64_t val); + +/** + * If we aren't learning any new datapoints for a channel, the historical liquidity bounds + * tracking can simply live on with increasingly stale data. Instead, when a channel has not + * seen a liquidity estimate update for this amount of time, the historical datapoints are + * decayed by half. + * + * Note that after 16 or more half lives all historical data will be completely gone. + * + * Default value: 14 days + */ +uint64_t ProbabilisticScoringParameters_get_historical_no_updates_half_life(const struct LDKProbabilisticScoringParameters *NONNULL_PTR this_ptr); + +/** + * If we aren't learning any new datapoints for a channel, the historical liquidity bounds + * tracking can simply live on with increasingly stale data. Instead, when a channel has not + * seen a liquidity estimate update for this amount of time, the historical datapoints are + * decayed by half. + * + * Note that after 16 or more half lives all historical data will be completely gone. + * + * Default value: 14 days + */ +void ProbabilisticScoringParameters_set_historical_no_updates_half_life(struct LDKProbabilisticScoringParameters *NONNULL_PTR this_ptr, uint64_t val); + +/** + * This penalty is applied when `htlc_maximum_msat` is equal to or larger than half of the + * channel's capacity, which makes us prefer nodes with a smaller `htlc_maximum_msat`. We + * treat such nodes preferentially as this makes balance discovery attacks harder to execute, + * thereby creating an incentive to restrict `htlc_maximum_msat` and improve privacy. + * + * Default value: 250 msat + */ +uint64_t ProbabilisticScoringParameters_get_anti_probing_penalty_msat(const struct LDKProbabilisticScoringParameters *NONNULL_PTR this_ptr); + +/** + * This penalty is applied when `htlc_maximum_msat` is equal to or larger than half of the + * channel's capacity, which makes us prefer nodes with a smaller `htlc_maximum_msat`. We + * treat such nodes preferentially as this makes balance discovery attacks harder to execute, + * thereby creating an incentive to restrict `htlc_maximum_msat` and improve privacy. + * + * Default value: 250 msat + */ +void ProbabilisticScoringParameters_set_anti_probing_penalty_msat(struct LDKProbabilisticScoringParameters *NONNULL_PTR this_ptr, uint64_t val); + +/** + * This penalty is applied when the amount we're attempting to send over a channel exceeds our + * current estimate of the channel's available liquidity. + * + * Note that in this case all other penalties, including the + * [`liquidity_penalty_multiplier_msat`] and [`liquidity_penalty_amount_multiplier_msat`]-based + * penalties, as well as the [`base_penalty_msat`] and the [`anti_probing_penalty_msat`], if + * applicable, are still included in the overall penalty. * - * When built with the `no-std` feature, time will never elapse. Therefore, this penalty will - * never decay. + * If you wish to avoid creating paths with such channels entirely, setting this to a value of + * `u64::max_value()` will guarantee that. + * + * Default value: 1_0000_0000_000 msat (1 Bitcoin) + * + * [`liquidity_penalty_multiplier_msat`]: Self::liquidity_penalty_multiplier_msat + * [`liquidity_penalty_amount_multiplier_msat`]: Self::liquidity_penalty_amount_multiplier_msat + * [`base_penalty_msat`]: Self::base_penalty_msat + * [`anti_probing_penalty_msat`]: Self::anti_probing_penalty_msat + */ +uint64_t ProbabilisticScoringParameters_get_considered_impossible_penalty_msat(const struct LDKProbabilisticScoringParameters *NONNULL_PTR this_ptr); + +/** + * This penalty is applied when the amount we're attempting to send over a channel exceeds our + * current estimate of the channel's available liquidity. + * + * Note that in this case all other penalties, including the + * [`liquidity_penalty_multiplier_msat`] and [`liquidity_penalty_amount_multiplier_msat`]-based + * penalties, as well as the [`base_penalty_msat`] and the [`anti_probing_penalty_msat`], if + * applicable, are still included in the overall penalty. + * + * If you wish to avoid creating paths with such channels entirely, setting this to a value of + * `u64::max_value()` will guarantee that. + * + * Default value: 1_0000_0000_000 msat (1 Bitcoin) + * + * [`liquidity_penalty_multiplier_msat`]: Self::liquidity_penalty_multiplier_msat + * [`liquidity_penalty_amount_multiplier_msat`]: Self::liquidity_penalty_amount_multiplier_msat + * [`base_penalty_msat`]: Self::base_penalty_msat + * [`anti_probing_penalty_msat`]: Self::anti_probing_penalty_msat + */ +void ProbabilisticScoringParameters_set_considered_impossible_penalty_msat(struct LDKProbabilisticScoringParameters *NONNULL_PTR this_ptr, uint64_t val); + +/** + * 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, struct LDKLogger logger); + +/** + * Dump the contents of this scorer into the configured logger. * - * [`failure_penalty_msat`]: Self::failure_penalty_msat + * Note that this writes roughly one line per channel for which we have a liquidity estimate, + * which may be a substantial amount of log output. + */ +void ProbabilisticScorer_debug_log_liquidity_stats(const struct LDKProbabilisticScorer *NONNULL_PTR this_arg); + +/** + * Query the estimated minimum and maximum liquidity available for sending a payment over the + * channel with `scid` towards the given `target` node. + */ +MUST_USE_RES struct LDKCOption_C2Tuple_u64u64ZZ ProbabilisticScorer_estimated_channel_liquidity_range(const struct LDKProbabilisticScorer *NONNULL_PTR this_arg, uint64_t scid, const struct LDKNodeId *NONNULL_PTR target); + +/** + * Marks the node with the given `node_id` as banned, i.e., + * it will be avoided during path finding. */ -void ScoringParameters_set_failure_penalty_half_life(struct LDKScoringParameters *NONNULL_PTR this_ptr, uint64_t val); +void ProbabilisticScorer_add_banned(struct LDKProbabilisticScorer *NONNULL_PTR this_arg, const struct LDKNodeId *NONNULL_PTR node_id); /** - * Constructs a new ScoringParameters given each field + * Removes the node with the given `node_id` from the list of nodes to avoid. */ -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); +void ProbabilisticScorer_remove_banned(struct LDKProbabilisticScorer *NONNULL_PTR this_arg, const struct LDKNodeId *NONNULL_PTR node_id); /** - * Serialize the ScoringParameters object into a byte array which can be read by ScoringParameters_read + * Sets a manual penalty for the given node. */ -struct LDKCVec_u8Z ScoringParameters_write(const struct LDKScoringParameters *NONNULL_PTR obj); +void ProbabilisticScorer_set_manual_penalty(struct LDKProbabilisticScorer *NONNULL_PTR this_arg, const struct LDKNodeId *NONNULL_PTR node_id, uint64_t penalty); /** - * Read a ScoringParameters from a byte array, created by ScoringParameters_write + * Removes the node with the given `node_id` from the list of manual penalties. */ -struct LDKCResult_ScoringParametersDecodeErrorZ ScoringParameters_read(struct LDKu8slice ser); +void ProbabilisticScorer_remove_manual_penalty(struct LDKProbabilisticScorer *NONNULL_PTR this_arg, const struct LDKNodeId *NONNULL_PTR node_id); /** - * Creates a new scorer using the given scoring parameters. + * Clears the list of manual penalties that are applied during path finding. */ -MUST_USE_RES struct LDKScorer Scorer_new(struct LDKScoringParameters params); +void ProbabilisticScorer_clear_manual_penalties(struct LDKProbabilisticScorer *NONNULL_PTR this_arg); /** - * Creates a "default" Scorer. See struct and individual field documentaiton for details on which values are used. + * Marks all nodes in the given list as banned, i.e., + * they will be avoided during path finding. */ -MUST_USE_RES struct LDKScorer Scorer_default(void); +void ProbabilisticScoringParameters_add_banned_from_list(struct LDKProbabilisticScoringParameters *NONNULL_PTR this_arg, struct LDKCVec_NodeIdZ node_ids); /** - * Creates a "default" ScoringParameters. See struct and individual field documentaiton for details on which values are used. + * Creates a "default" ProbabilisticScoringParameters. See struct and individual field documentaiton for details on which values are used. */ -MUST_USE_RES struct LDKScoringParameters ScoringParameters_default(void); +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 Scorer_as_Score(const struct LDKScorer *NONNULL_PTR this_arg); +struct LDKScore ProbabilisticScorer_as_Score(const struct LDKProbabilisticScorer *NONNULL_PTR this_arg); /** - * Serialize the Scorer object into a byte array which can be read by Scorer_read + * Serialize the ProbabilisticScorer object into a byte array which can be read by ProbabilisticScorer_read */ -struct LDKCVec_u8Z Scorer_write(const struct LDKScorer *NONNULL_PTR obj); +struct LDKCVec_u8Z ProbabilisticScorer_write(const struct LDKProbabilisticScorer *NONNULL_PTR obj); /** - * Read a Scorer from a byte array, created by Scorer_write + * Read a ProbabilisticScorer from a byte array, created by ProbabilisticScorer_write */ -struct LDKCResult_ScorerDecodeErrorZ Scorer_read(struct LDKu8slice ser); +struct LDKCResult_ProbabilisticScorerDecodeErrorZ ProbabilisticScorer_read(struct LDKu8slice ser, struct LDKProbabilisticScoringParameters arg_a, const struct LDKNetworkGraph *NONNULL_PTR arg_b, struct LDKLogger arg_c); /** - * Frees any resources used by the ProbabilisticScorer, if is_owned is set and inner is non-NULL. + * Frees any resources used by the BlindedRoute, if is_owned is set and inner is non-NULL. */ -void ProbabilisticScorer_free(struct LDKProbabilisticScorer this_obj); +void BlindedRoute_free(struct LDKBlindedRoute this_obj); /** - * Frees any resources used by the ProbabilisticScoringParameters, if is_owned is set and inner is non-NULL. + * Frees any resources used by the BlindedHop, if is_owned is set and inner is non-NULL. */ -void ProbabilisticScoringParameters_free(struct LDKProbabilisticScoringParameters this_obj); +void BlindedHop_free(struct LDKBlindedHop this_obj); /** - * A multiplier used to determine the amount in msats willing to be paid to avoid routing - * through a channel, as per multiplying by the negative `log10` of the channel's success - * probability for a payment. - * - * The success probability is determined by the effective channel capacity, the payment amount, - * and knowledge learned from prior successful and unsuccessful payments. The lower bound of - * the success probability is 0.01, effectively limiting the penalty to the range - * `0..=2*liquidity_penalty_multiplier_msat`. The knowledge learned is decayed over time based - * on [`liquidity_offset_half_life`]. - * - * Default value: 10,000 msat + * Create a blinded route to be forwarded along `node_pks`. The last node pubkey in `node_pks` + * will be the destination node. * - * [`liquidity_offset_half_life`]: Self::liquidity_offset_half_life + * Errors if less than two hops are provided or if `node_pk`(s) are invalid. */ -uint64_t ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat(const struct LDKProbabilisticScoringParameters *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCResult_BlindedRouteNoneZ BlindedRoute_new(struct LDKCVec_PublicKeyZ node_pks, const struct LDKKeysInterface *NONNULL_PTR keys_manager); /** - * A multiplier used to determine the amount in msats willing to be paid to avoid routing - * through a channel, as per multiplying by the negative `log10` of the channel's success - * probability for a payment. - * - * The success probability is determined by the effective channel capacity, the payment amount, - * and knowledge learned from prior successful and unsuccessful payments. The lower bound of - * the success probability is 0.01, effectively limiting the penalty to the range - * `0..=2*liquidity_penalty_multiplier_msat`. The knowledge learned is decayed over time based - * on [`liquidity_offset_half_life`]. - * - * Default value: 10,000 msat - * - * [`liquidity_offset_half_life`]: Self::liquidity_offset_half_life + * Serialize the BlindedRoute object into a byte array which can be read by BlindedRoute_read + */ +struct LDKCVec_u8Z BlindedRoute_write(const struct LDKBlindedRoute *NONNULL_PTR obj); + +/** + * Read a BlindedRoute from a byte array, created by BlindedRoute_write + */ +struct LDKCResult_BlindedRouteDecodeErrorZ BlindedRoute_read(struct LDKu8slice ser); + +/** + * Serialize the BlindedHop object into a byte array which can be read by BlindedHop_read + */ +struct LDKCVec_u8Z BlindedHop_write(const struct LDKBlindedHop *NONNULL_PTR obj); + +/** + * Read a BlindedHop from a byte array, created by BlindedHop_write + */ +struct LDKCResult_BlindedHopDecodeErrorZ BlindedHop_read(struct LDKu8slice ser); + +/** + * Frees any resources used by the OnionMessenger, if is_owned is set and inner is non-NULL. + */ +void OnionMessenger_free(struct LDKOnionMessenger this_obj); + +/** + * Frees any resources used by the Destination + */ +void Destination_free(struct LDKDestination this_ptr); + +/** + * Utility method to constructs a new Node-variant Destination + */ +struct LDKDestination Destination_node(struct LDKPublicKey a); + +/** + * Utility method to constructs a new BlindedRoute-variant Destination + */ +struct LDKDestination Destination_blinded_route(struct LDKBlindedRoute a); + +/** + * Frees any resources used by the SendError + */ +void SendError_free(struct LDKSendError this_ptr); + +/** + * Creates a copy of the SendError + */ +struct LDKSendError SendError_clone(const struct LDKSendError *NONNULL_PTR orig); + +/** + * Utility method to constructs a new Secp256k1-variant SendError + */ +struct LDKSendError SendError_secp256k1(enum LDKSecp256k1Error a); + +/** + * Utility method to constructs a new TooBigPacket-variant SendError */ -void ProbabilisticScoringParameters_set_liquidity_penalty_multiplier_msat(struct LDKProbabilisticScoringParameters *NONNULL_PTR this_ptr, uint64_t val); +struct LDKSendError SendError_too_big_packet(void); /** - * 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. + * Utility method to constructs a new TooFewBlindedHops-variant SendError */ -uint64_t ProbabilisticScoringParameters_get_liquidity_offset_half_life(const struct LDKProbabilisticScoringParameters *NONNULL_PTR this_ptr); +struct LDKSendError SendError_too_few_blinded_hops(void); /** - * 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. + * Utility method to constructs a new InvalidFirstHop-variant SendError */ -void ProbabilisticScoringParameters_set_liquidity_offset_half_life(struct LDKProbabilisticScoringParameters *NONNULL_PTR this_ptr, uint64_t val); +struct LDKSendError SendError_invalid_first_hop(void); /** - * Constructs a new ProbabilisticScoringParameters given each field + * Utility method to constructs a new InvalidMessage-variant SendError */ -MUST_USE_RES struct LDKProbabilisticScoringParameters ProbabilisticScoringParameters_new(uint64_t liquidity_penalty_multiplier_msat_arg, uint64_t liquidity_offset_half_life_arg); +struct LDKSendError SendError_invalid_message(void); /** - * Creates a copy of the ProbabilisticScoringParameters + * Utility method to constructs a new BufferFull-variant SendError */ -struct LDKProbabilisticScoringParameters ProbabilisticScoringParameters_clone(const struct LDKProbabilisticScoringParameters *NONNULL_PTR orig); +struct LDKSendError SendError_buffer_full(void); /** - * Serialize the ProbabilisticScoringParameters object into a byte array which can be read by ProbabilisticScoringParameters_read + * Checks if two SendErrors contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -struct LDKCVec_u8Z ProbabilisticScoringParameters_write(const struct LDKProbabilisticScoringParameters *NONNULL_PTR obj); +bool SendError_eq(const struct LDKSendError *NONNULL_PTR a, const struct LDKSendError *NONNULL_PTR b); /** - * Read a ProbabilisticScoringParameters from a byte array, created by ProbabilisticScoringParameters_write + * Calls the free function if one is set */ -struct LDKCResult_ProbabilisticScoringParametersDecodeErrorZ ProbabilisticScoringParameters_read(struct LDKu8slice ser); +void CustomOnionMessageHandler_free(struct LDKCustomOnionMessageHandler this_ptr); /** - * Creates a new scorer using the given scoring parameters for sending payments from a node - * through a network graph. + * Constructs a new `OnionMessenger` to send, forward, and delegate received onion messages to + * their respective handlers. */ -MUST_USE_RES struct LDKProbabilisticScorer ProbabilisticScorer_new(struct LDKProbabilisticScoringParameters params, const struct LDKNetworkGraph *NONNULL_PTR network_graph); +MUST_USE_RES struct LDKOnionMessenger OnionMessenger_new(struct LDKKeysInterface keys_manager, struct LDKLogger logger, struct LDKCustomOnionMessageHandler custom_handler); /** - * Creates a "default" ProbabilisticScoringParameters. See struct and individual field documentaiton for details on which values are used. + * Send an onion message with contents `message` to `destination`, routing it through `intermediate_nodes`. + * See [`OnionMessenger`] for example usage. + * + * Note that reply_path (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKProbabilisticScoringParameters ProbabilisticScoringParameters_default(void); +MUST_USE_RES struct LDKCResult_NoneSendErrorZ OnionMessenger_send_custom_onion_message(const struct LDKOnionMessenger *NONNULL_PTR this_arg, struct LDKCVec_PublicKeyZ intermediate_nodes, struct LDKDestination destination, struct LDKCustomOnionMessageContents msg, struct LDKBlindedRoute reply_path); /** - * 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 + * Constructs a new OnionMessageHandler which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned OnionMessageHandler must be freed before this_arg is */ -struct LDKScore ProbabilisticScorer_as_Score(const struct LDKProbabilisticScorer *NONNULL_PTR this_arg); +struct LDKOnionMessageHandler OnionMessenger_as_OnionMessageHandler(const struct LDKOnionMessenger *NONNULL_PTR this_arg); /** - * Serialize the ProbabilisticScorer object into a byte array which can be read by ProbabilisticScorer_read + * Constructs a new OnionMessageProvider which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned OnionMessageProvider must be freed before this_arg is */ -struct LDKCVec_u8Z ProbabilisticScorer_write(const struct LDKProbabilisticScorer *NONNULL_PTR obj); +struct LDKOnionMessageProvider OnionMessenger_as_OnionMessageProvider(const struct LDKOnionMessenger *NONNULL_PTR this_arg); /** - * Read a ProbabilisticScorer from a byte array, created by ProbabilisticScorer_write + * Calls the free function if one is set */ -struct LDKCResult_ProbabilisticScorerDecodeErrorZ ProbabilisticScorer_read(struct LDKu8slice ser, struct LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ arg); +void CustomOnionMessageContents_free(struct LDKCustomOnionMessageContents this_ptr); /** * Frees any resources used by the FilesystemPersister, if is_owned is set and inner is non-NULL. @@ -25515,48 +30377,55 @@ MUST_USE_RES struct LDKFilesystemPersister FilesystemPersister_new(struct LDKStr MUST_USE_RES struct LDKStr FilesystemPersister_get_data_dir(const struct LDKFilesystemPersister *NONNULL_PTR this_arg); /** - * Writes the provided `ChannelManager` to the path provided at `FilesystemPersister` - * initialization, within a file called \"manager\". + * Read `ChannelMonitor`s from disk. */ -MUST_USE_RES struct LDKCResult_NoneErrorZ FilesystemPersister_persist_manager(struct LDKStr data_dir, const struct LDKChannelManager *NONNULL_PTR manager); +MUST_USE_RES struct LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ FilesystemPersister_read_channelmonitors(const struct LDKFilesystemPersister *NONNULL_PTR this_arg, struct LDKKeysInterface keys_manager); /** - * Read `ChannelMonitor`s from disk. + * Frees any resources used by the BackgroundProcessor, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ FilesystemPersister_read_channelmonitors(const struct LDKFilesystemPersister *NONNULL_PTR this_arg, struct LDKKeysInterface keys_manager); +void BackgroundProcessor_free(struct LDKBackgroundProcessor this_obj); /** - * Constructs a new Persist which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned Persist must be freed before this_arg is + * Frees any resources used by the GossipSync */ -struct LDKPersist FilesystemPersister_as_Persist(const struct LDKFilesystemPersister *NONNULL_PTR this_arg); +void GossipSync_free(struct LDKGossipSync this_ptr); /** - * Frees any resources used by the BackgroundProcessor, if is_owned is set and inner is non-NULL. + * Utility method to constructs a new P2P-variant GossipSync */ -void BackgroundProcessor_free(struct LDKBackgroundProcessor this_obj); +struct LDKGossipSync GossipSync_p2_p(const struct LDKP2PGossipSync *NONNULL_PTR a); /** - * Calls the free function if one is set + * Utility method to constructs a new Rapid-variant GossipSync + */ +struct LDKGossipSync GossipSync_rapid(const struct LDKRapidGossipSync *NONNULL_PTR a); + +/** + * Utility method to constructs a new None-variant GossipSync */ -void ChannelManagerPersister_free(struct LDKChannelManagerPersister this_ptr); +struct LDKGossipSync GossipSync_none(void); /** * 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 + * [`ChannelManager`]. See the `lightning-persister` crate for LDK'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, if + * [`GossipSync`] is supplied. See [`NetworkGraph::write`] for writing out a [`NetworkGraph`]. + * See the `lightning-persister` crate for LDK's provided implementation. + * + * Typically, users should either implement [`Persister::persist_manager`] to never return an * error or call [`join`] and handle any error that may arise. For the latter case, * `BackgroundProcessor` must be restarted by calling `start` again after handling the error. * @@ -25565,19 +30434,25 @@ void ChannelManagerPersister_free(struct LDKChannelManagerPersister this_ptr); * `event_handler` is responsible for handling events that users should be notified of (e.g., * payment failed). [`BackgroundProcessor`] may decorate the given [`EventHandler`] with common * functionality implemented by other handlers. - * * [`NetGraphMsgHandler`] if given will update the [`NetworkGraph`] based on payment failures. + * * [`P2PGossipSync`] if given will update the [`NetworkGraph`] based on payment failures. + * + * # Rapid Gossip Sync + * + * If rapid gossip sync is meant to run at startup, pass [`RapidGossipSync`] via `gossip_sync` + * to indicate that the [`BackgroundProcessor`] should not prune the [`NetworkGraph`] instance + * until the [`RapidGossipSync`] instance completes its first sync. * * [top-level documentation]: BackgroundProcessor * [`join`]: Self::join * [`stop`]: Self::stop * [`ChannelManager`]: lightning::ln::channelmanager::ChannelManager * [`ChannelManager::write`]: lightning::ln::channelmanager::ChannelManager#impl-Writeable - * [`FilesystemPersister::persist_manager`]: lightning_persister::FilesystemPersister::persist_manager - * [`NetworkGraph`]: lightning::routing::network_graph::NetworkGraph - * - * Note that net_graph_msg_handler (or a relevant inner pointer) may be NULL or all-0s to represent None + * [`Persister::persist_manager`]: lightning::util::persist::Persister::persist_manager + * [`Persister::persist_graph`]: lightning::util::persist::Persister::persist_graph + * [`NetworkGraph`]: lightning::routing::gossip::NetworkGraph + * [`NetworkGraph::write`]: lightning::routing::gossip::NetworkGraph#impl-Writeable */ -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 LDKGossipSync gossip_sync, const struct LDKPeerManager *NONNULL_PTR peer_manager, struct LDKLogger logger, struct LDKCOption_WriteableScoreZ scorer); /** * Join `BackgroundProcessor`'s thread, returning any error that occurred while persisting @@ -25605,6 +30480,138 @@ MUST_USE_RES struct LDKCResult_NoneErrorZ BackgroundProcessor_join(struct LDKBac */ MUST_USE_RES struct LDKCResult_NoneErrorZ BackgroundProcessor_stop(struct LDKBackgroundProcessor this_arg); +/** + * Frees any resources used by the ParseError + */ +void ParseError_free(struct LDKParseError this_ptr); + +/** + * Creates a copy of the ParseError + */ +struct LDKParseError ParseError_clone(const struct LDKParseError *NONNULL_PTR orig); + +/** + * Utility method to constructs a new Bech32Error-variant ParseError + */ +struct LDKParseError ParseError_bech32_error(struct LDKBech32Error a); + +/** + * Utility method to constructs a new ParseAmountError-variant ParseError + */ +struct LDKParseError ParseError_parse_amount_error(struct LDKError a); + +/** + * Utility method to constructs a new MalformedSignature-variant ParseError + */ +struct LDKParseError ParseError_malformed_signature(enum LDKSecp256k1Error a); + +/** + * Utility method to constructs a new BadPrefix-variant ParseError + */ +struct LDKParseError ParseError_bad_prefix(void); + +/** + * Utility method to constructs a new UnknownCurrency-variant ParseError + */ +struct LDKParseError ParseError_unknown_currency(void); + +/** + * Utility method to constructs a new UnknownSiPrefix-variant ParseError + */ +struct LDKParseError ParseError_unknown_si_prefix(void); + +/** + * Utility method to constructs a new MalformedHRP-variant ParseError + */ +struct LDKParseError ParseError_malformed_hrp(void); + +/** + * Utility method to constructs a new TooShortDataPart-variant ParseError + */ +struct LDKParseError ParseError_too_short_data_part(void); + +/** + * Utility method to constructs a new UnexpectedEndOfTaggedFields-variant ParseError + */ +struct LDKParseError ParseError_unexpected_end_of_tagged_fields(void); + +/** + * Utility method to constructs a new DescriptionDecodeError-variant ParseError + */ +struct LDKParseError ParseError_description_decode_error(struct LDKError a); + +/** + * Utility method to constructs a new PaddingError-variant ParseError + */ +struct LDKParseError ParseError_padding_error(void); + +/** + * Utility method to constructs a new IntegerOverflowError-variant ParseError + */ +struct LDKParseError ParseError_integer_overflow_error(void); + +/** + * Utility method to constructs a new InvalidSegWitProgramLength-variant ParseError + */ +struct LDKParseError ParseError_invalid_seg_wit_program_length(void); + +/** + * Utility method to constructs a new InvalidPubKeyHashLength-variant ParseError + */ +struct LDKParseError ParseError_invalid_pub_key_hash_length(void); + +/** + * Utility method to constructs a new InvalidScriptHashLength-variant ParseError + */ +struct LDKParseError ParseError_invalid_script_hash_length(void); + +/** + * Utility method to constructs a new InvalidRecoveryId-variant ParseError + */ +struct LDKParseError ParseError_invalid_recovery_id(void); + +/** + * Utility method to constructs a new InvalidSliceLength-variant ParseError + */ +struct LDKParseError ParseError_invalid_slice_length(struct LDKStr a); + +/** + * Utility method to constructs a new Skip-variant ParseError + */ +struct LDKParseError ParseError_skip(void); + +/** + * Checks if two ParseErrors contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + */ +bool ParseError_eq(const struct LDKParseError *NONNULL_PTR a, const struct LDKParseError *NONNULL_PTR b); + +/** + * Frees any resources used by the ParseOrSemanticError + */ +void ParseOrSemanticError_free(struct LDKParseOrSemanticError this_ptr); + +/** + * Creates a copy of the ParseOrSemanticError + */ +struct LDKParseOrSemanticError ParseOrSemanticError_clone(const struct LDKParseOrSemanticError *NONNULL_PTR orig); + +/** + * Utility method to constructs a new ParseError-variant ParseOrSemanticError + */ +struct LDKParseOrSemanticError ParseOrSemanticError_parse_error(struct LDKParseError a); + +/** + * Utility method to constructs a new SemanticError-variant ParseOrSemanticError + */ +struct LDKParseOrSemanticError ParseOrSemanticError_semantic_error(enum LDKSemanticError a); + +/** + * Checks if two ParseOrSemanticErrors contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + */ +bool ParseOrSemanticError_eq(const struct LDKParseOrSemanticError *NONNULL_PTR a, const struct LDKParseOrSemanticError *NONNULL_PTR b); + /** * Frees any resources used by the Invoice, if is_owned is set and inner is non-NULL. */ @@ -25622,6 +30629,11 @@ bool Invoice_eq(const struct LDKInvoice *NONNULL_PTR a, const struct LDKInvoice */ struct LDKInvoice Invoice_clone(const struct LDKInvoice *NONNULL_PTR orig); +/** + * Checks if two Invoices contain equal inner contents. + */ +uint64_t Invoice_hash(const struct LDKInvoice *NONNULL_PTR o); + /** * Frees any resources used by the SignedRawInvoice, if is_owned is set and inner is non-NULL. */ @@ -25639,6 +30651,11 @@ bool SignedRawInvoice_eq(const struct LDKSignedRawInvoice *NONNULL_PTR a, const */ struct LDKSignedRawInvoice SignedRawInvoice_clone(const struct LDKSignedRawInvoice *NONNULL_PTR orig); +/** + * Checks if two SignedRawInvoices contain equal inner contents. + */ +uint64_t SignedRawInvoice_hash(const struct LDKSignedRawInvoice *NONNULL_PTR o); + /** * Frees any resources used by the RawInvoice, if is_owned is set and inner is non-NULL. */ @@ -25666,6 +30683,11 @@ bool RawInvoice_eq(const struct LDKRawInvoice *NONNULL_PTR a, const struct LDKRa */ struct LDKRawInvoice RawInvoice_clone(const struct LDKRawInvoice *NONNULL_PTR orig); +/** + * Checks if two RawInvoices contain equal inner contents. + */ +uint64_t RawInvoice_hash(const struct LDKRawInvoice *NONNULL_PTR o); + /** * Frees any resources used by the RawDataPart, if is_owned is set and inner is non-NULL. */ @@ -25693,6 +30715,11 @@ bool RawDataPart_eq(const struct LDKRawDataPart *NONNULL_PTR a, const struct LDK */ struct LDKRawDataPart RawDataPart_clone(const struct LDKRawDataPart *NONNULL_PTR orig); +/** + * Checks if two RawDataParts contain equal inner contents. + */ +uint64_t RawDataPart_hash(const struct LDKRawDataPart *NONNULL_PTR o); + /** * Frees any resources used by the PositiveTimestamp, if is_owned is set and inner is non-NULL. */ @@ -25710,6 +30737,11 @@ bool PositiveTimestamp_eq(const struct LDKPositiveTimestamp *NONNULL_PTR a, cons */ struct LDKPositiveTimestamp PositiveTimestamp_clone(const struct LDKPositiveTimestamp *NONNULL_PTR orig); +/** + * Checks if two PositiveTimestamps contain equal inner contents. + */ +uint64_t PositiveTimestamp_hash(const struct LDKPositiveTimestamp *NONNULL_PTR o); + /** * Creates a copy of the SiPrefix */ @@ -25741,6 +30773,11 @@ enum LDKSiPrefix SiPrefix_pico(void); */ bool SiPrefix_eq(const enum LDKSiPrefix *NONNULL_PTR a, const enum LDKSiPrefix *NONNULL_PTR b); +/** + * Checks if two SiPrefixs contain equal inner contents. + */ +uint64_t SiPrefix_hash(const enum LDKSiPrefix *NONNULL_PTR o); + /** * Returns the multiplier to go from a BTC value to picoBTC implied by this SiPrefix. * This is effectively 10^12 * the prefix multiplier @@ -25962,6 +30999,11 @@ void InvoiceSignature_free(struct LDKInvoiceSignature this_obj); */ struct LDKInvoiceSignature InvoiceSignature_clone(const struct LDKInvoiceSignature *NONNULL_PTR orig); +/** + * Checks if two InvoiceSignatures contain equal inner contents. + */ +uint64_t InvoiceSignature_hash(const struct LDKInvoiceSignature *NONNULL_PTR o); + /** * Checks if two InvoiceSignatures contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. @@ -26007,7 +31049,7 @@ MUST_USE_RES struct LDKRawInvoice SignedRawInvoice_raw_invoice(const struct LDKS /** * The hash of the `RawInvoice` that was signed. */ -MUST_USE_RES const uint8_t (*SignedRawInvoice_hash(const struct LDKSignedRawInvoice *NONNULL_PTR this_arg))[32]; +MUST_USE_RES const uint8_t (*SignedRawInvoice_signable_hash(const struct LDKSignedRawInvoice *NONNULL_PTR this_arg))[32]; /** * InvoiceSignature for the invoice. @@ -26026,9 +31068,9 @@ MUST_USE_RES struct LDKCResult_PayeePubKeyErrorZ SignedRawInvoice_recover_payee_ MUST_USE_RES bool SignedRawInvoice_check_signature(const struct LDKSignedRawInvoice *NONNULL_PTR this_arg); /** - * Calculate the hash of the encoded `RawInvoice` + * Calculate the hash of the encoded `RawInvoice` which should be signed. */ -MUST_USE_RES struct LDKThirtyTwoBytes RawInvoice_hash(const struct LDKRawInvoice *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKThirtyTwoBytes RawInvoice_signable_hash(const struct LDKRawInvoice *NONNULL_PTR this_arg); /** * @@ -26095,6 +31137,8 @@ MUST_USE_RES struct LDKCResult_PositiveTimestampCreationErrorZ PositiveTimestamp * Creates a `PositiveTimestamp` from a [`SystemTime`] with a corresponding Unix timestamp in * the range `0..=MAX_TIMESTAMP`. * + * Note that the subsecond part is dropped as it is not representable in BOLT 11 invoices. + * * Otherwise, returns a [`CreationError::TimestampOutOfBounds`]. */ MUST_USE_RES struct LDKCResult_PositiveTimestampCreationErrorZ PositiveTimestamp_from_system_time(uint64_t time); @@ -26103,6 +31147,8 @@ MUST_USE_RES struct LDKCResult_PositiveTimestampCreationErrorZ PositiveTimestamp * Creates a `PositiveTimestamp` from a [`Duration`] since the Unix epoch in the range * `0..=MAX_TIMESTAMP`. * + * Note that the subsecond part is dropped as it is not representable in BOLT 11 invoices. + * * Otherwise, returns a [`CreationError::TimestampOutOfBounds`]. */ MUST_USE_RES struct LDKCResult_PositiveTimestampCreationErrorZ PositiveTimestamp_from_duration_since_epoch(uint64_t duration); @@ -26256,7 +31302,7 @@ MUST_USE_RES struct LDKStr Description_into_inner(struct LDKDescription this_arg MUST_USE_RES struct LDKExpiryTime ExpiryTime_from_seconds(uint64_t seconds); /** - * Construct an `ExpiryTime` from a `Duration`. + * Construct an `ExpiryTime` from a `Duration`, dropping the sub-second part. */ MUST_USE_RES struct LDKExpiryTime ExpiryTime_from_duration(uint64_t duration); @@ -26434,35 +31480,35 @@ void Payer_free(struct LDKPayer this_ptr); void Router_free(struct LDKRouter this_ptr); /** - * Frees any resources used by the RetryAttempts, if is_owned is set and inner is non-NULL. + * Frees any resources used by the Retry */ -void RetryAttempts_free(struct LDKRetryAttempts this_obj); +void Retry_free(struct LDKRetry this_ptr); -uintptr_t RetryAttempts_get_a(const struct LDKRetryAttempts *NONNULL_PTR this_ptr); - -void RetryAttempts_set_a(struct LDKRetryAttempts *NONNULL_PTR this_ptr, uintptr_t val); +/** + * Creates a copy of the Retry + */ +struct LDKRetry Retry_clone(const struct LDKRetry *NONNULL_PTR orig); /** - * Constructs a new RetryAttempts given each field + * Utility method to constructs a new Attempts-variant Retry */ -MUST_USE_RES struct LDKRetryAttempts RetryAttempts_new(uintptr_t a_arg); +struct LDKRetry Retry_attempts(uintptr_t a); /** - * Creates a copy of the RetryAttempts + * Utility method to constructs a new Timeout-variant Retry */ -struct LDKRetryAttempts RetryAttempts_clone(const struct LDKRetryAttempts *NONNULL_PTR orig); +struct LDKRetry Retry_timeout(uint64_t a); /** - * Checks if two RetryAttemptss contain equal inner contents. + * Checks if two Retrys 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 RetryAttempts_eq(const struct LDKRetryAttempts *NONNULL_PTR a, const struct LDKRetryAttempts *NONNULL_PTR b); +bool Retry_eq(const struct LDKRetry *NONNULL_PTR a, const struct LDKRetry *NONNULL_PTR b); /** - * Checks if two RetryAttemptss contain equal inner contents. + * Checks if two Retrys contain equal inner contents. */ -uint64_t RetryAttempts_hash(const struct LDKRetryAttempts *NONNULL_PTR o); +uint64_t Retry_hash(const struct LDKRetry *NONNULL_PTR o); /** * Frees any resources used by the PaymentError @@ -26493,9 +31539,9 @@ struct LDKPaymentError PaymentError_sending(struct LDKPaymentSendFailure a); * Creates an invoice payer that retries failed payment paths. * * Will forward any [`Event::PaymentPathFailed`] events to the decorated `event_handler` once - * `retry_attempts` has been exceeded for a given [`Invoice`]. + * `retry` has been exceeded for a given [`Invoice`]. */ -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); +MUST_USE_RES struct LDKInvoicePayer InvoicePayer_new(struct LDKPayer payer, struct LDKRouter router, struct LDKLogger logger, struct LDKEventHandler event_handler, struct LDKRetry retry); /** * Pays the given [`Invoice`], caching it for later use in case a retry is needed. @@ -26539,6 +31585,62 @@ void InvoicePayer_remove_cached_payment(const struct LDKInvoicePayer *NONNULL_PT */ struct LDKEventHandler InvoicePayer_as_EventHandler(const struct LDKInvoicePayer *NONNULL_PTR this_arg); +/** + * Frees any resources used by the InFlightHtlcs, if is_owned is set and inner is non-NULL. + */ +void InFlightHtlcs_free(struct LDKInFlightHtlcs this_obj); + +/** + * Returns liquidity in msat given the public key of the HTLC source, target, and short channel + * id. + */ +MUST_USE_RES struct LDKCOption_u64Z InFlightHtlcs_used_liquidity_msat(const struct LDKInFlightHtlcs *NONNULL_PTR this_arg, const struct LDKNodeId *NONNULL_PTR source, const struct LDKNodeId *NONNULL_PTR target, uint64_t channel_scid); + +/** + * Serialize the InFlightHtlcs object into a byte array which can be read by InFlightHtlcs_read + */ +struct LDKCVec_u8Z InFlightHtlcs_write(const struct LDKInFlightHtlcs *NONNULL_PTR obj); + +/** + * Read a InFlightHtlcs from a byte array, created by InFlightHtlcs_write + */ +struct LDKCResult_InFlightHtlcsDecodeErrorZ InFlightHtlcs_read(struct LDKu8slice ser); + +/** + * Utility to create an invoice that can be paid to one of multiple nodes, or a \"phantom invoice.\" + * See [`PhantomKeysManager`] for more information on phantom node payments. + * + * `phantom_route_hints` parameter: + * * Contains channel info for all nodes participating in the phantom invoice + * * Entries are retrieved from a call to [`ChannelManager::get_phantom_route_hints`] on each + * participating node + * * It is fine to cache `phantom_route_hints` and reuse it across invoices, as long as the data is + * updated when a channel becomes disabled or closes + * * Note that if too many channels are included in [`PhantomRouteHints::channels`], the invoice + * may be too long for QR code scanning. To fix this, `PhantomRouteHints::channels` may be pared + * down + * + * `payment_hash` can be specified if you have a specific need for a custom payment hash (see the difference + * between [`ChannelManager::create_inbound_payment`] and [`ChannelManager::create_inbound_payment_for_hash`]). + * If `None` is provided for `payment_hash`, then one will be created. + * + * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for + * in excess of the current time. + * + * 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 + * [`ChannelManager::create_inbound_payment`]: lightning::ln::channelmanager::ChannelManager::create_inbound_payment + * [`ChannelManager::create_inbound_payment_for_hash`]: lightning::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash + * [`PhantomRouteHints::channels`]: lightning::ln::channelmanager::PhantomRouteHints::channels + * + * Note that payment_hash (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +struct LDKCResult_InvoiceSignOrCreationErrorZ create_phantom_invoice(struct LDKCOption_u64Z amt_msat, struct LDKThirtyTwoBytes payment_hash, struct LDKStr description, uint32_t invoice_expiry_delta_secs, struct LDKCVec_PhantomRouteHintsZ phantom_route_hints, struct LDKKeysInterface keys_manager, struct LDKLogger logger, 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. @@ -26553,9 +31655,14 @@ struct LDKEventHandler InvoicePayer_as_EventHandler(const struct LDKInvoicePayer * 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. + * `description_hash` is a SHA-256 hash of the description text + * + * `payment_hash` can be specified if you have a specific need for a custom payment hash (see the difference + * between [`ChannelManager::create_inbound_payment`] and [`ChannelManager::create_inbound_payment_for_hash`]). + * If `None` is provided for `payment_hash`, then one will be created. + * + * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for + * in excess of the current time. * * Note that the provided `keys_manager`'s `KeysInterface` implementation must support phantom * invoices in its `sign_invoice` implementation ([`PhantomKeysManager`] satisfies this @@ -26563,9 +31670,25 @@ struct LDKEventHandler InvoicePayer_as_EventHandler(const struct LDKInvoicePayer * * [`PhantomKeysManager`]: lightning::chain::keysinterface::PhantomKeysManager * [`ChannelManager::get_phantom_route_hints`]: lightning::ln::channelmanager::ChannelManager::get_phantom_route_hints + * [`ChannelManager::create_inbound_payment`]: lightning::ln::channelmanager::ChannelManager::create_inbound_payment + * [`ChannelManager::create_inbound_payment_for_hash`]: lightning::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash * [`PhantomRouteHints::channels`]: lightning::ln::channelmanager::PhantomRouteHints::channels + * + * Note that payment_hash (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +struct LDKCResult_InvoiceSignOrCreationErrorZ create_phantom_invoice_with_description_hash(struct LDKCOption_u64Z amt_msat, struct LDKThirtyTwoBytes payment_hash, uint32_t invoice_expiry_delta_secs, struct LDKSha256 description_hash, struct LDKCVec_PhantomRouteHintsZ phantom_route_hints, struct LDKKeysInterface keys_manager, struct LDKLogger logger, 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 + * method stores the invoice's payment secret and preimage in `ChannelManager`, so (a) the user + * doesn't have to store preimage/payment secret information and (b) `ChannelManager` can verify + * that the payment secret is valid when the invoice is paid. + * + * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for + * in excess of the current time. */ -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); +struct LDKCResult_InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager(const struct LDKChannelManager *NONNULL_PTR channelmanager, struct LDKKeysInterface keys_manager, struct LDKLogger logger, enum LDKCurrency network, struct LDKCOption_u64Z amt_msat, struct LDKStr description, uint32_t invoice_expiry_delta_secs); /** * Utility to construct an invoice. Generally, unless you want to do something like a custom @@ -26573,15 +31696,26 @@ struct LDKCResult_InvoiceSignOrCreationErrorZ create_phantom_invoice(struct LDKC * method stores the invoice's payment secret and preimage in `ChannelManager`, so (a) the user * doesn't have to store preimage/payment secret information and (b) `ChannelManager` can verify * that the payment secret is valid when the invoice is paid. + * Use this variant if you want to pass the `description_hash` to the invoice. + * + * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for + * in excess of the current time. + */ +struct LDKCResult_InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager_with_description_hash(const struct LDKChannelManager *NONNULL_PTR channelmanager, struct LDKKeysInterface keys_manager, struct LDKLogger logger, enum LDKCurrency network, struct LDKCOption_u64Z amt_msat, struct LDKSha256 description_hash, uint32_t invoice_expiry_delta_secs); + +/** + * 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(const struct LDKChannelManager *NONNULL_PTR channelmanager, struct LDKKeysInterface keys_manager, enum LDKCurrency network, struct LDKCOption_u64Z amt_msat, struct LDKStr description); +struct LDKCResult_InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager_with_description_hash_and_duration_since_epoch(const struct LDKChannelManager *NONNULL_PTR channelmanager, struct LDKKeysInterface keys_manager, struct LDKLogger logger, enum LDKCurrency network, struct LDKCOption_u64Z amt_msat, struct LDKSha256 description_hash, uint64_t duration_since_epoch, uint32_t invoice_expiry_delta_secs); /** * 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); +struct LDKCResult_InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager_and_duration_since_epoch(const struct LDKChannelManager *NONNULL_PTR channelmanager, struct LDKKeysInterface keys_manager, struct LDKLogger logger, enum LDKCurrency network, struct LDKCOption_u64Z amt_msat, struct LDKStr description, uint64_t duration_since_epoch, uint32_t invoice_expiry_delta_secs); /** * Frees any resources used by the DefaultRouter, if is_owned is set and inner is non-NULL. @@ -26589,9 +31723,10 @@ struct LDKCResult_InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager 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, struct LDKLockableScore scorer); /** * Constructs a new Router which calls the relevant methods on this_arg. @@ -26608,17 +31743,27 @@ struct LDKPayer ChannelManager_as_Payer(const struct LDKChannelManager *NONNULL_ /** * Read a SiPrefix object from a string */ -struct LDKCResult_SiPrefixNoneZ SiPrefix_from_str(struct LDKStr s); +struct LDKCResult_SiPrefixParseErrorZ SiPrefix_from_str(struct LDKStr s); /** * Read a Invoice object from a string */ -struct LDKCResult_InvoiceNoneZ Invoice_from_str(struct LDKStr s); +struct LDKCResult_InvoiceParseOrSemanticErrorZ Invoice_from_str(struct LDKStr s); /** * Read a SignedRawInvoice object from a string */ -struct LDKCResult_SignedRawInvoiceNoneZ SignedRawInvoice_from_str(struct LDKStr s); +struct LDKCResult_SignedRawInvoiceParseErrorZ SignedRawInvoice_from_str(struct LDKStr s); + +/** + * Get the string representation of a ParseError object + */ +struct LDKStr ParseError_to_str(const struct LDKParseError *NONNULL_PTR o); + +/** + * Get the string representation of a ParseOrSemanticError object + */ +struct LDKStr ParseOrSemanticError_to_str(const struct LDKParseOrSemanticError *NONNULL_PTR o); /** * Get the string representation of a Invoice object @@ -26640,6 +31785,51 @@ struct LDKStr Currency_to_str(const enum LDKCurrency *NONNULL_PTR o); */ struct LDKStr SiPrefix_to_str(const enum LDKSiPrefix *NONNULL_PTR o); +/** + * Frees any resources used by the RapidGossipSync, if is_owned is set and inner is non-NULL. + */ +void RapidGossipSync_free(struct LDKRapidGossipSync this_obj); + +/** + * Instantiate a new [`RapidGossipSync`] instance. + */ +MUST_USE_RES struct LDKRapidGossipSync RapidGossipSync_new(const struct LDKNetworkGraph *NONNULL_PTR network_graph); + +/** + * Update network graph from binary data. + * Returns the last sync timestamp to be used the next time rapid sync data is queried. + * + * `network_graph`: network graph to be updated + * + * `update_data`: `&[u8]` binary stream that comprises the update data + */ +MUST_USE_RES struct LDKCResult_u32GraphSyncErrorZ RapidGossipSync_update_network_graph(const struct LDKRapidGossipSync *NONNULL_PTR this_arg, struct LDKu8slice update_data); + +/** + * Returns whether a rapid gossip sync has completed at least once. + */ +MUST_USE_RES bool RapidGossipSync_is_initial_sync_complete(const struct LDKRapidGossipSync *NONNULL_PTR this_arg); + +/** + * Frees any resources used by the GraphSyncError + */ +void GraphSyncError_free(struct LDKGraphSyncError this_ptr); + +/** + * Creates a copy of the GraphSyncError + */ +struct LDKGraphSyncError GraphSyncError_clone(const struct LDKGraphSyncError *NONNULL_PTR orig); + +/** + * Utility method to constructs a new DecodeError-variant GraphSyncError + */ +struct LDKGraphSyncError GraphSyncError_decode_error(struct LDKDecodeError a); + +/** + * Utility method to constructs a new LightningError-variant GraphSyncError + */ +struct LDKGraphSyncError GraphSyncError_lightning_error(struct LDKLightningError a); + #endif /* LDK_C_BINDINGS_H */ #include "ldk_ver.h"