X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning-c-bindings%2Finclude%2Flightning.h;h=8b6468cb4dd62e524269446a2e72364cecefa9e1;hb=a21177846ed75d66f68a1603f768410f07a65791;hp=7c95e089463d9f95d99636e62585d8a7a2b3f903;hpb=f10bdbea94cd8c638a42ab637a52e86a7cfd8157;p=ldk-c-bindings diff --git a/lightning-c-bindings/include/lightning.h b/lightning-c-bindings/include/lightning.h index 7c95e08..8b6468c 100644 --- a/lightning-c-bindings/include/lightning.h +++ b/lightning-c-bindings/include/lightning.h @@ -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 @@ -467,6 +482,27 @@ 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 */ @@ -580,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 */ @@ -635,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 */ @@ -731,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 */ @@ -1559,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. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - enum LDKIOError *err; -} LDKCResult_NoneErrorZPtr; + 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; @@ -1612,12 +1842,190 @@ typedef struct MUST_USE_STRUCT LDKRouteHop { } LDKRouteHop; /** - * The contents of CResult_RouteHopDecodeErrorZ + * A dynamically-allocated array of crate::lightning::routing::router::RouteHops of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef union LDKCResult_RouteHopDecodeErrorZPtr { +typedef struct LDKCVec_RouteHopZ { /** - * 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 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 + */ +typedef union LDKCResult_RouteHopDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ struct LDKRouteHop *result; /** @@ -1644,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++ @@ -2111,33 +2503,6 @@ typedef struct LDKCResult_RouteLightningErrorZ { bool result_ok; } LDKCResult_RouteLightningErrorZ; -/** - * 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; - -/** - * 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; - /** * 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. @@ -2268,13 +2633,21 @@ typedef enum LDKClosureReason_Tag { * 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, /** @@ -2535,7 +2908,7 @@ typedef enum LDKNetworkUpdate_Tag { LDKNetworkUpdate_ChannelFailure, /** * An error indicating that a node failed to route a payment, which should be applied via - * [`NetworkGraph::node_failed`]. + * [`NetworkGraph::node_failed_permanent`] if permanent. */ LDKNetworkUpdate_NodeFailure, /** @@ -3141,7 +3514,7 @@ 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. @@ -3724,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 */ @@ -4011,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. */ @@ -4186,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. */ @@ -4195,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 channel_announcement which should be sent. + */ + struct LDKChannelAnnouncement msg; /** - * The node_announcement which should be sent. + * 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 { /** @@ -4291,8 +4655,8 @@ typedef struct MUST_USE_STRUCT LDKMessageSendEvent { 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; @@ -4398,50 +4762,18 @@ typedef struct LDKCVec_TxidZ { uintptr_t datalen; } LDKCVec_TxidZ; + + /** - * The contents of CResult_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 union LDKCResult_NoneChannelMonitorUpdateErrZPtr { +typedef struct MUST_USE_STRUCT LDKHTLCUpdate { /** - * 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. + * A pointer to the opaque Rust object. + * Nearly everywhere, 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; /** @@ -4466,16 +4798,16 @@ typedef enum LDKMonitorEvent_Tag { LDKMonitorEvent_CommitmentTxConfirmed, /** * Indicates a [`ChannelMonitor`] update has completed. See - * [`ChannelMonitorUpdateErr::TemporaryFailure`] for more information on how this is used. + * [`ChannelMonitorUpdateStatus::InProgress`] for more information on how this is used. * - * [`ChannelMonitorUpdateErr::TemporaryFailure`]: super::ChannelMonitorUpdateErr::TemporaryFailure + * [`ChannelMonitorUpdateStatus::InProgress`]: super::ChannelMonitorUpdateStatus::InProgress */ - LDKMonitorEvent_UpdateCompleted, + LDKMonitorEvent_Completed, /** * Indicates a [`ChannelMonitor`] update has failed. See - * [`ChannelMonitorUpdateErr::PermanentFailure`] for more information on how this is used. + * [`ChannelMonitorUpdateStatus::PermanentFailure`] for more information on how this is used. * - * [`ChannelMonitorUpdateErr::PermanentFailure`]: super::ChannelMonitorUpdateErr::PermanentFailure + * [`ChannelMonitorUpdateStatus::PermanentFailure`]: super::ChannelMonitorUpdateStatus::PermanentFailure */ LDKMonitorEvent_UpdateFailed, /** @@ -4484,7 +4816,7 @@ typedef enum LDKMonitorEvent_Tag { LDKMonitorEvent_Sentinel, } LDKMonitorEvent_Tag; -typedef struct LDKMonitorEvent_LDKUpdateCompleted_Body { +typedef struct LDKMonitorEvent_LDKCompleted_Body { /** * The funding outpoint of the [`ChannelMonitor`] that was updated */ @@ -4497,7 +4829,7 @@ typedef struct LDKMonitorEvent_LDKUpdateCompleted_Body { * same [`ChannelMonitor`] have been applied and persisted. */ uint64_t monitor_update_id; -} LDKMonitorEvent_LDKUpdateCompleted_Body; +} LDKMonitorEvent_LDKCompleted_Body; typedef struct MUST_USE_STRUCT LDKMonitorEvent { LDKMonitorEvent_Tag tag; @@ -4508,7 +4840,7 @@ typedef struct MUST_USE_STRUCT LDKMonitorEvent { struct { struct LDKOutPoint commitment_tx_confirmed; }; - LDKMonitorEvent_LDKUpdateCompleted_Body update_completed; + LDKMonitorEvent_LDKCompleted_Body completed; struct { struct LDKOutPoint update_failed; }; @@ -4565,33 +4897,6 @@ typedef struct LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ { uintptr_t datalen; } LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ; -/** - * An enum which can either contain a crate::c_types::derived::C2Tuple_usizeTransactionZ or not - */ -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, - /** - * When we're in this state, this COption_C2Tuple_usizeTransactionZZ contains nothing - */ - LDKCOption_C2Tuple_usizeTransactionZZ_None, - /** - * Must be last for serialization purposes - */ - 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; - /** @@ -4686,26 +4991,6 @@ typedef struct LDKCOption_C2Tuple_u64u64ZZ { }; } LDKCOption_C2Tuple_u64u64ZZ; - - -/** - * Represents the compressed public key of a node - */ -typedef struct MUST_USE_STRUCT LDKNodeId { - /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. - */ - LDKnativeNodeId *inner; - /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. - */ - bool is_owned; -} LDKNodeId; - /** * A dynamically-allocated array of crate::lightning::routing::gossip::NodeIds of arbitrary size. * This corresponds to std::vector in C++ @@ -4788,19 +5073,28 @@ typedef struct MUST_USE_STRUCT LDKNetworkGraph { /** * [`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 * @@ -4808,6 +5102,11 @@ typedef struct MUST_USE_STRUCT LDKNetworkGraph { * 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 { /** @@ -5272,36 +5571,31 @@ typedef struct LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ { } LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ; /** - * A dynamically-allocated array of crate::c_types::derived::C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZs of arbitrary size. - * This corresponds to std::vector in C++ + * An enum which can either contain a crate::c_types::derived::C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ or not */ -typedef struct LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ { - /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - */ - struct LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *data; +typedef enum LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Tag { /** - * The number of elements pointed to by `data`. + * When we're in this state, this COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ contains a crate::c_types::derived::C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ */ - uintptr_t datalen; -} LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ; - -/** - * A dynamically-allocated array of crate::lightning::ln::msgs::NodeAnnouncements of arbitrary size. - * This corresponds to std::vector in C++ - */ -typedef struct LDKCVec_NodeAnnouncementZ { + LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some, /** - * 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_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ contains nothing */ - struct LDKNodeAnnouncement *data; + LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None, /** - * The number of elements pointed to by `data`. + * Must be last for serialization purposes */ - uintptr_t datalen; -} LDKCVec_NodeAnnouncementZ; + 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_NoneLightningErrorZ @@ -6158,6 +6452,97 @@ typedef struct LDKCResult_SecretKeyNoneZ { bool result_ok; } LDKCResult_SecretKeyNoneZ; +/** + * The contents of CResult_PublicKeyNoneZ + */ +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 LDKPublicKey *result; + /** + * Note that this value is always NULL, as there are no contents in the Err variant + */ + void *err; +} LDKCResult_PublicKeyNoneZPtr; + +/** + * 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_PublicKeyNoneZ { + /** + * The contents of this CResult_PublicKeyNoneZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_PublicKeyNoneZPtr contents; + /** + * Whether this CResult_PublicKeyNoneZ represents a success state. + */ + bool result_ok; +} LDKCResult_PublicKeyNoneZ; + +/** + * An enum which can either contain a crate::c_types::BigEndianScalar or not + */ +typedef enum LDKCOption_ScalarZ_Tag { + /** + * When we're in this state, this COption_ScalarZ contains a crate::c_types::BigEndianScalar + */ + LDKCOption_ScalarZ_Some, + /** + * When we're in this state, this COption_ScalarZ contains nothing + */ + LDKCOption_ScalarZ_None, + /** + * Must be last for serialization purposes + */ + 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 { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKThirtyTwoBytes *result; + /** + * Note that this value is always NULL, as there are no contents in the Err variant + */ + void *err; +} LDKCResult_SharedSecretNoneZPtr; + +/** + * 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 contents of this CResult_SharedSecretNoneZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_SharedSecretNoneZPtr contents; + /** + * Whether this CResult_SharedSecretNoneZ represents a success state. + */ + bool result_ok; +} LDKCResult_SharedSecretNoneZ; + /** @@ -6377,6 +6762,11 @@ typedef struct LDKBaseSign { * chosen to forgo their output as dust. */ struct LDKCResult_SignatureNoneZ (*sign_closing_transaction)(const void *this_arg, const struct LDKClosingTransaction *NONNULL_PTR closing_tx); + /** + * 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 LDKCResult_SignatureNoneZ (*sign_holder_anchor_input)(const void *this_arg, struct LDKTransaction anchor_tx, uintptr_t input); /** * 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. @@ -6848,10 +7238,16 @@ typedef enum LDKAPIError_Tag { */ LDKAPIError_ChannelUnavailable, /** - * An attempt to call watch/update_channel returned an Err (ie you did this!), causing the - * attempted action to fail. + * 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. + * + * [`chain::Watch::watch_channel`]: crate::chain::Watch::watch_channel + * [`chain::Watch::update_channel`]: crate::chain::Watch::update_channel + * [`ChannelMonitorUpdateStatus::InProgress`]: crate::chain::ChannelMonitorUpdateStatus::InProgress */ - LDKAPIError_MonitorUpdateFailed, + LDKAPIError_MonitorUpdateInProgress, /** * [`KeysInterface::get_shutdown_scriptpubkey`] returned a shutdown scriptpubkey incompatible * with the channel counterparty as negotiated in [`InitFeatures`]. @@ -7050,13 +7446,13 @@ typedef enum LDKPaymentSendFailure_Tag { * 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). + * 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::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. + * 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. */ LDKPaymentSendFailure_PartialFailure, /** @@ -7619,8 +8015,13 @@ typedef struct LDKCVec_ChannelMonitorZ { /** - * An update generated by the underlying Channel itself which contains some new information the - * ChannelMonitor should be made aware of. + * An update generated by the underlying channel itself which contains some new information the + * [`ChannelMonitor`] should be made aware of. + * + * 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 LDKChannelMonitorUpdate { /** @@ -7653,10 +8054,10 @@ typedef struct MUST_USE_STRUCT LDKChannelMonitorUpdate { * 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 + * funds in the channel. See [`ChannelMonitorUpdateStatus`] for more details about how to handle * multiple instances. * - * [`PermanentFailure`]: ChannelMonitorUpdateErr::PermanentFailure + * [`PermanentFailure`]: ChannelMonitorUpdateStatus::PermanentFailure */ typedef struct LDKWatch { /** @@ -7671,23 +8072,23 @@ typedef struct LDKWatch { * 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 + * 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 */ - struct LDKCResult_NoneChannelMonitorUpdateErrZ (*watch_channel)(const void *this_arg, struct LDKOutPoint funding_txo, struct LDKChannelMonitor monitor); + enum LDKChannelMonitorUpdateStatus (*watch_channel)(const void *this_arg, struct LDKOutPoint funding_txo, struct LDKChannelMonitor monitor); /** * Updates a channel identified by `funding_txo` by applying `update` to its monitor. * * Implementations must call [`update_monitor`] with the given update. See - * [`ChannelMonitorUpdateErr`] for invariants around returning an error. + * [`ChannelMonitorUpdateStatus`] for invariants around returning an error. * * [`update_monitor`]: channelmonitor::ChannelMonitor::update_monitor */ - struct LDKCResult_NoneChannelMonitorUpdateErrZ (*update_channel)(const void *this_arg, struct LDKOutPoint funding_txo, struct LDKChannelMonitorUpdate update); + enum LDKChannelMonitorUpdateStatus (*update_channel)(const void *this_arg, struct LDKOutPoint funding_txo, struct LDKChannelMonitorUpdate update); /** * Returns any monitor events since the last call. Subsequent calls must only return new * events. @@ -7697,7 +8098,7 @@ typedef struct LDKWatch { * to disk. * * For details on asynchronous [`ChannelMonitor`] updating and returning - * [`MonitorEvent::UpdateCompleted`] here, see [`ChannelMonitorUpdateErr::TemporaryFailure`]. + * [`MonitorEvent::Completed`] here, see [`ChannelMonitorUpdateStatus::InProgress`]. */ struct LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ (*release_pending_monitor_events)(const void *this_arg); /** @@ -7758,8 +8159,32 @@ typedef struct LDKKeysInterface { * * 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. */ 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. * @@ -7806,6 +8231,8 @@ typedef struct LDKKeysInterface { * 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); /** @@ -8207,6 +8634,62 @@ typedef struct LDKCResult_PaymentIdPaymentErrorZ { bool result_ok; } LDKCResult_PaymentIdPaymentErrorZ; + + +/** + * 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 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 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_InFlightHtlcsDecodeErrorZPtr; + +/** + * 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_InFlightHtlcsDecodeErrorZ { + /** + * The contents of this CResult_InFlightHtlcsDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_InFlightHtlcsDecodeErrorZPtr contents; + /** + * Whether this CResult_InFlightHtlcsDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_InFlightHtlcsDecodeErrorZ; + /** * Sub-errors which don't have specific information in them use this type. */ @@ -9176,7 +9659,21 @@ typedef enum LDKBalance_Tag { * 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. */ - LDKBalance_MaybeClaimableHTLCAwaitingTimeout, + LDKBalance_MaybeTimeoutClaimableHTLC, + /** + * 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. + */ + LDKBalance_MaybePreimageClaimableHTLC, + /** + * 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. + */ + LDKBalance_CounterpartyRevokedOutputClaimable, /** * Must be last for serialization purposes */ @@ -9217,10 +9714,10 @@ typedef struct LDKBalance_LDKContentiousClaimable_Body { uint32_t timeout_height; } LDKBalance_LDKContentiousClaimable_Body; -typedef struct LDKBalance_LDKMaybeClaimableHTLCAwaitingTimeout_Body { +typedef struct LDKBalance_LDKMaybeTimeoutClaimableHTLC_Body { /** - * The amount available to claim, in satoshis, excluding the on-chain fees which will be - * required to do so. + * The amount potentially available to claim, in satoshis, excluding the on-chain fees + * which will be required to do so. */ uint64_t claimable_amount_satoshis; /** @@ -9228,7 +9725,30 @@ typedef struct LDKBalance_LDKMaybeClaimableHTLCAwaitingTimeout_Body { * done so. */ uint32_t claimable_height; -} LDKBalance_LDKMaybeClaimableHTLCAwaitingTimeout_Body; +} LDKBalance_LDKMaybeTimeoutClaimableHTLC_Body; + +typedef struct LDKBalance_LDKMaybePreimageClaimableHTLC_Body { + /** + * The amount potentially 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 our counterparty will be able to claim the balance if we have not + * yet received the preimage and claimed it ourselves. + */ + uint32_t expiry_height; +} LDKBalance_LDKMaybePreimageClaimableHTLC_Body; + +typedef struct LDKBalance_LDKCounterpartyRevokedOutputClaimable_Body { + /** + * 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. + */ + uint64_t claimable_amount_satoshis; +} LDKBalance_LDKCounterpartyRevokedOutputClaimable_Body; typedef struct MUST_USE_STRUCT LDKBalance { LDKBalance_Tag tag; @@ -9236,7 +9756,9 @@ typedef struct MUST_USE_STRUCT LDKBalance { 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_LDKMaybeTimeoutClaimableHTLC_Body maybe_timeout_claimable_htlc; + LDKBalance_LDKMaybePreimageClaimableHTLC_Body maybe_preimage_claimable_htlc; + LDKBalance_LDKCounterpartyRevokedOutputClaimable_Body counterparty_revoked_output_claimable; }; } LDKBalance; @@ -9320,36 +9842,120 @@ typedef struct LDKCVec_C2Tuple_PublicKeyTypeZZ { } LDKCVec_C2Tuple_PublicKeyTypeZZ; /** - * An enum which can either contain a crate::lightning::ln::msgs::NetAddress or not + * The contents of a custom onion message. */ -typedef enum LDKCOption_NetAddressZ_Tag { +typedef struct LDKCustomOnionMessageContents { /** - * When we're in this state, this COption_NetAddressZ contains a crate::lightning::ln::msgs::NetAddress + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. */ - LDKCOption_NetAddressZ_Some, + void *this_arg; /** - * When we're in this state, this COption_NetAddressZ contains nothing + * Returns the TLV type identifying the message contents. MUST be >= 64. */ - LDKCOption_NetAddressZ_None, + 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; + +/** + * An enum which can either contain a crate::lightning::onion_message::packet::CustomOnionMessageContents or not + */ +typedef enum LDKCOption_CustomOnionMessageContentsZ_Tag { + /** + * When we're in this state, this COption_CustomOnionMessageContentsZ contains a crate::lightning::onion_message::packet::CustomOnionMessageContents + */ + LDKCOption_CustomOnionMessageContentsZ_Some, + /** + * When we're in this state, this COption_CustomOnionMessageContentsZ contains nothing + */ + LDKCOption_CustomOnionMessageContentsZ_None, /** * Must be last for serialization purposes */ - LDKCOption_NetAddressZ_Sentinel, -} LDKCOption_NetAddressZ_Tag; + LDKCOption_CustomOnionMessageContentsZ_Sentinel, +} LDKCOption_CustomOnionMessageContentsZ_Tag; -typedef struct LDKCOption_NetAddressZ { - LDKCOption_NetAddressZ_Tag tag; +typedef struct LDKCOption_CustomOnionMessageContentsZ { + LDKCOption_CustomOnionMessageContentsZ_Tag tag; union { struct { - struct LDKNetAddress some; + struct LDKCustomOnionMessageContents some; }; }; -} LDKCOption_NetAddressZ; - - +} LDKCOption_CustomOnionMessageContentsZ; /** - * Error for PeerManager errors. If you get one of these, you must disconnect the socket and + * 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; + +/** + * 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 LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ { + /** + * The contents of this CResult_COption_CustomOnionMessageContentsZDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZPtr contents; + /** + * Whether this CResult_COption_CustomOnionMessageContentsZDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ; + +/** + * An enum which can either contain a crate::lightning::ln::msgs::NetAddress or not + */ +typedef enum LDKCOption_NetAddressZ_Tag { + /** + * When we're in this state, this COption_NetAddressZ contains a crate::lightning::ln::msgs::NetAddress + */ + LDKCOption_NetAddressZ_Some, + /** + * When we're in this state, this COption_NetAddressZ contains nothing + */ + LDKCOption_NetAddressZ_None, + /** + * Must be last for serialization purposes + */ + LDKCOption_NetAddressZ_Sentinel, +} LDKCOption_NetAddressZ_Tag; + +typedef struct LDKCOption_NetAddressZ { + LDKCOption_NetAddressZ_Tag tag; + union { + struct { + struct LDKNetAddress some; + }; + }; +} LDKCOption_NetAddressZ; + + + +/** + * 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. */ @@ -9466,6 +10072,85 @@ typedef struct LDKCResult_boolPeerHandleErrorZ { bool result_ok; } LDKCResult_boolPeerHandleErrorZ; +/** + * Errors that may occur when [sending an onion message]. + * + * [sending an onion message]: OnionMessenger::send_custom_onion_message + */ +typedef enum LDKSendError_Tag { + /** + * Errored computing onion message packet keys. + */ + LDKSendError_Secp256k1, + /** + * 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. + */ + LDKSendError_TooBigPacket, + /** + * The provided [`Destination`] was an invalid [`BlindedRoute`], due to having fewer than two + * blinded hops. + */ + LDKSendError_TooFewBlindedHops, + /** + * Our next-hop peer was offline or does not support onion message forwarding. + */ + LDKSendError_InvalidFirstHop, + /** + * Onion message contents must have a TLV type >= 64. + */ + LDKSendError_InvalidMessage, + /** + * Our next-hop peer's buffer was full or our total outbound buffer was full. + */ + LDKSendError_BufferFull, + /** + * Must be last for serialization purposes + */ + LDKSendError_Sentinel, +} LDKSendError_Tag; + +typedef struct MUST_USE_STRUCT LDKSendError { + LDKSendError_Tag tag; + union { + struct { + enum LDKSecp256k1Error secp256k1; + }; + }; +} LDKSendError; + +/** + * The contents of CResult_NoneSendErrorZ + */ +typedef union LDKCResult_NoneSendErrorZPtr { + /** + * 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 LDKSendError *err; +} LDKCResult_NoneSendErrorZPtr; + +/** + * 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_NoneSendErrorZ { + /** + * The contents of this CResult_NoneSendErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_NoneSendErrorZPtr contents; + /** + * Whether this CResult_NoneSendErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_NoneSendErrorZ; + /** * All-encompassing standard error type that processing can return */ @@ -10386,6 +11071,59 @@ typedef struct LDKCResult_UpdateAddHTLCDecodeErrorZ { +/** + * An onion message to be sent or received from a peer + */ +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. + */ + 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; +} LDKOnionMessage; + +/** + * The contents of CResult_OnionMessageDecodeErrorZ + */ +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 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_OnionMessageDecodeErrorZPtr; + +/** + * 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_OnionMessageDecodeErrorZ { + /** + * The contents of this CResult_OnionMessageDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_OnionMessageDecodeErrorZPtr contents; + /** + * Whether this CResult_OnionMessageDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_OnionMessageDecodeErrorZ; + + + /** * A ping message to be sent or received from a peer */ @@ -10761,6 +11499,26 @@ typedef struct LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ { bool result_ok; } LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ; + + +/** + * 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; + /** * The contents of CResult_NodeAnnouncementDecodeErrorZ */ @@ -11066,7 +11824,7 @@ typedef struct LDKCResult_InvoiceSignOrCreationErrorZ { * * 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`]. + * [`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. @@ -11105,9 +11863,9 @@ typedef struct MUST_USE_STRUCT LDKWatchedOutput { * 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`]. + * invocation that has called the `Filter` must return [`InProgress`]. * - * [`TemporaryFailure`]: ChannelMonitorUpdateErr::TemporaryFailure + * [`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 */ @@ -11125,15 +11883,12 @@ typedef struct LDKFilter { /** * 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). + * 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. */ - struct LDKCOption_C2Tuple_usizeTransactionZZ (*register_output)(const void *this_arg, struct LDKWatchedOutput output); + void (*register_output)(const void *this_arg, struct LDKWatchedOutput output); /** * Frees any resources associated with this object given its this_arg pointer. * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. @@ -11260,6 +12015,28 @@ typedef struct LDKMessageSendEventsProvider { void (*free)(void *this_arg); } LDKMessageSendEventsProvider; +/** + * A trait indicating an object may generate onion messages to send + */ +typedef struct LDKOnionMessageProvider { + /** + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. + */ + void *this_arg; + /** + * Gets the next pending onion message for the peer with the given node id. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + */ + struct LDKOnionMessage (*next_onion_message_for_peer)(const void *this_arg, struct LDKPublicKey peer_node_id); + /** + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + */ + void (*free)(void *this_arg); +} LDKOnionMessageProvider; + /** * A trait implemented for objects handling events from [`EventsProvider`]. */ @@ -11289,11 +12066,17 @@ typedef struct LDKEventHandler { * * # 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. + * event since the last invocation. + * + * In order to ensure no [`Event`]s are lost, implementors of this trait will persist [`Event`]s + * and replay any unhandled events on startup. An [`Event`] is considered handled when + * [`process_pending_events`] returns, thus handlers MUST fully handle [`Event`]s and persist any + * relevant changes to disk *before* returning. + * + * Further, because an application may crash between an [`Event`] being handled and the + * implementor of this trait being re-serialized, [`Event`] handling must be idempotent - in + * effect, [`Event`]s may be replayed. * * Note, handlers may call back into the provider and thus deadlocking must be avoided. Be sure to * consult the provider's documentation on the implication of processing events and how a handler @@ -11317,9 +12100,7 @@ typedef struct LDKEventsProvider { /** * 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). + * See the trait-level documentation for requirements. */ void (*process_pending_events)(const void *this_arg, struct LDKEventHandler handler); /** @@ -11355,122 +12136,80 @@ typedef struct MUST_USE_STRUCT LDKBigSize { bool is_owned; } LDKBigSize; - - /** - * Proposed use of a channel passed as a parameter to [`Score::channel_penalty_msat`]. + * Trait that handles persisting a [`ChannelManager`], [`NetworkGraph`], and [`WriteableScore`] to disk. */ -typedef struct MUST_USE_STRUCT LDKChannelUsage { - /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. - */ - LDKnativeChannelUsage *inner; - /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. - */ - bool is_owned; -} LDKChannelUsage; - -/** - * An interface used to score payment channels for path finding. - * - *\tScoring is in terms of fees willing to be paid in order to avoid routing through a channel. - */ -typedef struct LDKScore { +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; /** - * 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. + * Persist the given ['ChannelManager'] to disk, returning an error if persistence failed. */ - 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); + struct LDKCResult_NoneErrorZ (*persist_manager)(const void *this_arg, const struct LDKChannelManager *NONNULL_PTR channel_manager); /** - * Handles updating channel penalties after failing to route through a channel. + * Persist the given [`NetworkGraph`] to disk, returning an error if persistence failed. */ - void (*payment_path_failed)(void *this_arg, struct LDKCVec_RouteHopZ path, uint64_t short_channel_id); + struct LDKCResult_NoneErrorZ (*persist_graph)(const void *this_arg, const struct LDKNetworkGraph *NONNULL_PTR network_graph); /** - * Handles updating channel penalties after successfully routing along a path. + * Persist the given [`WriteableScore`] to disk, returning an error if persistence failed. */ - void (*payment_path_successful)(void *this_arg, struct LDKCVec_RouteHopZ path); + struct LDKCResult_NoneErrorZ (*persist_scorer)(const void *this_arg, const struct LDKWriteableScore *NONNULL_PTR scorer); /** - * Handles updating channel penalties after a probe over the given path failed. + * 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 (*probe_failed)(void *this_arg, struct LDKCVec_RouteHopZ path, uint64_t short_channel_id); + void (*free)(void *this_arg); +} LDKPersister; + +/** + * 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 LDKFutureCallback { /** - * Handles updating channel penalties after a probe over the given path succeeded. + * 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 (*probe_successful)(void *this_arg, struct LDKCVec_RouteHopZ path); + void *this_arg; /** - * Serialize the object into a byte array + * The method which is called. */ - struct LDKCVec_u8Z (*write)(const void *this_arg); + 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); -} LDKScore; +} LDKFutureCallback; /** - * A concrete implementation of [`LockableScore`] which supports multi-threading. + * A simple future which can complete once, and calls some callback(s) when it does so. */ -typedef struct MUST_USE_STRUCT LDKMultiThreadedLockableScore { +typedef struct MUST_USE_STRUCT LDKFuture { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeMultiThreadedLockableScore *inner; + LDKnativeFuture *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKMultiThreadedLockableScore; - -/** - * Trait that handles persisting a [`ChannelManager`], [`NetworkGraph`], and [`MultiThreadedLockableScore`] to disk. - */ -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; - /** - * Persist the given ['ChannelManager'] to disk, returning an error if persistence failed. - */ - struct LDKCResult_NoneErrorZ (*persist_manager)(const void *this_arg, const struct LDKChannelManager *NONNULL_PTR channel_manager); - /** - * Persist the given [`NetworkGraph`] to disk, returning an error if persistence failed. - */ - struct LDKCResult_NoneErrorZ (*persist_graph)(const void *this_arg, const struct LDKNetworkGraph *NONNULL_PTR network_graph); - /** - * Persist the given [`MultiThreadedLockableScore`] to disk, returning an error if persistence failed. - */ - struct LDKCResult_NoneErrorZ (*persist_scorer)(const void *this_arg, const struct LDKMultiThreadedLockableScore *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); -} LDKPersister; +} LDKFuture; @@ -11658,7 +12397,7 @@ typedef struct LDKConfirm { * 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 + * [chain order]: Confirm#order * [`best_block_updated`]: Self::best_block_updated */ void (*transactions_confirmed)(const void *this_arg, const uint8_t (*header)[80], struct LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height); @@ -11666,8 +12405,8 @@ typedef struct LDKConfirm { * 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`]. + * 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 @@ -11683,9 +12422,9 @@ typedef struct LDKConfirm { /** * 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. + * 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 @@ -11729,20 +12468,21 @@ typedef struct MUST_USE_STRUCT LDKMonitorUpdateId { * * 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. + * 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 - * `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`]. + * [`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 - * `Err(ChannelMonitorUpdateErr::PermanentFailure)`, in which case the channel will likely be + * [`ChannelMonitorUpdateStatus::PermanentFailure`], in which case the channel will likely be * closed without broadcasting the latest state. See - * [`ChannelMonitorUpdateErr::PermanentFailure`] for more details. + * [`ChannelMonitorUpdateStatus::PermanentFailure`] for more details. */ typedef struct LDKPersist { /** @@ -11759,15 +12499,15 @@ typedef struct LDKPersist { * 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`]. + * if you return [`ChannelMonitorUpdateStatus::InProgress`]. * * See [`Writeable::write`] on [`ChannelMonitor`] for writing out a `ChannelMonitor` - * and [`ChannelMonitorUpdateErr`] for requirements when returning errors. + * and [`ChannelMonitorUpdateStatus`] for requirements when returning errors. * * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager * [`Writeable::write`]: crate::util::ser::Writeable::write */ - struct LDKCResult_NoneChannelMonitorUpdateErrZ (*persist_new_channel)(const void *this_arg, struct LDKOutPoint channel_id, const struct LDKChannelMonitor *NONNULL_PTR data, struct LDKMonitorUpdateId update_id); + enum LDKChannelMonitorUpdateStatus (*persist_new_channel)(const void *this_arg, struct LDKOutPoint channel_id, const struct LDKChannelMonitor *NONNULL_PTR data, struct LDKMonitorUpdateId update_id); /** * Update one channel's data. The provided [`ChannelMonitor`] has already applied the given * update. @@ -11795,17 +12535,17 @@ typedef struct LDKPersist { * 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`]. + * 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 - * [`ChannelMonitorUpdateErr`] for requirements when returning errors. + * [`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 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); + 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. @@ -11931,16 +12671,6 @@ typedef struct MUST_USE_STRUCT LDKChainParameters { bool is_owned; } LDKChainParameters; -/** - * A 3-byte byte array. - */ -typedef struct LDKThreeBytes { - /** - * The three bytes - */ - uint8_t data[3]; -} LDKThreeBytes; - /** * A trait to describe an object which can receive channel messages. * @@ -12018,12 +12748,19 @@ typedef struct LDKChannelMessageHandler { * 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. */ - void (*peer_connected)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKInit *NONNULL_PTR msg); + 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. */ @@ -12036,6 +12773,20 @@ typedef struct LDKChannelMessageHandler { * 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. */ @@ -12144,6 +12895,16 @@ typedef struct MUST_USE_STRUCT LDKDataLossProtect { bool is_owned; } LDKDataLossProtect; +/** + * A 3-byte byte array. + */ +typedef struct LDKThreeBytes { + /** + * The three bytes + */ + uint8_t data[3]; +} LDKThreeBytes; + /** * A trait to describe an object which can receive routing messages. * @@ -12175,26 +12936,31 @@ typedef struct LDKRoutingMessageHandler { */ 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. + * 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 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ (*get_next_channel_announcements)(const void *this_arg, uint64_t starting_point, uint8_t batch_amount); + struct LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ (*get_next_channel_announcement)(const void *this_arg, uint64_t starting_point); /** - * 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. + * 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 LDKCVec_NodeAnnouncementZ (*get_next_node_announcements)(const void *this_arg, struct LDKPublicKey starting_point, uint8_t batch_amount); + struct LDKNodeAnnouncement (*get_next_node_announcement)(const void *this_arg, struct LDKPublicKey starting_point); /** * 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 (*peer_connected)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKInit *NONNULL_PTR init); + struct LDKCResult_NoneNoneZ (*peer_connected)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKInit *NONNULL_PTR init); /** * Handles the reply of a query we initiated to learn about channels * for a given range of blocks. We can expect to receive one or more @@ -12218,6 +12984,20 @@ typedef struct LDKRoutingMessageHandler { * 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. */ @@ -12229,6 +13009,61 @@ typedef struct LDKRoutingMessageHandler { 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; + /** + * 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. + * + * 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 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); +} LDKOnionMessageHandler; + /** * Trait to be implemented by custom message (unrelated to the channel/gossip LN layers) * decoders. @@ -12306,6 +13141,40 @@ typedef struct MUST_USE_STRUCT LDKIgnoringMessageHandler { 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 [`OnionMessenger`] for example usage. + * + * [`IgnoringMessageHandler`]: crate::ln::peer_handler::IgnoringMessageHandler + * [`CustomMessage`]: Self::CustomMessage + */ +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; + /** @@ -12624,32 +13493,45 @@ typedef struct MUST_USE_STRUCT LDKEffectiveCapacity { }; } LDKEffectiveCapacity; + + /** - * 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 + * A concrete implementation of [`LockableScore`] which supports multi-threading. */ -typedef struct LDKLockableScore { +typedef struct MUST_USE_STRUCT LDKMultiThreadedLockableScore { /** - * 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; + LDKnativeMultiThreadedLockableScore *inner; /** - * Returns the locked scorer. + * Indicates that this is the only struct which contains the same pointer. + * Rust 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 LDKScore (*lock)(const void *this_arg); + bool is_owned; +} LDKMultiThreadedLockableScore; + + + +/** + * A locked `MultiThreadedLockableScore`. + */ +typedef struct MUST_USE_STRUCT LDKMultiThreadedScoreLock { /** - * 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 opaque Rust object. + * Nearly everywhere, 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 (*free)(void *this_arg); -} LDKLockableScore; + 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; @@ -12668,14 +13550,134 @@ typedef struct MUST_USE_STRUCT LDKProbabilisticScoringParameters { * Nearly everywhere, 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; + 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, /** - * Indicates that this is the only struct which contains the same pointer. - * Rust 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; -} LDKProbabilisticScoringParameters; + LDKDestination_Sentinel, +} LDKDestination_Tag; + +typedef struct MUST_USE_STRUCT LDKDestination { + LDKDestination_Tag tag; + union { + struct { + struct LDKPublicKey node; + }; + struct { + struct LDKBlindedRoute blinded_route; + }; + }; +} LDKDestination; @@ -12720,8 +13722,8 @@ typedef struct MUST_USE_STRUCT LDKFilesystemPersister { * [`ChannelManager`] persistence should be done in the background. * * Calling [`ChannelManager::timer_tick_occurred`] and [`PeerManager::timer_tick_occurred`] * at the appropriate intervals. - * * Calling [`NetworkGraph::remove_stale_channels`] (if a [`GossipSync`] with a [`NetworkGraph`] - * is provided to [`BackgroundProcessor::start`]). + * * 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. @@ -12755,7 +13757,8 @@ typedef struct MUST_USE_STRUCT LDKBackgroundProcessor { /** - * Rapid Gossip Sync struct + * The main Rapid Gossip Sync object. + * * See [crate-level documentation] for usage. * * [crate-level documentation]: crate @@ -12993,7 +13996,23 @@ typedef struct LDKRouter { * * Note that first_hops (or a relevant inner pointer) may be NULL or all-0s to represent None */ - struct LDKCResult_RouteLightningErrorZ (*find_route)(const void *this_arg, struct LDKPublicKey payer, const struct LDKRouteParameters *NONNULL_PTR route_params, const uint8_t (*payment_hash)[32], struct LDKCVec_ChannelDetailsZ *first_hops, const struct LDKScore *NONNULL_PTR scorer); + struct LDKCResult_RouteLightningErrorZ (*find_route)(const void *this_arg, struct LDKPublicKey payer, const struct LDKRouteParameters *NONNULL_PTR route_params, const uint8_t (*payment_hash)[32], struct LDKCVec_ChannelDetailsZ *first_hops, 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. @@ -13134,6 +14153,11 @@ 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` */ @@ -13177,6 +14201,71 @@ void Str_free(struct LDKStr _res); 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. */ @@ -13674,6 +14763,21 @@ void CResult_ShutdownScriptInvalidShutdownScriptZ_free(struct LDKCResult_Shutdow */ 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. */ @@ -13933,11 +15037,6 @@ void CResult_RouteLightningErrorZ_free(struct LDKCResult_RouteLightningErrorZ _r */ struct LDKCResult_RouteLightningErrorZ CResult_RouteLightningErrorZ_clone(const struct LDKCResult_RouteLightningErrorZ *NONNULL_PTR orig); -/** - * Frees the buffer pointed to by `data` if `datalen` is non-0. - */ -void CVec_PublicKeyZ_free(struct LDKCVec_PublicKeyZ _res); - /** * Creates a new CResult_PaymentPurposeDecodeErrorZ in the success state. */ @@ -14188,32 +15287,6 @@ void CVec_C2Tuple_usizeTransactionZZ_free(struct LDKCVec_C2Tuple_usizeTransactio */ void CVec_TxidZ_free(struct LDKCVec_TxidZ _res); -/** - * Creates a new CResult_NoneChannelMonitorUpdateErrZ in the success state. - */ -struct LDKCResult_NoneChannelMonitorUpdateErrZ CResult_NoneChannelMonitorUpdateErrZ_ok(void); - -/** - * Creates a new CResult_NoneChannelMonitorUpdateErrZ in the error state. - */ -struct LDKCResult_NoneChannelMonitorUpdateErrZ CResult_NoneChannelMonitorUpdateErrZ_err(enum LDKChannelMonitorUpdateErr e); - -/** - * Checks if the given object is currently in the success state - */ -bool CResult_NoneChannelMonitorUpdateErrZ_is_ok(const struct LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR o); - -/** - * Frees any resources used by the CResult_NoneChannelMonitorUpdateErrZ. - */ -void CResult_NoneChannelMonitorUpdateErrZ_free(struct LDKCResult_NoneChannelMonitorUpdateErrZ _res); - -/** - * Creates a new CResult_NoneChannelMonitorUpdateErrZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. - */ -struct LDKCResult_NoneChannelMonitorUpdateErrZ CResult_NoneChannelMonitorUpdateErrZ_clone(const struct LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR orig); - /** * Frees the buffer pointed to by `data` if `datalen` is non-0. */ @@ -14240,27 +15313,6 @@ void C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_free(struct LDKC3Tuple_OutPoin */ void CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ_free(struct LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ _res); -/** - * Constructs a new COption_C2Tuple_usizeTransactionZZ containing a crate::c_types::derived::C2Tuple_usizeTransactionZ - */ -struct LDKCOption_C2Tuple_usizeTransactionZZ COption_C2Tuple_usizeTransactionZZ_some(struct LDKC2Tuple_usizeTransactionZ o); - -/** - * Constructs a new COption_C2Tuple_usizeTransactionZZ containing nothing - */ -struct LDKCOption_C2Tuple_usizeTransactionZZ COption_C2Tuple_usizeTransactionZZ_none(void); - -/** - * Frees any resources associated with the crate::c_types::derived::C2Tuple_usizeTransactionZ, if we are in the Some state - */ -void COption_C2Tuple_usizeTransactionZZ_free(struct LDKCOption_C2Tuple_usizeTransactionZZ _res); - -/** - * Creates a new COption_C2Tuple_usizeTransactionZZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. - */ -struct LDKCOption_C2Tuple_usizeTransactionZZ COption_C2Tuple_usizeTransactionZZ_clone(const struct LDKCOption_C2Tuple_usizeTransactionZZ *NONNULL_PTR orig); - /** * Creates a new CResult_FixedPenaltyScorerDecodeErrorZ in the success state. */ @@ -14589,14 +15641,25 @@ struct LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ C3Tuple_Channel void C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(struct LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Constructs a new COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ containing a crate::c_types::derived::C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ */ -void CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(struct LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res); +struct LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_some(struct LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ o); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * 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. */ -void CVec_NodeAnnouncementZ_free(struct LDKCVec_NodeAnnouncementZ _res); +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. @@ -15045,6 +16108,73 @@ void CResult_SecretKeyNoneZ_free(struct LDKCResult_SecretKeyNoneZ _res); */ struct LDKCResult_SecretKeyNoneZ CResult_SecretKeyNoneZ_clone(const struct LDKCResult_SecretKeyNoneZ *NONNULL_PTR orig); +/** + * Creates a new CResult_PublicKeyNoneZ in the success state. + */ +struct LDKCResult_PublicKeyNoneZ CResult_PublicKeyNoneZ_ok(struct LDKPublicKey o); + +/** + * Creates a new CResult_PublicKeyNoneZ in the error state. + */ +struct LDKCResult_PublicKeyNoneZ CResult_PublicKeyNoneZ_err(void); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_PublicKeyNoneZ_is_ok(const struct LDKCResult_PublicKeyNoneZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_PublicKeyNoneZ. + */ +void CResult_PublicKeyNoneZ_free(struct LDKCResult_PublicKeyNoneZ _res); + +/** + * Creates a new CResult_PublicKeyNoneZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_PublicKeyNoneZ CResult_PublicKeyNoneZ_clone(const struct LDKCResult_PublicKeyNoneZ *NONNULL_PTR orig); + +/** + * Constructs a new COption_ScalarZ containing a crate::c_types::BigEndianScalar + */ +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_SharedSecretNoneZ in the error state. + */ +struct LDKCResult_SharedSecretNoneZ CResult_SharedSecretNoneZ_err(void); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_SharedSecretNoneZ_is_ok(const struct LDKCResult_SharedSecretNoneZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_SharedSecretNoneZ. + */ +void CResult_SharedSecretNoneZ_free(struct LDKCResult_SharedSecretNoneZ _res); + +/** + * Creates a new CResult_SharedSecretNoneZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_SharedSecretNoneZ CResult_SharedSecretNoneZ_clone(const struct LDKCResult_SharedSecretNoneZ *NONNULL_PTR orig); + /** * Creates a new CResult_SignDecodeErrorZ in the success state. */ @@ -15810,6 +16940,26 @@ void CResult_PaymentIdPaymentErrorZ_free(struct LDKCResult_PaymentIdPaymentError */ struct LDKCResult_PaymentIdPaymentErrorZ CResult_PaymentIdPaymentErrorZ_clone(const struct LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR orig); +/** + * Creates a new CResult_InFlightHtlcsDecodeErrorZ in the success state. + */ +struct LDKCResult_InFlightHtlcsDecodeErrorZ CResult_InFlightHtlcsDecodeErrorZ_ok(struct LDKInFlightHtlcs o); + +/** + * Creates a new CResult_InFlightHtlcsDecodeErrorZ in the error state. + */ +struct LDKCResult_InFlightHtlcsDecodeErrorZ CResult_InFlightHtlcsDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_InFlightHtlcsDecodeErrorZ_is_ok(const struct LDKCResult_InFlightHtlcsDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_InFlightHtlcsDecodeErrorZ. + */ +void CResult_InFlightHtlcsDecodeErrorZ_free(struct LDKCResult_InFlightHtlcsDecodeErrorZ _res); + /** * Creates a new CResult_SiPrefixParseErrorZ in the success state. */ @@ -16340,6 +17490,41 @@ void C2Tuple_PublicKeyTypeZ_free(struct LDKC2Tuple_PublicKeyTypeZ _res); */ void CVec_C2Tuple_PublicKeyTypeZZ_free(struct LDKCVec_C2Tuple_PublicKeyTypeZZ _res); +/** + * Constructs a new COption_CustomOnionMessageContentsZ containing a crate::lightning::onion_message::packet::CustomOnionMessageContents + */ +struct LDKCOption_CustomOnionMessageContentsZ COption_CustomOnionMessageContentsZ_some(struct LDKCustomOnionMessageContents o); + +/** + * Constructs a new COption_CustomOnionMessageContentsZ containing nothing + */ +struct LDKCOption_CustomOnionMessageContentsZ COption_CustomOnionMessageContentsZ_none(void); + +/** + * Frees any resources associated with the crate::lightning::onion_message::packet::CustomOnionMessageContents, if we are in the Some state + */ +void COption_CustomOnionMessageContentsZ_free(struct LDKCOption_CustomOnionMessageContentsZ _res); + +/** + * Creates a new CResult_COption_CustomOnionMessageContentsZDecodeErrorZ in the success state. + */ +struct LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_ok(struct LDKCOption_CustomOnionMessageContentsZ o); + +/** + * Creates a new CResult_COption_CustomOnionMessageContentsZDecodeErrorZ in the error state. + */ +struct LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_is_ok(const struct LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_COption_CustomOnionMessageContentsZDecodeErrorZ. + */ +void CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_free(struct LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ _res); + /** * Constructs a new COption_NetAddressZ containing a crate::lightning::ln::msgs::NetAddress */ @@ -16439,6 +17624,26 @@ void CResult_boolPeerHandleErrorZ_free(struct LDKCResult_boolPeerHandleErrorZ _r */ struct LDKCResult_boolPeerHandleErrorZ CResult_boolPeerHandleErrorZ_clone(const struct LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR orig); +/** + * Creates a new CResult_NoneSendErrorZ in the success state. + */ +struct LDKCResult_NoneSendErrorZ CResult_NoneSendErrorZ_ok(void); + +/** + * Creates a new CResult_NoneSendErrorZ in the error state. + */ +struct LDKCResult_NoneSendErrorZ CResult_NoneSendErrorZ_err(struct LDKSendError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_NoneSendErrorZ_is_ok(const struct LDKCResult_NoneSendErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_NoneSendErrorZ. + */ +void CResult_NoneSendErrorZ_free(struct LDKCResult_NoneSendErrorZ _res); + /** * Creates a new CResult_u32GraphSyncErrorZ in the success state. */ @@ -16973,6 +18178,32 @@ void CResult_UpdateAddHTLCDecodeErrorZ_free(struct LDKCResult_UpdateAddHTLCDecod */ 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_OnionMessageDecodeErrorZ_is_ok(const struct LDKCResult_OnionMessageDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_OnionMessageDecodeErrorZ. + */ +void CResult_OnionMessageDecodeErrorZ_free(struct LDKCResult_OnionMessageDecodeErrorZ _res); + +/** + * Creates a new CResult_OnionMessageDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_OnionMessageDecodeErrorZ CResult_OnionMessageDecodeErrorZ_clone(const struct LDKCResult_OnionMessageDecodeErrorZ *NONNULL_PTR orig); + /** * Creates a new CResult_PingDecodeErrorZ in the success state. */ @@ -17514,6 +18745,12 @@ struct LDKClosureReason ClosureReason_disconnected_peer(void); */ struct LDKClosureReason ClosureReason_outdated_channel_manager(void); +/** + * Checks if two ClosureReasons contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + */ +bool ClosureReason_eq(const struct LDKClosureReason *NONNULL_PTR a, const struct LDKClosureReason *NONNULL_PTR b); + /** * Serialize the ClosureReason object into a byte array which can be read by ClosureReason_read */ @@ -17549,6 +18786,12 @@ struct LDKHTLCDestination HTLCDestination_unknown_next_hop(uint64_t requested_fo */ struct LDKHTLCDestination HTLCDestination_failed_payment(struct LDKThirtyTwoBytes payment_hash); +/** + * Checks if two HTLCDestinations contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + */ +bool HTLCDestination_eq(const struct LDKHTLCDestination *NONNULL_PTR a, const struct LDKHTLCDestination *NONNULL_PTR b); + /** * Serialize the HTLCDestination object into a byte array which can be read by HTLCDestination_read */ @@ -17602,7 +18845,7 @@ struct LDKEvent Event_payment_path_successful(struct LDKThirtyTwoBytes payment_i /** * Utility method to constructs a new PaymentPathFailed-variant Event */ -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 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); /** * Utility method to constructs a new ProbeSuccessful-variant Event @@ -17725,14 +18968,14 @@ struct LDKMessageSendEvent MessageSendEvent_send_shutdown(struct LDKPublicKey no struct LDKMessageSendEvent MessageSendEvent_send_channel_reestablish(struct LDKPublicKey node_id, struct LDKChannelReestablish msg); /** - * Utility method to constructs a new BroadcastChannelAnnouncement-variant MessageSendEvent + * Utility method to constructs a new SendChannelAnnouncement-variant MessageSendEvent */ -struct LDKMessageSendEvent MessageSendEvent_broadcast_channel_announcement(struct LDKChannelAnnouncement msg, struct LDKChannelUpdate update_msg); +struct LDKMessageSendEvent MessageSendEvent_send_channel_announcement(struct LDKPublicKey node_id, struct LDKChannelAnnouncement msg, struct LDKChannelUpdate update_msg); /** - * Utility method to constructs a new BroadcastNodeAnnouncement-variant MessageSendEvent + * Utility method to constructs a new BroadcastChannelAnnouncement-variant MessageSendEvent */ -struct LDKMessageSendEvent MessageSendEvent_broadcast_node_announcement(struct LDKNodeAnnouncement msg); +struct LDKMessageSendEvent MessageSendEvent_broadcast_channel_announcement(struct LDKChannelAnnouncement msg, struct LDKChannelUpdate update_msg); /** * Utility method to constructs a new BroadcastChannelUpdate-variant MessageSendEvent @@ -17774,6 +19017,11 @@ struct LDKMessageSendEvent MessageSendEvent_send_gossip_timestamp_filter(struct */ void MessageSendEventsProvider_free(struct LDKMessageSendEventsProvider this_ptr); +/** + * Calls the free function if one is set + */ +void OnionMessageProvider_free(struct LDKOnionMessageProvider this_ptr); + /** * Calls the free function if one is set */ @@ -17815,15 +19063,21 @@ struct LDKAPIError APIError_route_error(struct LDKStr err); struct LDKAPIError APIError_channel_unavailable(struct LDKStr err); /** - * Utility method to constructs a new MonitorUpdateFailed-variant APIError + * Utility method to constructs a new MonitorUpdateInProgress-variant APIError */ -struct LDKAPIError APIError_monitor_update_failed(void); +struct LDKAPIError APIError_monitor_update_in_progress(void); /** * Utility method to constructs a new IncompatibleShutdownScript-variant APIError */ struct LDKAPIError APIError_incompatible_shutdown_script(struct LDKShutdownScript script); +/** + * Checks if two APIErrors contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + */ +bool APIError_eq(const struct LDKAPIError *NONNULL_PTR a, const struct LDKAPIError *NONNULL_PTR b); + /** * Frees any resources used by the BigSize, if is_owned is set and inner is non-NULL. */ @@ -17844,9 +19098,16 @@ MUST_USE_RES struct LDKBigSize BigSize_new(uint64_t a_arg); void Hostname_free(struct LDKHostname this_obj); /** - * Creates a copy of the Hostname + * Creates a copy of the Hostname + */ +struct LDKHostname Hostname_clone(const struct LDKHostname *NONNULL_PTR orig); + +/** + * 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 LDKHostname Hostname_clone(const struct LDKHostname *NONNULL_PTR orig); +bool Hostname_eq(const struct LDKHostname *NONNULL_PTR a, const struct LDKHostname *NONNULL_PTR b); /** * Returns the length of the hostname. @@ -17881,6 +19142,22 @@ struct LDKCVec_u8Z construct_invoice_preimage(struct LDKu8slice hrp_bytes, struc */ void Persister_free(struct LDKPersister this_ptr); +/** + * Calls the free function if one is set + */ +void FutureCallback_free(struct LDKFutureCallback this_ptr); + +/** + * Frees any resources used by the Future, if is_owned is set and inner is non-NULL. + */ +void Future_free(struct LDKFuture this_obj); + +/** + * Registers a callback to be called upon completion of this future. If the future has already + * completed, the callback will be called immediately. + */ +void Future_register_callback_fn(const struct LDKFuture *NONNULL_PTR this_arg, struct LDKFutureCallback callback); + /** * Creates a copy of the Level */ @@ -18260,10 +19537,62 @@ bool ChannelHandshakeConfig_get_commit_upfront_shutdown_pubkey(const struct LDKC */ void ChannelHandshakeConfig_set_commit_upfront_shutdown_pubkey(struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr, bool val); +/** + * 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. + */ +uint32_t ChannelHandshakeConfig_get_their_channel_reserve_proportional_millionths(const struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr); + +/** + * 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. + */ +void ChannelHandshakeConfig_set_their_channel_reserve_proportional_millionths(struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr, uint32_t val); + /** * Constructs a new ChannelHandshakeConfig given each field */ -MUST_USE_RES struct LDKChannelHandshakeConfig ChannelHandshakeConfig_new(uint32_t minimum_depth_arg, uint16_t our_to_self_delay_arg, uint64_t our_htlc_minimum_msat_arg, uint8_t max_inbound_htlc_value_in_flight_percent_of_channel_arg, bool negotiate_scid_privacy_arg, bool announced_channel_arg, bool commit_upfront_shutdown_pubkey_arg); +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); /** * Creates a copy of the ChannelHandshakeConfig @@ -18614,6 +19943,12 @@ void ChannelConfig_set_cltv_expiry_delta(struct LDKChannelConfig *NONNULL_PTR th * 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 @@ -18633,6 +19968,12 @@ uint64_t ChannelConfig_get_max_dust_htlc_exposure_msat(const struct LDKChannelCo * 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 @@ -18704,6 +20045,13 @@ MUST_USE_RES struct LDKChannelConfig ChannelConfig_new(uint32_t forwarding_fee_p */ struct LDKChannelConfig ChannelConfig_clone(const struct LDKChannelConfig *NONNULL_PTR orig); +/** + * 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 ChannelConfig_eq(const struct LDKChannelConfig *NONNULL_PTR a, const struct LDKChannelConfig *NONNULL_PTR b); + /** * Creates a "default" ChannelConfig. See struct and individual field documentaiton for details on which values are used. */ @@ -18865,6 +20213,13 @@ void BestBlock_free(struct LDKBestBlock this_obj); */ struct LDKBestBlock BestBlock_clone(const struct LDKBestBlock *NONNULL_PTR orig); +/** + * 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. + */ +bool BestBlock_eq(const struct LDKBestBlock *NONNULL_PTR a, const struct LDKBestBlock *NONNULL_PTR b); + /** * Constructs a `BestBlock` that represents the genesis block at height 0 of the given * network. @@ -18917,19 +20272,30 @@ void Listen_free(struct LDKListen this_ptr); void Confirm_free(struct LDKConfirm this_ptr); /** - * Creates a copy of the ChannelMonitorUpdateErr + * Creates a copy of the ChannelMonitorUpdateStatus + */ +enum LDKChannelMonitorUpdateStatus ChannelMonitorUpdateStatus_clone(const enum LDKChannelMonitorUpdateStatus *NONNULL_PTR orig); + +/** + * Utility method to constructs a new Completed-variant ChannelMonitorUpdateStatus + */ +enum LDKChannelMonitorUpdateStatus ChannelMonitorUpdateStatus_completed(void); + +/** + * Utility method to constructs a new InProgress-variant ChannelMonitorUpdateStatus */ -enum LDKChannelMonitorUpdateErr ChannelMonitorUpdateErr_clone(const enum LDKChannelMonitorUpdateErr *NONNULL_PTR orig); +enum LDKChannelMonitorUpdateStatus ChannelMonitorUpdateStatus_in_progress(void); /** - * Utility method to constructs a new TemporaryFailure-variant ChannelMonitorUpdateErr + * Utility method to constructs a new PermanentFailure-variant ChannelMonitorUpdateStatus */ -enum LDKChannelMonitorUpdateErr ChannelMonitorUpdateErr_temporary_failure(void); +enum LDKChannelMonitorUpdateStatus ChannelMonitorUpdateStatus_permanent_failure(void); /** - * Utility method to constructs a new PermanentFailure-variant ChannelMonitorUpdateErr + * Checks if two ChannelMonitorUpdateStatuss contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -enum LDKChannelMonitorUpdateErr ChannelMonitorUpdateErr_permanent_failure(void); +bool ChannelMonitorUpdateStatus_eq(const enum LDKChannelMonitorUpdateStatus *NONNULL_PTR a, const enum LDKChannelMonitorUpdateStatus *NONNULL_PTR b); /** * Calls the free function if one is set @@ -18990,6 +20356,13 @@ MUST_USE_RES struct LDKWatchedOutput WatchedOutput_new(struct LDKThirtyTwoBytes */ struct LDKWatchedOutput WatchedOutput_clone(const struct LDKWatchedOutput *NONNULL_PTR orig); +/** + * 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. + */ +bool WatchedOutput_eq(const struct LDKWatchedOutput *NONNULL_PTR a, const struct LDKWatchedOutput *NONNULL_PTR b); + /** * Checks if two WatchedOutputs contain equal inner contents. */ @@ -19111,12 +20484,12 @@ MUST_USE_RES struct LDKCVec_OutPointZ ChainMonitor_list_monitors(const struct LD /** * Indicates the persistence of a [`ChannelMonitor`] has completed after - * [`ChannelMonitorUpdateErr::TemporaryFailure`] was returned from an update operation. + * [`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 [`ChannelMonitorUpdateErr::TemporaryFailure`], + * 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. @@ -19161,12 +20534,14 @@ void ChannelMonitorUpdate_free(struct LDKChannelMonitorUpdate this_obj); * 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 + * [`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 */ uint64_t ChannelMonitorUpdate_get_update_id(const struct LDKChannelMonitorUpdate *NONNULL_PTR this_ptr); @@ -19176,12 +20551,14 @@ uint64_t ChannelMonitorUpdate_get_update_id(const struct LDKChannelMonitorUpdate * 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 + * [`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 ChannelMonitorUpdate_set_update_id(struct LDKChannelMonitorUpdate *NONNULL_PTR this_ptr, uint64_t val); @@ -19221,15 +20598,21 @@ struct LDKMonitorEvent MonitorEvent_htlcevent(struct LDKHTLCUpdate a); struct LDKMonitorEvent MonitorEvent_commitment_tx_confirmed(struct LDKOutPoint a); /** - * Utility method to constructs a new UpdateCompleted-variant MonitorEvent + * Utility method to constructs a new Completed-variant MonitorEvent */ -struct LDKMonitorEvent MonitorEvent_update_completed(struct LDKOutPoint funding_txo, uint64_t monitor_update_id); +struct LDKMonitorEvent MonitorEvent_completed(struct LDKOutPoint funding_txo, uint64_t monitor_update_id); /** * Utility method to constructs a new UpdateFailed-variant MonitorEvent */ struct LDKMonitorEvent MonitorEvent_update_failed(struct LDKOutPoint a); +/** + * Checks if two MonitorEvents contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + */ +bool MonitorEvent_eq(const struct LDKMonitorEvent *NONNULL_PTR a, const struct LDKMonitorEvent *NONNULL_PTR b); + /** * Serialize the MonitorEvent object into a byte array which can be read by MonitorEvent_read */ @@ -19250,6 +20633,13 @@ void HTLCUpdate_free(struct LDKHTLCUpdate this_obj); */ struct LDKHTLCUpdate HTLCUpdate_clone(const struct LDKHTLCUpdate *NONNULL_PTR orig); +/** + * 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. + */ +bool HTLCUpdate_eq(const struct LDKHTLCUpdate *NONNULL_PTR a, const struct LDKHTLCUpdate *NONNULL_PTR b); + /** * Serialize the HTLCUpdate object into a byte array which can be read by HTLCUpdate_read */ @@ -19286,9 +20676,19 @@ struct LDKBalance Balance_claimable_awaiting_confirmations(uint64_t claimable_am struct LDKBalance Balance_contentious_claimable(uint64_t claimable_amount_satoshis, uint32_t timeout_height); /** - * Utility method to constructs a new MaybeClaimableHTLCAwaitingTimeout-variant Balance + * Utility method to constructs a new MaybeTimeoutClaimableHTLC-variant Balance + */ +struct LDKBalance Balance_maybe_timeout_claimable_htlc(uint64_t claimable_amount_satoshis, uint32_t claimable_height); + +/** + * Utility method to constructs a new MaybePreimageClaimableHTLC-variant Balance + */ +struct LDKBalance Balance_maybe_preimage_claimable_htlc(uint64_t claimable_amount_satoshis, uint32_t expiry_height); + +/** + * Utility method to constructs a new CounterpartyRevokedOutputClaimable-variant Balance */ -struct LDKBalance Balance_maybe_claimable_htlcawaiting_timeout(uint64_t claimable_amount_satoshis, uint32_t claimable_height); +struct LDKBalance Balance_counterparty_revoked_output_claimable(uint64_t claimable_amount_satoshis); /** * Checks if two Balances contain equal inner contents. @@ -19366,14 +20766,20 @@ MUST_USE_RES struct LDKPublicKey ChannelMonitor_get_counterparty_node_id(const s /** * 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. + * 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 */ 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); @@ -19451,8 +20857,9 @@ MUST_USE_RES struct LDKBestBlock ChannelMonitor_current_best_block(const struct * 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. + * 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. @@ -19563,6 +20970,13 @@ uint16_t DelayedPaymentOutputDescriptor_get_to_self_delay(const struct LDKDelaye */ void DelayedPaymentOutputDescriptor_set_to_self_delay(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, uint16_t val); +/** + * The output which is referenced by the given outpoint + * + * Returns a copy of the field. + */ +struct LDKTxOut DelayedPaymentOutputDescriptor_get_output(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr); + /** * The output which is referenced by the given outpoint */ @@ -19614,6 +21028,13 @@ MUST_USE_RES struct LDKDelayedPaymentOutputDescriptor DelayedPaymentOutputDescri */ struct LDKDelayedPaymentOutputDescriptor DelayedPaymentOutputDescriptor_clone(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR orig); +/** + * 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. + */ +bool DelayedPaymentOutputDescriptor_eq(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR a, const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR b); + /** * Serialize the DelayedPaymentOutputDescriptor object into a byte array which can be read by DelayedPaymentOutputDescriptor_read */ @@ -19639,6 +21060,13 @@ struct LDKOutPoint StaticPaymentOutputDescriptor_get_outpoint(const struct LDKSt */ void StaticPaymentOutputDescriptor_set_outpoint(struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKOutPoint val); +/** + * The output which is referenced by the given outpoint + * + * Returns a copy of the field. + */ +struct LDKTxOut StaticPaymentOutputDescriptor_get_output(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr); + /** * The output which is referenced by the given outpoint */ @@ -19678,6 +21106,13 @@ MUST_USE_RES struct LDKStaticPaymentOutputDescriptor StaticPaymentOutputDescript */ struct LDKStaticPaymentOutputDescriptor StaticPaymentOutputDescriptor_clone(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR orig); +/** + * 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. + */ +bool StaticPaymentOutputDescriptor_eq(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR a, const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR b); + /** * Serialize the StaticPaymentOutputDescriptor object into a byte array which can be read by StaticPaymentOutputDescriptor_read */ @@ -19713,6 +21148,12 @@ struct LDKSpendableOutputDescriptor SpendableOutputDescriptor_delayed_payment_ou */ struct LDKSpendableOutputDescriptor SpendableOutputDescriptor_static_payment_output(struct LDKStaticPaymentOutputDescriptor a); +/** + * Checks if two SpendableOutputDescriptors contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + */ +bool SpendableOutputDescriptor_eq(const struct LDKSpendableOutputDescriptor *NONNULL_PTR a, const struct LDKSpendableOutputDescriptor *NONNULL_PTR b); + /** * Serialize the SpendableOutputDescriptor object into a byte array which can be read by SpendableOutputDescriptor_read */ @@ -20791,7 +22232,7 @@ struct LDKPhantomRouteHints PhantomRouteHints_clone(const struct LDKPhantomRoute 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); /** - * Gets the current configuration applied to all new channels, as + * Gets the current configuration applied to all new channels. */ MUST_USE_RES struct LDKUserConfig ChannelManager_get_current_default_configuration(const struct LDKChannelManager *NONNULL_PTR this_arg); @@ -20939,12 +22380,12 @@ void ChannelManager_force_close_all_channels_without_broadcasting_txn(const stru * PaymentSendFailure for more info. * * In general, a path may raise: - * * APIError::RouteError when an invalid route or forwarding parameter (cltv_delta, fee, + * * [`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 + * * [`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 + * * [`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 @@ -21057,28 +22498,6 @@ MUST_USE_RES struct LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ */ 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); -/** - * 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 100). - * - * [`get_and_clear_pending_msg_events`]: MessageSendEventsProvider::get_and_clear_pending_msg_events - */ -void ChannelManager_broadcast_node_announcement(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKThreeBytes rgb, struct LDKThirtyTwoBytes alias, struct LDKCVec_NetAddressZ addresses); - /** * Atomically updates the [`ChannelConfig`] for the given channels. * @@ -21382,6 +22801,13 @@ MUST_USE_RES bool ChannelManager_await_persistable_update_timeout(const struct L */ void ChannelManager_await_persistable_update(const struct LDKChannelManager *NONNULL_PTR this_arg); +/** + * Gets a [`Future`] that completes when a persistable update is available. Note that + * callbacks registered on the [`Future`] MUST NOT call back into this [`ChannelManager`] and + * should instead register actions to be taken later. + */ +MUST_USE_RES struct LDKFuture ChannelManager_get_persistable_update_future(const struct LDKChannelManager *NONNULL_PTR this_arg); + /** * Gets the latest best block which was connected either via the [`chain::Listen`] or * [`chain::Confirm`] interfaces. @@ -21394,6 +22820,24 @@ MUST_USE_RES struct LDKBestBlock ChannelManager_current_best_block(const struct */ struct LDKChannelMessageHandler ChannelManager_as_ChannelMessageHandler(const struct LDKChannelManager *NONNULL_PTR this_arg); +/** + * Fetches the set of [`NodeFeatures`] flags which are provided by or required by + * [`ChannelManager`]. + */ +struct LDKNodeFeatures provided_node_features(void); + +/** + * Fetches the set of [`ChannelFeatures`] flags which are provided by or required by + * [`ChannelManager`]. + */ +struct LDKChannelFeatures provided_channel_features(void); + +/** + * Fetches the set of [`InitFeatures`] flags which are provided by or required by + * [`ChannelManager`]. + */ +struct LDKInitFeatures provided_init_features(void); + /** * Serialize the CounterpartyForwardingInfo object into a byte array which can be read by CounterpartyForwardingInfo_read */ @@ -21579,15 +23023,56 @@ struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ create(const struct LDK 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); /** - * Frees any resources used by the DecodeError, if is_owned is set and inner is non-NULL. + * Frees any resources used by the DecodeError */ -void DecodeError_free(struct LDKDecodeError this_obj); +void DecodeError_free(struct LDKDecodeError this_ptr); /** * Creates a copy of the DecodeError */ struct LDKDecodeError DecodeError_clone(const struct LDKDecodeError *NONNULL_PTR orig); +/** + * Utility method to constructs a new UnknownVersion-variant DecodeError + */ +struct LDKDecodeError DecodeError_unknown_version(void); + +/** + * Utility method to constructs a new UnknownRequiredFeature-variant DecodeError + */ +struct LDKDecodeError DecodeError_unknown_required_feature(void); + +/** + * Utility method to constructs a new InvalidValue-variant DecodeError + */ +struct LDKDecodeError DecodeError_invalid_value(void); + +/** + * Utility method to constructs a new ShortRead-variant DecodeError + */ +struct LDKDecodeError DecodeError_short_read(void); + +/** + * Utility method to constructs a new BadLengthDescriptor-variant DecodeError + */ +struct LDKDecodeError DecodeError_bad_length_descriptor(void); + +/** + * Utility method to constructs a new Io-variant DecodeError + */ +struct LDKDecodeError DecodeError_io(enum LDKIOError a); + +/** + * Utility method to constructs a new UnsupportedCompression-variant DecodeError + */ +struct LDKDecodeError DecodeError_unsupported_compression(void); + +/** + * Checks if two DecodeErrors contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + */ +bool DecodeError_eq(const struct LDKDecodeError *NONNULL_PTR a, const struct LDKDecodeError *NONNULL_PTR b); + /** * Frees any resources used by the Init, if is_owned is set and inner is non-NULL. */ @@ -21629,6 +23114,13 @@ MUST_USE_RES struct LDKInit Init_new(struct LDKInitFeatures features_arg, struct */ struct LDKInit Init_clone(const struct LDKInit *NONNULL_PTR orig); +/** + * 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. + */ +bool Init_eq(const struct LDKInit *NONNULL_PTR a, const struct LDKInit *NONNULL_PTR b); + /** * Frees any resources used by the ErrorMessage, if is_owned is set and inner is non-NULL. */ @@ -21676,6 +23168,13 @@ MUST_USE_RES struct LDKErrorMessage ErrorMessage_new(struct LDKThirtyTwoBytes ch */ struct LDKErrorMessage ErrorMessage_clone(const struct LDKErrorMessage *NONNULL_PTR orig); +/** + * 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. + */ +bool ErrorMessage_eq(const struct LDKErrorMessage *NONNULL_PTR a, const struct LDKErrorMessage *NONNULL_PTR b); + /** * Frees any resources used by the WarningMessage, if is_owned is set and inner is non-NULL. */ @@ -21721,6 +23220,13 @@ MUST_USE_RES struct LDKWarningMessage WarningMessage_new(struct LDKThirtyTwoByte */ struct LDKWarningMessage WarningMessage_clone(const struct LDKWarningMessage *NONNULL_PTR orig); +/** + * 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. + */ +bool WarningMessage_eq(const struct LDKWarningMessage *NONNULL_PTR a, const struct LDKWarningMessage *NONNULL_PTR b); + /** * Frees any resources used by the Ping, if is_owned is set and inner is non-NULL. */ @@ -21758,6 +23264,13 @@ MUST_USE_RES struct LDKPing Ping_new(uint16_t ponglen_arg, uint16_t byteslen_arg */ struct LDKPing Ping_clone(const struct LDKPing *NONNULL_PTR orig); +/** + * 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. + */ +bool Ping_eq(const struct LDKPing *NONNULL_PTR a, const struct LDKPing *NONNULL_PTR b); + /** * Frees any resources used by the Pong, if is_owned is set and inner is non-NULL. */ @@ -21785,6 +23298,13 @@ MUST_USE_RES struct LDKPong Pong_new(uint16_t byteslen_arg); */ struct LDKPong Pong_clone(const struct LDKPong *NONNULL_PTR orig); +/** + * 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. + */ +bool Pong_eq(const struct LDKPong *NONNULL_PTR a, const struct LDKPong *NONNULL_PTR b); + /** * Frees any resources used by the OpenChannel, if is_owned is set and inner is non-NULL. */ @@ -21993,6 +23513,13 @@ void OpenChannel_set_channel_type(struct LDKOpenChannel *NONNULL_PTR this_ptr, s */ struct LDKOpenChannel OpenChannel_clone(const struct LDKOpenChannel *NONNULL_PTR orig); +/** + * 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. + */ +bool OpenChannel_eq(const struct LDKOpenChannel *NONNULL_PTR a, const struct LDKOpenChannel *NONNULL_PTR b); + /** * Frees any resources used by the AcceptChannel, if is_owned is set and inner is non-NULL. */ @@ -22165,6 +23692,13 @@ void AcceptChannel_set_channel_type(struct LDKAcceptChannel *NONNULL_PTR this_pt */ struct LDKAcceptChannel AcceptChannel_clone(const struct LDKAcceptChannel *NONNULL_PTR orig); +/** + * 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. + */ +bool AcceptChannel_eq(const struct LDKAcceptChannel *NONNULL_PTR a, const struct LDKAcceptChannel *NONNULL_PTR b); + /** * Frees any resources used by the FundingCreated, if is_owned is set and inner is non-NULL. */ @@ -22220,6 +23754,13 @@ MUST_USE_RES struct LDKFundingCreated FundingCreated_new(struct LDKThirtyTwoByte */ struct LDKFundingCreated FundingCreated_clone(const struct LDKFundingCreated *NONNULL_PTR orig); +/** + * 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. + */ +bool FundingCreated_eq(const struct LDKFundingCreated *NONNULL_PTR a, const struct LDKFundingCreated *NONNULL_PTR b); + /** * Frees any resources used by the FundingSigned, if is_owned is set and inner is non-NULL. */ @@ -22255,6 +23796,13 @@ MUST_USE_RES struct LDKFundingSigned FundingSigned_new(struct LDKThirtyTwoBytes */ struct LDKFundingSigned FundingSigned_clone(const struct LDKFundingSigned *NONNULL_PTR orig); +/** + * 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. + */ +bool FundingSigned_eq(const struct LDKFundingSigned *NONNULL_PTR a, const struct LDKFundingSigned *NONNULL_PTR b); + /** * Frees any resources used by the ChannelReady, if is_owned is set and inner is non-NULL. */ @@ -22302,6 +23850,13 @@ MUST_USE_RES struct LDKChannelReady ChannelReady_new(struct LDKThirtyTwoBytes ch */ struct LDKChannelReady ChannelReady_clone(const struct LDKChannelReady *NONNULL_PTR orig); +/** + * 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. + */ +bool ChannelReady_eq(const struct LDKChannelReady *NONNULL_PTR a, const struct LDKChannelReady *NONNULL_PTR b); + /** * Frees any resources used by the Shutdown, if is_owned is set and inner is non-NULL. */ @@ -22339,6 +23894,13 @@ MUST_USE_RES struct LDKShutdown Shutdown_new(struct LDKThirtyTwoBytes channel_id */ struct LDKShutdown Shutdown_clone(const struct LDKShutdown *NONNULL_PTR orig); +/** + * 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. + */ +bool Shutdown_eq(const struct LDKShutdown *NONNULL_PTR a, const struct LDKShutdown *NONNULL_PTR b); + /** * Frees any resources used by the ClosingSignedFeeRange, if is_owned is set and inner is non-NULL. */ @@ -22378,6 +23940,13 @@ MUST_USE_RES struct LDKClosingSignedFeeRange ClosingSignedFeeRange_new(uint64_t */ struct LDKClosingSignedFeeRange ClosingSignedFeeRange_clone(const struct LDKClosingSignedFeeRange *NONNULL_PTR orig); +/** + * 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. + */ +bool ClosingSignedFeeRange_eq(const struct LDKClosingSignedFeeRange *NONNULL_PTR a, const struct LDKClosingSignedFeeRange *NONNULL_PTR b); + /** * Frees any resources used by the ClosingSigned, if is_owned is set and inner is non-NULL. */ @@ -22439,6 +24008,13 @@ MUST_USE_RES struct LDKClosingSigned ClosingSigned_new(struct LDKThirtyTwoBytes */ struct LDKClosingSigned ClosingSigned_clone(const struct LDKClosingSigned *NONNULL_PTR orig); +/** + * 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. + */ +bool ClosingSigned_eq(const struct LDKClosingSigned *NONNULL_PTR a, const struct LDKClosingSigned *NONNULL_PTR b); + /** * Frees any resources used by the UpdateAddHTLC, if is_owned is set and inner is non-NULL. */ @@ -22499,6 +24075,40 @@ void UpdateAddHTLC_set_cltv_expiry(struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr */ struct LDKUpdateAddHTLC UpdateAddHTLC_clone(const struct LDKUpdateAddHTLC *NONNULL_PTR orig); +/** + * 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. + */ +bool UpdateAddHTLC_eq(const struct LDKUpdateAddHTLC *NONNULL_PTR a, const struct LDKUpdateAddHTLC *NONNULL_PTR b); + +/** + * Frees any resources used by the OnionMessage, if is_owned is set and inner is non-NULL. + */ +void OnionMessage_free(struct LDKOnionMessage this_obj); + +/** + * Used in decrypting the onion packet's payload. + */ +struct LDKPublicKey OnionMessage_get_blinding_point(const struct LDKOnionMessage *NONNULL_PTR this_ptr); + +/** + * Used in decrypting the onion packet's payload. + */ +void OnionMessage_set_blinding_point(struct LDKOnionMessage *NONNULL_PTR this_ptr, struct LDKPublicKey val); + +/** + * Creates a copy of the OnionMessage + */ +struct LDKOnionMessage OnionMessage_clone(const struct LDKOnionMessage *NONNULL_PTR orig); + +/** + * 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. + */ +bool OnionMessage_eq(const struct LDKOnionMessage *NONNULL_PTR a, const struct LDKOnionMessage *NONNULL_PTR b); + /** * Frees any resources used by the UpdateFulfillHTLC, if is_owned is set and inner is non-NULL. */ @@ -22544,6 +24154,13 @@ MUST_USE_RES struct LDKUpdateFulfillHTLC UpdateFulfillHTLC_new(struct LDKThirtyT */ struct LDKUpdateFulfillHTLC UpdateFulfillHTLC_clone(const struct LDKUpdateFulfillHTLC *NONNULL_PTR orig); +/** + * 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. + */ +bool UpdateFulfillHTLC_eq(const struct LDKUpdateFulfillHTLC *NONNULL_PTR a, const struct LDKUpdateFulfillHTLC *NONNULL_PTR b); + /** * Frees any resources used by the UpdateFailHTLC, if is_owned is set and inner is non-NULL. */ @@ -22574,6 +24191,13 @@ void UpdateFailHTLC_set_htlc_id(struct LDKUpdateFailHTLC *NONNULL_PTR this_ptr, */ struct LDKUpdateFailHTLC UpdateFailHTLC_clone(const struct LDKUpdateFailHTLC *NONNULL_PTR orig); +/** + * 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. + */ +bool UpdateFailHTLC_eq(const struct LDKUpdateFailHTLC *NONNULL_PTR a, const struct LDKUpdateFailHTLC *NONNULL_PTR b); + /** * Frees any resources used by the UpdateFailMalformedHTLC, if is_owned is set and inner is non-NULL. */ @@ -22612,7 +24236,14 @@ void UpdateFailMalformedHTLC_set_failure_code(struct LDKUpdateFailMalformedHTLC /** * Creates a copy of the UpdateFailMalformedHTLC */ -struct LDKUpdateFailMalformedHTLC UpdateFailMalformedHTLC_clone(const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR orig); +struct LDKUpdateFailMalformedHTLC UpdateFailMalformedHTLC_clone(const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR orig); + +/** + * 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. + */ +bool UpdateFailMalformedHTLC_eq(const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR a, const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR b); /** * Frees any resources used by the CommitmentSigned, if is_owned is set and inner is non-NULL. @@ -22639,6 +24270,13 @@ struct LDKSignature CommitmentSigned_get_signature(const struct LDKCommitmentSig */ void CommitmentSigned_set_signature(struct LDKCommitmentSigned *NONNULL_PTR this_ptr, struct LDKSignature val); +/** + * Signatures on the HTLC transactions + * + * Returns a copy of the field. + */ +struct LDKCVec_SignatureZ CommitmentSigned_get_htlc_signatures(const struct LDKCommitmentSigned *NONNULL_PTR this_ptr); + /** * Signatures on the HTLC transactions */ @@ -22654,6 +24292,13 @@ MUST_USE_RES struct LDKCommitmentSigned CommitmentSigned_new(struct LDKThirtyTwo */ struct LDKCommitmentSigned CommitmentSigned_clone(const struct LDKCommitmentSigned *NONNULL_PTR orig); +/** + * 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. + */ +bool CommitmentSigned_eq(const struct LDKCommitmentSigned *NONNULL_PTR a, const struct LDKCommitmentSigned *NONNULL_PTR b); + /** * Frees any resources used by the RevokeAndACK, if is_owned is set and inner is non-NULL. */ @@ -22699,6 +24344,13 @@ MUST_USE_RES struct LDKRevokeAndACK RevokeAndACK_new(struct LDKThirtyTwoBytes ch */ struct LDKRevokeAndACK RevokeAndACK_clone(const struct LDKRevokeAndACK *NONNULL_PTR orig); +/** + * 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. + */ +bool RevokeAndACK_eq(const struct LDKRevokeAndACK *NONNULL_PTR a, const struct LDKRevokeAndACK *NONNULL_PTR b); + /** * Frees any resources used by the UpdateFee, if is_owned is set and inner is non-NULL. */ @@ -22734,6 +24386,13 @@ MUST_USE_RES struct LDKUpdateFee UpdateFee_new(struct LDKThirtyTwoBytes channel_ */ struct LDKUpdateFee UpdateFee_clone(const struct LDKUpdateFee *NONNULL_PTR orig); +/** + * 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. + */ +bool UpdateFee_eq(const struct LDKUpdateFee *NONNULL_PTR a, const struct LDKUpdateFee *NONNULL_PTR b); + /** * Frees any resources used by the DataLossProtect, if is_owned is set and inner is non-NULL. */ @@ -22771,6 +24430,13 @@ MUST_USE_RES struct LDKDataLossProtect DataLossProtect_new(struct LDKThirtyTwoBy */ struct LDKDataLossProtect DataLossProtect_clone(const struct LDKDataLossProtect *NONNULL_PTR orig); +/** + * 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. + */ +bool DataLossProtect_eq(const struct LDKDataLossProtect *NONNULL_PTR a, const struct LDKDataLossProtect *NONNULL_PTR b); + /** * Frees any resources used by the ChannelReestablish, if is_owned is set and inner is non-NULL. */ @@ -22811,6 +24477,13 @@ void ChannelReestablish_set_next_remote_commitment_number(struct LDKChannelReest */ struct LDKChannelReestablish ChannelReestablish_clone(const struct LDKChannelReestablish *NONNULL_PTR orig); +/** + * 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. + */ +bool ChannelReestablish_eq(const struct LDKChannelReestablish *NONNULL_PTR a, const struct LDKChannelReestablish *NONNULL_PTR b); + /** * Frees any resources used by the AnnouncementSignatures, if is_owned is set and inner is non-NULL. */ @@ -22866,6 +24539,13 @@ MUST_USE_RES struct LDKAnnouncementSignatures AnnouncementSignatures_new(struct */ struct LDKAnnouncementSignatures AnnouncementSignatures_clone(const struct LDKAnnouncementSignatures *NONNULL_PTR orig); +/** + * 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. + */ +bool AnnouncementSignatures_eq(const struct LDKAnnouncementSignatures *NONNULL_PTR a, const struct LDKAnnouncementSignatures *NONNULL_PTR b); + /** * Frees any resources used by the NetAddress */ @@ -22901,6 +24581,12 @@ struct LDKNetAddress NetAddress_onion_v3(struct LDKThirtyTwoBytes ed25519_pubkey */ struct LDKNetAddress NetAddress_hostname(struct LDKHostname hostname, uint16_t port); +/** + * Checks if two NetAddresss contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + */ +bool NetAddress_eq(const struct LDKNetAddress *NONNULL_PTR a, const struct LDKNetAddress *NONNULL_PTR b); + /** * Serialize the NetAddress object into a byte array which can be read by NetAddress_read */ @@ -22970,6 +24656,13 @@ const uint8_t (*UnsignedNodeAnnouncement_get_alias(const struct LDKUnsignedNodeA */ void UnsignedNodeAnnouncement_set_alias(struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +/** + * List of addresses on which this node is reachable + * + * Returns a copy of the field. + */ +struct LDKCVec_NetAddressZ UnsignedNodeAnnouncement_get_addresses(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr); + /** * List of addresses on which this node is reachable */ @@ -22980,6 +24673,13 @@ void UnsignedNodeAnnouncement_set_addresses(struct LDKUnsignedNodeAnnouncement * */ struct LDKUnsignedNodeAnnouncement UnsignedNodeAnnouncement_clone(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR orig); +/** + * 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. + */ +bool UnsignedNodeAnnouncement_eq(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR a, const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR b); + /** * Frees any resources used by the NodeAnnouncement, if is_owned is set and inner is non-NULL. */ @@ -23015,6 +24715,13 @@ MUST_USE_RES struct LDKNodeAnnouncement NodeAnnouncement_new(struct LDKSignature */ struct LDKNodeAnnouncement NodeAnnouncement_clone(const struct LDKNodeAnnouncement *NONNULL_PTR orig); +/** + * 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. + */ +bool NodeAnnouncement_eq(const struct LDKNodeAnnouncement *NONNULL_PTR a, const struct LDKNodeAnnouncement *NONNULL_PTR b); + /** * Frees any resources used by the UnsignedChannelAnnouncement, if is_owned is set and inner is non-NULL. */ @@ -23095,6 +24802,13 @@ void UnsignedChannelAnnouncement_set_bitcoin_key_2(struct LDKUnsignedChannelAnno */ struct LDKUnsignedChannelAnnouncement UnsignedChannelAnnouncement_clone(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR orig); +/** + * 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. + */ +bool UnsignedChannelAnnouncement_eq(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR a, const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR b); + /** * Frees any resources used by the ChannelAnnouncement, if is_owned is set and inner is non-NULL. */ @@ -23160,6 +24874,13 @@ MUST_USE_RES struct LDKChannelAnnouncement ChannelAnnouncement_new(struct LDKSig */ struct LDKChannelAnnouncement ChannelAnnouncement_clone(const struct LDKChannelAnnouncement *NONNULL_PTR orig); +/** + * 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. + */ +bool ChannelAnnouncement_eq(const struct LDKChannelAnnouncement *NONNULL_PTR a, const struct LDKChannelAnnouncement *NONNULL_PTR b); + /** * Frees any resources used by the UnsignedChannelUpdate, if is_owned is set and inner is non-NULL. */ @@ -23269,6 +24990,15 @@ uint32_t UnsignedChannelUpdate_get_fee_proportional_millionths(const struct LDKU */ void UnsignedChannelUpdate_set_fee_proportional_millionths(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint32_t val); +/** + * 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. + */ +struct LDKCVec_u8Z UnsignedChannelUpdate_get_excess_data(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); + /** * 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 @@ -23286,6 +25016,13 @@ MUST_USE_RES struct LDKUnsignedChannelUpdate UnsignedChannelUpdate_new(struct LD */ struct LDKUnsignedChannelUpdate UnsignedChannelUpdate_clone(const struct LDKUnsignedChannelUpdate *NONNULL_PTR orig); +/** + * 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. + */ +bool UnsignedChannelUpdate_eq(const struct LDKUnsignedChannelUpdate *NONNULL_PTR a, const struct LDKUnsignedChannelUpdate *NONNULL_PTR b); + /** * Frees any resources used by the ChannelUpdate, if is_owned is set and inner is non-NULL. */ @@ -23321,6 +25058,13 @@ MUST_USE_RES struct LDKChannelUpdate ChannelUpdate_new(struct LDKSignature signa */ struct LDKChannelUpdate ChannelUpdate_clone(const struct LDKChannelUpdate *NONNULL_PTR orig); +/** + * 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. + */ +bool ChannelUpdate_eq(const struct LDKChannelUpdate *NONNULL_PTR a, const struct LDKChannelUpdate *NONNULL_PTR b); + /** * Frees any resources used by the QueryChannelRange, if is_owned is set and inner is non-NULL. */ @@ -23366,6 +25110,13 @@ MUST_USE_RES struct LDKQueryChannelRange QueryChannelRange_new(struct LDKThirtyT */ struct LDKQueryChannelRange QueryChannelRange_clone(const struct LDKQueryChannelRange *NONNULL_PTR orig); +/** + * 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. + */ +bool QueryChannelRange_eq(const struct LDKQueryChannelRange *NONNULL_PTR a, const struct LDKQueryChannelRange *NONNULL_PTR b); + /** * Frees any resources used by the ReplyChannelRange, if is_owned is set and inner is non-NULL. */ @@ -23411,6 +25162,13 @@ bool ReplyChannelRange_get_sync_complete(const struct LDKReplyChannelRange *NONN */ void ReplyChannelRange_set_sync_complete(struct LDKReplyChannelRange *NONNULL_PTR this_ptr, bool val); +/** + * The short_channel_ids in the channel range + * + * Returns a copy of the field. + */ +struct LDKCVec_u64Z ReplyChannelRange_get_short_channel_ids(const struct LDKReplyChannelRange *NONNULL_PTR this_ptr); + /** * The short_channel_ids in the channel range */ @@ -23426,6 +25184,13 @@ MUST_USE_RES struct LDKReplyChannelRange ReplyChannelRange_new(struct LDKThirtyT */ struct LDKReplyChannelRange ReplyChannelRange_clone(const struct LDKReplyChannelRange *NONNULL_PTR orig); +/** + * 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. + */ +bool ReplyChannelRange_eq(const struct LDKReplyChannelRange *NONNULL_PTR a, const struct LDKReplyChannelRange *NONNULL_PTR b); + /** * Frees any resources used by the QueryShortChannelIds, if is_owned is set and inner is non-NULL. */ @@ -23441,6 +25206,13 @@ const uint8_t (*QueryShortChannelIds_get_chain_hash(const struct LDKQueryShortCh */ void QueryShortChannelIds_set_chain_hash(struct LDKQueryShortChannelIds *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +/** + * The short_channel_ids that are being queried + * + * Returns a copy of the field. + */ +struct LDKCVec_u64Z QueryShortChannelIds_get_short_channel_ids(const struct LDKQueryShortChannelIds *NONNULL_PTR this_ptr); + /** * The short_channel_ids that are being queried */ @@ -23456,6 +25228,13 @@ MUST_USE_RES struct LDKQueryShortChannelIds QueryShortChannelIds_new(struct LDKT */ struct LDKQueryShortChannelIds QueryShortChannelIds_clone(const struct LDKQueryShortChannelIds *NONNULL_PTR orig); +/** + * 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. + */ +bool QueryShortChannelIds_eq(const struct LDKQueryShortChannelIds *NONNULL_PTR a, const struct LDKQueryShortChannelIds *NONNULL_PTR b); + /** * Frees any resources used by the ReplyShortChannelIdsEnd, if is_owned is set and inner is non-NULL. */ @@ -23493,6 +25272,13 @@ MUST_USE_RES struct LDKReplyShortChannelIdsEnd ReplyShortChannelIdsEnd_new(struc */ struct LDKReplyShortChannelIdsEnd ReplyShortChannelIdsEnd_clone(const struct LDKReplyShortChannelIdsEnd *NONNULL_PTR orig); +/** + * 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. + */ +bool ReplyShortChannelIdsEnd_eq(const struct LDKReplyShortChannelIdsEnd *NONNULL_PTR a, const struct LDKReplyShortChannelIdsEnd *NONNULL_PTR b); + /** * Frees any resources used by the GossipTimestampFilter, if is_owned is set and inner is non-NULL. */ @@ -23538,6 +25324,13 @@ MUST_USE_RES struct LDKGossipTimestampFilter GossipTimestampFilter_new(struct LD */ struct LDKGossipTimestampFilter GossipTimestampFilter_clone(const struct LDKGossipTimestampFilter *NONNULL_PTR orig); +/** + * 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. + */ +bool GossipTimestampFilter_eq(const struct LDKGossipTimestampFilter *NONNULL_PTR a, const struct LDKGossipTimestampFilter *NONNULL_PTR b); + /** * Frees any resources used by the ErrorAction */ @@ -23692,6 +25485,13 @@ MUST_USE_RES struct LDKCommitmentUpdate CommitmentUpdate_new(struct LDKCVec_Upda */ struct LDKCommitmentUpdate CommitmentUpdate_clone(const struct LDKCommitmentUpdate *NONNULL_PTR orig); +/** + * 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. + */ +bool CommitmentUpdate_eq(const struct LDKCommitmentUpdate *NONNULL_PTR a, const struct LDKCommitmentUpdate *NONNULL_PTR b); + /** * Calls the free function if one is set */ @@ -23702,6 +25502,11 @@ void ChannelMessageHandler_free(struct LDKChannelMessageHandler this_ptr); */ void RoutingMessageHandler_free(struct LDKRoutingMessageHandler this_ptr); +/** + * Calls the free function if one is set + */ +void OnionMessageHandler_free(struct LDKOnionMessageHandler this_ptr); + /** * Serialize the AcceptChannel object into a byte array which can be read by AcceptChannel_read */ @@ -23882,6 +25687,16 @@ struct LDKCVec_u8Z UpdateAddHTLC_write(const struct LDKUpdateAddHTLC *NONNULL_PT */ struct LDKCResult_UpdateAddHTLCDecodeErrorZ UpdateAddHTLC_read(struct LDKu8slice ser); +/** + * Read a OnionMessage from a byte array, created by OnionMessage_write + */ +struct LDKCResult_OnionMessageDecodeErrorZ OnionMessage_read(struct LDKu8slice ser); + +/** + * Serialize the OnionMessage object into a byte array which can be read by OnionMessage_read + */ +struct LDKCVec_u8Z OnionMessage_write(const struct LDKOnionMessage *NONNULL_PTR obj); + /** * Serialize the Ping object into a byte array which can be read by Ping_read */ @@ -24064,6 +25879,24 @@ struct LDKMessageSendEventsProvider IgnoringMessageHandler_as_MessageSendEventsP */ struct LDKRoutingMessageHandler IgnoringMessageHandler_as_RoutingMessageHandler(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); +/** + * Constructs a new OnionMessageProvider which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned OnionMessageProvider must be freed before this_arg is + */ +struct LDKOnionMessageProvider IgnoringMessageHandler_as_OnionMessageProvider(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); + +/** + * Constructs a new OnionMessageHandler which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned OnionMessageHandler must be freed before this_arg is + */ +struct LDKOnionMessageHandler IgnoringMessageHandler_as_OnionMessageHandler(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); + +/** + * 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 + */ +struct LDKCustomOnionMessageHandler IgnoringMessageHandler_as_CustomOnionMessageHandler(const struct LDKIgnoringMessageHandler *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 @@ -24135,10 +25968,22 @@ const struct LDKRoutingMessageHandler *MessageHandler_get_route_handler(const st */ void MessageHandler_set_route_handler(struct LDKMessageHandler *NONNULL_PTR this_ptr, struct LDKRoutingMessageHandler val); +/** + * A message handler which handles onion messages. For now, this can only be an + * [`IgnoringMessageHandler`]. + */ +const struct LDKOnionMessageHandler *MessageHandler_get_onion_message_handler(const struct LDKMessageHandler *NONNULL_PTR this_ptr); + +/** + * A message handler which handles onion messages. For now, this can only be an + * [`IgnoringMessageHandler`]. + */ +void MessageHandler_set_onion_message_handler(struct LDKMessageHandler *NONNULL_PTR this_ptr, struct LDKOnionMessageHandler val); + /** * Constructs a new MessageHandler given each field */ -MUST_USE_RES struct LDKMessageHandler MessageHandler_new(struct LDKChannelMessageHandler chan_handler_arg, struct LDKRoutingMessageHandler route_handler_arg); +MUST_USE_RES struct LDKMessageHandler MessageHandler_new(struct LDKChannelMessageHandler chan_handler_arg, struct LDKRoutingMessageHandler route_handler_arg, struct LDKOnionMessageHandler onion_message_handler_arg); /** * Creates a copy of a SocketDescriptor @@ -24196,8 +26041,13 @@ void PeerManager_free(struct LDKPeerManager this_obj); * Constructs a new PeerManager with the given message handlers and node_id secret key * ephemeral_random_data is used to derive per-connection ephemeral keys and must be * 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 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); +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); /** * Get the list of node ids for peers which have completed the initial handshake. @@ -24341,6 +26191,25 @@ void PeerManager_disconnect_all_peers(const struct LDKPeerManager *NONNULL_PTR t */ void PeerManager_timer_tick_occurred(const struct LDKPeerManager *NONNULL_PTR this_arg); +/** + * 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 PeerManager_broadcast_node_announcement(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKThreeBytes rgb, struct LDKThirtyTwoBytes alias, struct LDKCVec_NetAddressZ addresses); + /** * Gets the weight for an HTLC-Success transaction. */ @@ -24517,6 +26386,13 @@ void TxCreationKeys_set_broadcaster_delayed_payment_key(struct LDKTxCreationKeys */ 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); +/** + * 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. + */ +bool TxCreationKeys_eq(const struct LDKTxCreationKeys *NONNULL_PTR a, const struct LDKTxCreationKeys *NONNULL_PTR b); + /** * Creates a copy of the TxCreationKeys */ @@ -24615,6 +26491,13 @@ MUST_USE_RES struct LDKChannelPublicKeys ChannelPublicKeys_new(struct LDKPublicK */ struct LDKChannelPublicKeys ChannelPublicKeys_clone(const struct LDKChannelPublicKeys *NONNULL_PTR orig); +/** + * 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. + */ +bool ChannelPublicKeys_eq(const struct LDKChannelPublicKeys *NONNULL_PTR a, const struct LDKChannelPublicKeys *NONNULL_PTR b); + /** * Serialize the ChannelPublicKeys object into a byte array which can be read by ChannelPublicKeys_read */ @@ -24721,6 +26604,13 @@ MUST_USE_RES struct LDKHTLCOutputInCommitment HTLCOutputInCommitment_new(bool of */ struct LDKHTLCOutputInCommitment HTLCOutputInCommitment_clone(const struct LDKHTLCOutputInCommitment *NONNULL_PTR orig); +/** + * 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. + */ +bool HTLCOutputInCommitment_eq(const struct LDKHTLCOutputInCommitment *NONNULL_PTR a, const struct LDKHTLCOutputInCommitment *NONNULL_PTR b); + /** * Serialize the HTLCOutputInCommitment object into a byte array which can be read by HTLCOutputInCommitment_read */ @@ -24832,12 +26722,14 @@ struct LDKOutPoint ChannelTransactionParameters_get_funding_outpoint(const struc void ChannelTransactionParameters_set_funding_outpoint(struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr, struct LDKOutPoint val); /** - * Are anchors used for this channel. Boolean is serialization backwards-compatible + * Are anchors (zero fee HTLC transaction variant) used for this channel. Boolean is + * serialization backwards-compatible. */ enum LDKCOption_NoneZ ChannelTransactionParameters_get_opt_anchors(const struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr); /** - * Are anchors used for this channel. Boolean is serialization backwards-compatible + * Are anchors (zero fee HTLC transaction variant) used for this channel. Boolean is + * serialization backwards-compatible. */ void ChannelTransactionParameters_set_opt_anchors(struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr, enum LDKCOption_NoneZ val); @@ -24981,6 +26873,13 @@ struct LDKSignature HolderCommitmentTransaction_get_counterparty_sig(const struc */ void HolderCommitmentTransaction_set_counterparty_sig(struct LDKHolderCommitmentTransaction *NONNULL_PTR this_ptr, struct LDKSignature val); +/** + * All non-dust counterparty HTLC signatures, in the order they appear in the transaction + * + * Returns a copy of the field. + */ +struct LDKCVec_SignatureZ HolderCommitmentTransaction_get_counterparty_htlc_sigs(const struct LDKHolderCommitmentTransaction *NONNULL_PTR this_ptr); + /** * All non-dust counterparty HTLC signatures, in the order they appear in the transaction */ @@ -25086,6 +26985,13 @@ struct LDKClosingTransaction ClosingTransaction_clone(const struct LDKClosingTra */ uint64_t ClosingTransaction_hash(const struct LDKClosingTransaction *NONNULL_PTR o); +/** + * 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. + */ +bool ClosingTransaction_eq(const struct LDKClosingTransaction *NONNULL_PTR a, const struct LDKClosingTransaction *NONNULL_PTR b); + /** * Construct an object of the class */ @@ -25349,11 +27255,6 @@ void ChannelTypeFeatures_free(struct LDKChannelTypeFeatures this_obj); */ MUST_USE_RES struct LDKInitFeatures InitFeatures_empty(void); -/** - * Creates a Features with the bits set which are known by the implementation - */ -MUST_USE_RES struct LDKInitFeatures InitFeatures_known(void); - /** * Returns true if this `Features` object contains unknown feature flags which are set as * \"required\". @@ -25365,11 +27266,6 @@ MUST_USE_RES bool InitFeatures_requires_unknown_bits(const struct LDKInitFeature */ MUST_USE_RES struct LDKNodeFeatures NodeFeatures_empty(void); -/** - * Creates a Features with the bits set which are known by the implementation - */ -MUST_USE_RES struct LDKNodeFeatures NodeFeatures_known(void); - /** * Returns true if this `Features` object contains unknown feature flags which are set as * \"required\". @@ -25381,11 +27277,6 @@ MUST_USE_RES bool NodeFeatures_requires_unknown_bits(const struct LDKNodeFeature */ MUST_USE_RES struct LDKChannelFeatures ChannelFeatures_empty(void); -/** - * Creates a Features with the bits set which are known by the implementation - */ -MUST_USE_RES struct LDKChannelFeatures ChannelFeatures_known(void); - /** * Returns true if this `Features` object contains unknown feature flags which are set as * \"required\". @@ -25397,11 +27288,6 @@ MUST_USE_RES bool ChannelFeatures_requires_unknown_bits(const struct LDKChannelF */ MUST_USE_RES struct LDKInvoiceFeatures InvoiceFeatures_empty(void); -/** - * Creates a Features with the bits set which are known by the implementation - */ -MUST_USE_RES struct LDKInvoiceFeatures InvoiceFeatures_known(void); - /** * Returns true if this `Features` object contains unknown feature flags which are set as * \"required\". @@ -25413,11 +27299,6 @@ MUST_USE_RES bool InvoiceFeatures_requires_unknown_bits(const struct LDKInvoiceF */ MUST_USE_RES struct LDKChannelTypeFeatures ChannelTypeFeatures_empty(void); -/** - * Creates a Features with the bits set which are known by the implementation - */ -MUST_USE_RES struct LDKChannelTypeFeatures ChannelTypeFeatures_known(void); - /** * Returns true if this `Features` object contains unknown feature flags which are set as * \"required\". @@ -25929,6 +27810,46 @@ MUST_USE_RES bool InitFeatures_requires_shutdown_anysegwit(const struct LDKInitF */ MUST_USE_RES bool NodeFeatures_requires_shutdown_anysegwit(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +/** + * Set this feature as optional. + */ +void InitFeatures_set_onion_messages_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); + +/** + * Set this feature as required. + */ +void InitFeatures_set_onion_messages_required(struct LDKInitFeatures *NONNULL_PTR this_arg); + +/** + * Checks if this feature is supported. + */ +MUST_USE_RES bool InitFeatures_supports_onion_messages(const struct LDKInitFeatures *NONNULL_PTR this_arg); + +/** + * Set this feature as optional. + */ +void NodeFeatures_set_onion_messages_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); + +/** + * Set this feature as required. + */ +void NodeFeatures_set_onion_messages_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); + +/** + * Checks if this feature is supported. + */ +MUST_USE_RES bool NodeFeatures_supports_onion_messages(const struct LDKNodeFeatures *NONNULL_PTR this_arg); + +/** + * Checks if this feature is required. + */ +MUST_USE_RES bool InitFeatures_requires_onion_messages(const struct LDKInitFeatures *NONNULL_PTR this_arg); + +/** + * Checks if this feature is required. + */ +MUST_USE_RES bool NodeFeatures_requires_onion_messages(const struct LDKNodeFeatures *NONNULL_PTR this_arg); + /** * Set this feature as optional. */ @@ -26119,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. */ @@ -26279,6 +28207,12 @@ struct LDKNetworkUpdate NetworkUpdate_channel_failure(uint64_t short_channel_id, */ 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 */ @@ -26425,6 +28359,13 @@ MUST_USE_RES struct LDKChannelUpdateInfo ChannelUpdateInfo_new(uint32_t last_upd */ 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 */ @@ -26533,6 +28474,13 @@ 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. * @@ -26736,6 +28684,13 @@ struct LDKNodeAlias NodeAnnouncementInfo_get_alias(const struct LDKNodeAnnouncem */ void NodeAnnouncementInfo_set_alias(struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr, struct LDKNodeAlias val); +/** + * Internet-level addresses via which one can connect to the node + * + * Returns a copy of the field. + */ +struct LDKCVec_NetAddressZ NodeAnnouncementInfo_get_addresses(const struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr); + /** * Internet-level addresses via which one can connect to the node */ @@ -26771,6 +28726,13 @@ MUST_USE_RES struct LDKNodeAnnouncementInfo NodeAnnouncementInfo_new(struct LDKN */ 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 */ @@ -26800,6 +28762,13 @@ MUST_USE_RES struct LDKNodeAlias NodeAlias_new(struct LDKThirtyTwoBytes a_arg); */ 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 */ @@ -26815,6 +28784,13 @@ struct LDKCResult_NodeAliasDecodeErrorZ NodeAlias_read(struct LDKu8slice ser); */ 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 */ @@ -26866,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 */ @@ -26967,9 +28950,10 @@ MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_add_channel_from 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_node_failed(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. @@ -26983,10 +28967,13 @@ void NetworkGraph_node_failed(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. @@ -26997,10 +28984,13 @@ 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 @@ -27032,6 +29022,11 @@ MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel_u */ 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. * @@ -27039,6 +29034,11 @@ MUST_USE_RES struct LDKChannelInfo ReadOnlyNetworkGraph_channel(const struct LDK */ 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. * Returns None if the requested node is completely unknown, @@ -27415,6 +29415,15 @@ uint8_t PaymentParameters_get_max_channel_saturation_power_of_half(const struct */ 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 @@ -27655,16 +29664,49 @@ 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`]. */ @@ -27806,7 +29848,8 @@ void ProbabilisticScoringParameters_set_base_penalty_amount_multiplier_msat(stru /** * A multiplier used in conjunction with the negative `log10` of the channel's success - * probability for a payment to determine the liquidity penalty. + * 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 @@ -27815,7 +29858,9 @@ void ProbabilisticScoringParameters_set_base_penalty_amount_multiplier_msat(stru * uncertainty bounds of the channel liquidity balance. Amounts above the upper bound will * result in a `u64::max_value` penalty, however. * - * Default value: 40,000 msat + * `-log10(success_probability) * liquidity_penalty_multiplier_msat` + * + * Default value: 30,000 msat * * [`liquidity_offset_half_life`]: Self::liquidity_offset_half_life */ @@ -27823,7 +29868,8 @@ uint64_t ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat(co /** * A multiplier used in conjunction with the negative `log10` of the channel's success - * probability for a payment to determine the liquidity penalty. + * 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 @@ -27832,21 +29878,29 @@ uint64_t ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat(co * uncertainty bounds of the channel liquidity balance. Amounts above the upper bound will * result in a `u64::max_value` penalty, however. * - * Default value: 40,000 msat + * `-log10(success_probability) * liquidity_penalty_multiplier_msat` + * + * Default value: 30,000 msat * * [`liquidity_offset_half_life`]: Self::liquidity_offset_half_life */ void ProbabilisticScoringParameters_set_liquidity_penalty_multiplier_msat(struct LDKProbabilisticScoringParameters *NONNULL_PTR this_ptr, uint64_t val); /** - * The time required to elapse before any knowledge learned about channel liquidity balances is - * cut in half. + * 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. * - * 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. + * 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: 1 hour + * Default value: 6 hours * * # Note * @@ -27856,14 +29910,20 @@ void ProbabilisticScoringParameters_set_liquidity_penalty_multiplier_msat(struct uint64_t ProbabilisticScoringParameters_get_liquidity_offset_half_life(const struct LDKProbabilisticScoringParameters *NONNULL_PTR this_ptr); /** - * The time required to elapse before any knowledge learned about channel liquidity balances is - * cut in half. + * 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. * - * 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. + * 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. * - * Default value: 1 hour + * For example, if the channel's capacity is 1 million sats, and the current upper and lower + * liquidity bounds are 200,000 sats and 600,000 sats, after this amount of time the upper + * and lower liquidity bounds will be decayed to 100,000 and 800,000 sats. + * + * Default value: 6 hours * * # Note * @@ -27874,7 +29934,8 @@ void ProbabilisticScoringParameters_set_liquidity_offset_half_life(struct LDKPro /** * A multiplier used in conjunction with a payment amount and the negative `log10` of the - * channel's success probability for the payment to determine the amount penalty. + * 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 @@ -27889,13 +29950,14 @@ void ProbabilisticScoringParameters_set_liquidity_offset_half_life(struct LDKPro * probabilities, the multiplier will have a decreasing effect as the negative `log10` will * fall below `1`. * - * Default value: 256 msat + * 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 to determine the amount penalty. + * 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 @@ -27910,10 +29972,114 @@ uint64_t ProbabilisticScoringParameters_get_liquidity_penalty_amount_multiplier_ * probabilities, the multiplier will have a decreasing effect as the negative `log10` will * fall below `1`. * - * Default value: 256 msat + * Default value: 192 msat */ void ProbabilisticScoringParameters_set_liquidity_penalty_amount_multiplier_msat(struct LDKProbabilisticScoringParameters *NONNULL_PTR this_ptr, uint64_t val); +/** + * A multiplier used in conjunction with the negative `log10` of the channel's success + * probability for 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 + */ +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 @@ -28054,6 +30220,146 @@ struct LDKCVec_u8Z ProbabilisticScorer_write(const struct LDKProbabilisticScorer */ struct LDKCResult_ProbabilisticScorerDecodeErrorZ ProbabilisticScorer_read(struct LDKu8slice ser, struct LDKProbabilisticScoringParameters arg_a, const struct LDKNetworkGraph *NONNULL_PTR arg_b, struct LDKLogger arg_c); +/** + * Frees any resources used by the BlindedRoute, if is_owned is set and inner is non-NULL. + */ +void BlindedRoute_free(struct LDKBlindedRoute this_obj); + +/** + * Frees any resources used by the BlindedHop, if is_owned is set and inner is non-NULL. + */ +void BlindedHop_free(struct LDKBlindedHop this_obj); + +/** + * Create a blinded route to be forwarded along `node_pks`. The last node pubkey in `node_pks` + * will be the destination node. + * + * Errors if less than two hops are provided or if `node_pk`(s) are invalid. + */ +MUST_USE_RES struct LDKCResult_BlindedRouteNoneZ BlindedRoute_new(struct LDKCVec_PublicKeyZ node_pks, const struct LDKKeysInterface *NONNULL_PTR keys_manager); + +/** + * 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 + */ +struct LDKSendError SendError_too_big_packet(void); + +/** + * Utility method to constructs a new TooFewBlindedHops-variant SendError + */ +struct LDKSendError SendError_too_few_blinded_hops(void); + +/** + * Utility method to constructs a new InvalidFirstHop-variant SendError + */ +struct LDKSendError SendError_invalid_first_hop(void); + +/** + * Utility method to constructs a new InvalidMessage-variant SendError + */ +struct LDKSendError SendError_invalid_message(void); + +/** + * Utility method to constructs a new BufferFull-variant SendError + */ +struct LDKSendError SendError_buffer_full(void); + +/** + * Checks if two SendErrors contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + */ +bool SendError_eq(const struct LDKSendError *NONNULL_PTR a, const struct LDKSendError *NONNULL_PTR b); + +/** + * Calls the free function if one is set + */ +void CustomOnionMessageHandler_free(struct LDKCustomOnionMessageHandler this_ptr); + +/** + * Constructs a new `OnionMessenger` to send, forward, and delegate received onion messages to + * their respective handlers. + */ +MUST_USE_RES struct LDKOnionMessenger OnionMessenger_new(struct LDKKeysInterface keys_manager, struct LDKLogger logger, struct LDKCustomOnionMessageHandler custom_handler); + +/** + * Send an onion message with contents `message` to `destination`, routing it through `intermediate_nodes`. + * See [`OnionMessenger`] for example usage. + * + * Note that reply_path (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +MUST_USE_RES struct LDKCResult_NoneSendErrorZ OnionMessenger_send_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 OnionMessageHandler which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned OnionMessageHandler must be freed before this_arg is + */ +struct LDKOnionMessageHandler OnionMessenger_as_OnionMessageHandler(const struct LDKOnionMessenger *NONNULL_PTR this_arg); + +/** + * Constructs a new OnionMessageProvider which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned OnionMessageProvider must be freed before this_arg is + */ +struct LDKOnionMessageProvider OnionMessenger_as_OnionMessageProvider(const struct LDKOnionMessenger *NONNULL_PTR this_arg); + +/** + * Calls the free function if one is set + */ +void CustomOnionMessageContents_free(struct LDKCustomOnionMessageContents this_ptr); + /** * Frees any resources used by the FilesystemPersister, if is_owned is set and inner is non-NULL. */ @@ -28145,10 +30451,8 @@ struct LDKGossipSync GossipSync_none(void); * [`Persister::persist_graph`]: lightning::util::persist::Persister::persist_graph * [`NetworkGraph`]: lightning::routing::gossip::NetworkGraph * [`NetworkGraph::write`]: lightning::routing::gossip::NetworkGraph#impl-Writeable - * - * Note that scorer (or a relevant inner pointer) may be NULL or all-0s to represent None */ -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 LDKMultiThreadedLockableScore scorer); +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 @@ -28276,6 +30580,12 @@ struct LDKParseError ParseError_invalid_slice_length(struct LDKStr a); */ 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 */ @@ -28296,6 +30606,12 @@ struct LDKParseOrSemanticError ParseOrSemanticError_parse_error(struct LDKParseE */ 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. */ @@ -28313,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. */ @@ -28330,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. */ @@ -28357,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. */ @@ -28384,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. */ @@ -28401,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 */ @@ -28432,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 @@ -28653,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. @@ -28698,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. @@ -28717,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); /** * @@ -28786,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); @@ -28794,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); @@ -28947,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); @@ -29186,7 +31541,7 @@ struct LDKPaymentError PaymentError_sending(struct LDKPaymentSendFailure a); * Will forward any [`Event::PaymentPathFailed`] events to the decorated `event_handler` once * `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 LDKRetry retry); +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. @@ -29230,6 +31585,27 @@ 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. @@ -29263,7 +31639,7 @@ struct LDKEventHandler InvoicePayer_as_EventHandler(const struct LDKInvoicePayer * * 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, enum LDKCurrency network); +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.\" @@ -29300,7 +31676,7 @@ struct LDKCResult_InvoiceSignOrCreationErrorZ create_phantom_invoice(struct LDKC * * 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, enum LDKCurrency network); +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 @@ -29312,7 +31688,7 @@ struct LDKCResult_InvoiceSignOrCreationErrorZ create_phantom_invoice_with_descri * `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(const struct LDKChannelManager *NONNULL_PTR channelmanager, struct LDKKeysInterface keys_manager, enum LDKCurrency network, struct LDKCOption_u64Z amt_msat, struct LDKStr description, uint32_t invoice_expiry_delta_secs); +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 @@ -29325,21 +31701,21 @@ struct LDKCResult_InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager * `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, enum LDKCurrency network, struct LDKCOption_u64Z amt_msat, struct LDKSha256 description_hash, uint32_t invoice_expiry_delta_secs); +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_with_description_hash_and_duration_since_epoch(const struct LDKChannelManager *NONNULL_PTR channelmanager, struct LDKKeysInterface keys_manager, enum LDKCurrency network, struct LDKCOption_u64Z amt_msat, struct LDKSha256 description_hash, uint64_t duration_since_epoch, uint32_t invoice_expiry_delta_secs); +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, uint32_t invoice_expiry_delta_secs); +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. @@ -29350,7 +31726,7 @@ void DefaultRouter_free(struct LDKDefaultRouter this_obj); * 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, struct LDKThirtyTwoBytes random_seed_bytes); +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. @@ -29415,23 +31791,22 @@ struct LDKStr SiPrefix_to_str(const enum LDKSiPrefix *NONNULL_PTR o); void RapidGossipSync_free(struct LDKRapidGossipSync this_obj); /** - * Instantiate a new [`RapidGossipSync`] instance + * Instantiate a new [`RapidGossipSync`] instance. */ MUST_USE_RES struct LDKRapidGossipSync RapidGossipSync_new(const struct LDKNetworkGraph *NONNULL_PTR network_graph); /** - * Sync gossip data from a file + * Update network graph from binary data. * Returns the last sync timestamp to be used the next time rapid sync data is queried. * - * `network_graph`: The network graph to apply the updates to - * - * `sync_path`: Path to the file where the gossip update data is located + * `network_graph`: network graph to be updated * + * `update_data`: `&[u8]` binary stream that comprises the update data */ -MUST_USE_RES struct LDKCResult_u32GraphSyncErrorZ RapidGossipSync_sync_network_graph_with_file_path(const struct LDKRapidGossipSync *NONNULL_PTR this_arg, struct LDKStr sync_path); +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 + * 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); @@ -29455,16 +31830,6 @@ struct LDKGraphSyncError GraphSyncError_decode_error(struct LDKDecodeError a); */ struct LDKGraphSyncError GraphSyncError_lightning_error(struct LDKLightningError a); -/** - * 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); - #endif /* LDK_C_BINDINGS_H */ #include "ldk_ver.h"