} 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
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
*/
bool result_ok;
} LDKCResult_BlindedRouteNoneZ;
-
-
/**
* An error in decoding a message or struct.
*/
-typedef struct MUST_USE_STRUCT LDKDecodeError {
+typedef enum LDKDecodeError_Tag {
/**
- * A pointer to the opaque Rust object.
- * Nearly everywhere, inner must be non-null, however in places where
- * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ * A version byte specified something we don't know how to handle.
+ * Includes unknown realm byte in an OnionHopData packet
*/
- LDKnativeDecodeError *inner;
+ LDKDecodeError_UnknownVersion,
/**
- * Indicates that this is the only struct which contains the same pointer.
- * Rust functions which take ownership of an object provided via an argument require
- * this to be true and invalidate the object pointed to by inner.
+ * Unknown feature mandating we fail to parse message (eg TLV with an even, unknown type)
*/
- bool is_owned;
+ 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;
/**
bool result_ok;
} LDKCResult_RouteLightningErrorZ;
-/**
- * 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.
* 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,
/**
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,
/**
uintptr_t datalen;
} LDKCVec_TxidZ;
-/**
- * The contents of CResult_NoneChannelMonitorUpdateErrZ
- */
-typedef union LDKCResult_NoneChannelMonitorUpdateErrZPtr {
- /**
- * Note that this value is always NULL, as there are no contents in the OK variant
- */
- void *result;
- /**
- * A pointer to the contents in the error state.
- * Reading from this pointer when `result_ok` is set is undefined.
- */
- enum LDKChannelMonitorUpdateErr *err;
-} LDKCResult_NoneChannelMonitorUpdateErrZPtr;
-
-/**
- * A CResult_NoneChannelMonitorUpdateErrZ represents the result of a fallible operation,
- * containing a () on success and a crate::lightning::chain::ChannelMonitorUpdateErr on failure.
- * `result_ok` indicates the overall state, and the contents are provided via `contents`.
- */
-typedef struct LDKCResult_NoneChannelMonitorUpdateErrZ {
- /**
- * The contents of this CResult_NoneChannelMonitorUpdateErrZ, accessible via either
- * `err` or `result` depending on the state of `result_ok`.
- */
- union LDKCResult_NoneChannelMonitorUpdateErrZPtr contents;
- /**
- * Whether this CResult_NoneChannelMonitorUpdateErrZ represents a success state.
- */
- bool result_ok;
-} LDKCResult_NoneChannelMonitorUpdateErrZ;
-
/**
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,
/**
LDKMonitorEvent_Sentinel,
} LDKMonitorEvent_Tag;
-typedef struct LDKMonitorEvent_LDKUpdateCompleted_Body {
+typedef struct LDKMonitorEvent_LDKCompleted_Body {
/**
* The funding outpoint of the [`ChannelMonitor`] that was updated
*/
* 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;
struct {
struct LDKOutPoint commitment_tx_confirmed;
};
- LDKMonitorEvent_LDKUpdateCompleted_Body update_completed;
+ LDKMonitorEvent_LDKCompleted_Body completed;
struct {
struct LDKOutPoint update_failed;
};
/**
* [`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.
+ *
+ * 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)`).
*
- * 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.
+ * 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.
*
- * 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.
+ * 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
*
* 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 {
/**
} LDKCResult_SecretKeyNoneZ;
/**
- * Represents a scalar value between zero and the secp256k1 curve order, in big endian.
+ * The contents of CResult_PublicKeyNoneZ
*/
-typedef struct LDKBigEndianScalar {
+typedef union LDKCResult_PublicKeyNoneZPtr {
/**
- * The bytes of the scalar value.
+ * A pointer to the contents in the success state.
+ * Reading from this pointer when `result_ok` is not set is undefined.
*/
- uint8_t big_endian_bytes[32];
-} LDKBigEndianScalar;
+ 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
* 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.
*/
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`].
* 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,
/**
* 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 {
/**
* 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.
* 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);
/**
*
* 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);
* 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);
/**
uintptr_t datalen;
} LDKCVec_C2Tuple_PublicKeyTypeZZ;
+/**
+ * The contents of a custom onion message.
+ */
+typedef struct LDKCustomOnionMessageContents {
+ /**
+ * 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 TLV type identifying the message contents. MUST be >= 64.
+ */
+ 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_CustomOnionMessageContentsZ_Sentinel,
+} LDKCOption_CustomOnionMessageContentsZ_Tag;
+
+typedef struct LDKCOption_CustomOnionMessageContentsZ {
+ LDKCOption_CustomOnionMessageContentsZ_Tag tag;
+ union {
+ struct {
+ struct LDKCustomOnionMessageContents some;
+ };
+ };
+} LDKCOption_CustomOnionMessageContentsZ;
+
+/**
+ * The contents of CResult_COption_CustomOnionMessageContentsZDecodeErrorZ
+ */
+typedef union LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZPtr {
+ /**
+ * A pointer to the contents in the success state.
+ * Reading from this pointer when `result_ok` is not set is undefined.
+ */
+ struct LDKCOption_CustomOnionMessageContentsZ *result;
+ /**
+ * A pointer to the contents in the error state.
+ * Reading from this pointer when `result_ok` is set is undefined.
+ */
+ struct LDKDecodeError *err;
+} LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZPtr;
+
+/**
+ * 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
*/
/**
* Errors that may occur when [sending an onion message].
*
- * [sending an onion message]: OnionMessenger::send_onion_message
+ * [sending an onion message]: OnionMessenger::send_custom_onion_message
*/
typedef enum LDKSendError_Tag {
/**
* 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.
*/
* 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
*/
*
* 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 {
/**
* 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.
* 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.
* 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.
*/
* 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
/**
* 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.
*/
- 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);
/**
* 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);
/**
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;
+
/**
/**
* 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 empty onion messages is supported.
+ * and receiving custom onion messages is supported.
*
* # Example
*
* # 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 {
* # 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 (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);
- *
- * // Send an empty onion message to a node id.
+ * let onion_messenger = OnionMessenger::new(&keys_manager, logger, your_custom_message_handler);
+ *
+ * # struct YourCustomMessage {}
+ * impl Writeable for YourCustomMessage {
+ * \tfn write<W: Writer>(&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;
- * onion_messenger.send_onion_message(&intermediate_hops, Destination::Node(destination_node_id), reply_path);
+ * # 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 an empty onion message to a blinded route.
+ * // Send a custom onion message to a blinded route.
* # let intermediate_hops = [hop_node_id1, hop_node_id2];
* let reply_path = None;
- * onion_messenger.send_onion_message(&intermediate_hops, Destination::BlindedRoute(blinded_route), reply_path);
+ * # let your_custom_message = YourCustomMessage {};
+ * onion_messenger.send_custom_onion_message(&intermediate_hops, Destination::BlindedRoute(blinded_route), your_custom_message, reply_path);
* ```
*
* [offers]: <https://github.com/lightning/bolts/pull/798>
* [`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.
/**
- * Rapid Gossip Sync struct
+ * The main Rapid Gossip Sync object.
+ *
* See [crate-level documentation] for usage.
*
* [crate-level documentation]: crate
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`
*/
*/
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.
*/
*/
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
*/
void CVec_C2Tuple_PublicKeyTypeZZ_free(struct LDKCVec_C2Tuple_PublicKeyTypeZZ _res);
/**
- * Constructs a new COption_NetAddressZ containing a crate::lightning::ln::msgs::NetAddress
+ * Constructs a new COption_CustomOnionMessageContentsZ containing a crate::lightning::onion_message::packet::CustomOnionMessageContents
*/
-struct LDKCOption_NetAddressZ COption_NetAddressZ_some(struct LDKNetAddress o);
+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
+ */
+struct LDKCOption_NetAddressZ COption_NetAddressZ_some(struct LDKNetAddress o);
/**
* Constructs a new COption_NetAddressZ containing nothing
*/
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
*/
*/
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
*/
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.
*/
*/
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.
+ */
+bool Hostname_eq(const struct LDKHostname *NONNULL_PTR a, const struct LDKHostname *NONNULL_PTR b);
+
/**
* Returns the length of the hostname.
*/
* 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
* 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
*/
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.
*/
*/
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.
void Confirm_free(struct LDKConfirm this_ptr);
/**
- * Creates a copy of the ChannelMonitorUpdateErr
+ * Creates a copy of the ChannelMonitorUpdateStatus
*/
-enum LDKChannelMonitorUpdateErr ChannelMonitorUpdateErr_clone(const enum LDKChannelMonitorUpdateErr *NONNULL_PTR orig);
+enum LDKChannelMonitorUpdateStatus ChannelMonitorUpdateStatus_clone(const enum LDKChannelMonitorUpdateStatus *NONNULL_PTR orig);
/**
- * Utility method to constructs a new TemporaryFailure-variant ChannelMonitorUpdateErr
+ * Utility method to constructs a new Completed-variant ChannelMonitorUpdateStatus
*/
-enum LDKChannelMonitorUpdateErr ChannelMonitorUpdateErr_temporary_failure(void);
+enum LDKChannelMonitorUpdateStatus ChannelMonitorUpdateStatus_completed(void);
/**
- * Utility method to constructs a new PermanentFailure-variant ChannelMonitorUpdateErr
+ * Utility method to constructs a new InProgress-variant ChannelMonitorUpdateStatus
*/
-enum LDKChannelMonitorUpdateErr ChannelMonitorUpdateErr_permanent_failure(void);
+enum LDKChannelMonitorUpdateStatus ChannelMonitorUpdateStatus_in_progress(void);
+
+/**
+ * Utility method to constructs a new PermanentFailure-variant ChannelMonitorUpdateStatus
+ */
+enum LDKChannelMonitorUpdateStatus ChannelMonitorUpdateStatus_permanent_failure(void);
+
+/**
+ * Checks if two ChannelMonitorUpdateStatuss contain equal inner contents.
+ * This ignores pointers and is_owned flags and looks at the values in fields.
+ */
+bool ChannelMonitorUpdateStatus_eq(const enum LDKChannelMonitorUpdateStatus *NONNULL_PTR a, const enum LDKChannelMonitorUpdateStatus *NONNULL_PTR b);
/**
* Calls the free function if one is set
*/
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.
*/
/**
* 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.
* 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);
* 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);
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
*/
*/
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
*/
/**
* 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);
*/
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
*/
*/
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
*/
*/
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
*/
* 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
*/
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
*/
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.
*/
*/
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.
*/
*/
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.
*/
*/
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.
*/
*/
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.
*/
*/
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.
*/
*/
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.
*/
*/
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.
*/
*/
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.
*/
*/
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.
*/
*/
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.
*/
*/
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.
*/
*/
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.
*/
*/
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.
*/
*/
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.
*/
*/
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.
*/
*/
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.
*/
*/
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.
*/
*/
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.
*/
*/
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.
*/
*/
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.
*/
*/
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.
*/
*/
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.
*/
*/
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.
*/
*/
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
*/
*/
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
*/
*/
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.
*/
*/
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.
*/
*/
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.
*/
*/
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.
*/
*/
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.
*/
*/
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.
*/
*/
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.
*/
*/
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.
*/
*/
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.
*/
*/
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.
*/
*/
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
*/
*/
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
*/
*/
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
* 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, uint64_t current_time, 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.
*/
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
*/
*/
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
*/
*/
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
*/
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);
*/
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
*/
*/
void ChannelTypeFeatures_free(struct LDKChannelTypeFeatures this_obj);
-/**
- * Returns the set of known init features that are related to channels. At least some of
- * these features are likely required for peers to talk to us.
- */
-MUST_USE_RES struct LDKInitFeatures InitFeatures_known_channel_features(void);
-
-/**
- * Returns the set of known node features that are related to channels.
- */
-MUST_USE_RES struct LDKNodeFeatures NodeFeatures_known_channel_features(void);
-
/**
* Create a blank Features with no features set
*/
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\".
*/
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\".
*/
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\".
*/
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\".
*/
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\".
*/
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.
*/
*/
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
*/
*/
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
*/
*/
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.
*
*/
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
*/
*/
struct LDKNodeAlias NodeAlias_clone(const struct LDKNodeAlias *NONNULL_PTR orig);
+/**
+ * Checks if two NodeAliass contain equal inner contents.
+ * This ignores pointers and is_owned flags and looks at the values in fields.
+ * Two objects with NULL inner values will be considered "equal" here.
+ */
+bool NodeAlias_eq(const struct LDKNodeAlias *NONNULL_PTR a, const struct LDKNodeAlias *NONNULL_PTR b);
+
/**
* Serialize the NodeAlias object into a byte array which can be read by NodeAlias_read
*/
*/
struct 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
*/
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.
* 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.
* 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
*/
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`].
*/
/**
* 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
* 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
*/
/**
* 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
* 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
*
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
*
/**
* 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
* 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
* 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
*/
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);
+MUST_USE_RES struct LDKOnionMessenger OnionMessenger_new(struct LDKKeysInterface keys_manager, struct LDKLogger logger, struct LDKCustomOnionMessageHandler custom_handler);
/**
- * Send an empty onion message to `destination`, routing it through `intermediate_nodes`.
+ * 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_onion_message(const struct LDKOnionMessenger *NONNULL_PTR this_arg, struct LDKCVec_PublicKeyZ intermediate_nodes, struct LDKDestination destination, struct LDKBlindedRoute reply_path);
+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.
*/
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.
*/
*/
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
*/
*/
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.
*/
* Creates a `PositiveTimestamp` from a [`SystemTime`] with a corresponding Unix timestamp in
* the range `0..=MAX_TIMESTAMP`.
*
+ * Note that the subsecond part is dropped as it is not representable in BOLT 11 invoices.
+ *
* Otherwise, returns a [`CreationError::TimestampOutOfBounds`].
*/
MUST_USE_RES struct LDKCResult_PositiveTimestampCreationErrorZ PositiveTimestamp_from_system_time(uint64_t time);
* Creates a `PositiveTimestamp` from a [`Duration`] since the Unix epoch in the range
* `0..=MAX_TIMESTAMP`.
*
+ * 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);
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);
*
* 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.\"
*
* 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
* `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
* `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.
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);
*/
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"