#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
-#include <ldk_rust_types.h>
+#include "ldk_rust_types.h"
/**
* An error when accessing the chain via [`Access`].
*/
typedef enum LDKLevel {
/**
- *Designates logger being silent
- */
- LDKLevel_Off,
- /**
- * Designates very serious errors
+ * Designates very low priority, often extremely verbose, information
*/
- LDKLevel_Error,
+ LDKLevel_Trace,
/**
- * Designates hazardous situations
+ * Designates lower priority information
*/
- LDKLevel_Warn,
+ LDKLevel_Debug,
/**
* Designates useful information
*/
LDKLevel_Info,
/**
- * Designates lower priority information
+ * Designates hazardous situations
*/
- LDKLevel_Debug,
+ LDKLevel_Warn,
/**
- * Designates very low priority, often extremely verbose, information
+ * Designates very serious errors
*/
- LDKLevel_Trace,
+ LDKLevel_Error,
/**
* Must be last for serialization purposes
*/
bool result_ok;
} LDKCResult_CVec_SignatureZNoneZ;
+
+
+/**
+ * A script pubkey for shutting down a channel as defined by [BOLT #2].
+ *
+ * [BOLT #2]: https://github.com/lightningnetwork/lightning-rfc/blob/master/02-peer-protocol.md
+ */
+typedef struct MUST_USE_STRUCT LDKShutdownScript {
+ /**
+ * 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.
+ */
+ LDKnativeShutdownScript *inner;
+ /**
+ * Indicates that this is the only struct which contains the same pointer.
+ * Rust functions which take ownership of an object provided via an argument require
+ * this to be true and invalidate the object pointed to by inner.
+ */
+ bool is_owned;
+} LDKShutdownScript;
+
+/**
+ * The contents of CResult_ShutdownScriptDecodeErrorZ
+ */
+typedef union LDKCResult_ShutdownScriptDecodeErrorZPtr {
+ /**
+ * A pointer to the contents in the success state.
+ * Reading from this pointer when `result_ok` is not set is undefined.
+ */
+ struct LDKShutdownScript *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_ShutdownScriptDecodeErrorZPtr;
+
+/**
+ * A CResult_ShutdownScriptDecodeErrorZ represents the result of a fallible operation,
+ * containing a crate::lightning::ln::script::ShutdownScript 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_ShutdownScriptDecodeErrorZ {
+ /**
+ * The contents of this CResult_ShutdownScriptDecodeErrorZ, accessible via either
+ * `err` or `result` depending on the state of `result_ok`.
+ */
+ union LDKCResult_ShutdownScriptDecodeErrorZPtr contents;
+ /**
+ * Whether this CResult_ShutdownScriptDecodeErrorZ represents a success state.
+ */
+ bool result_ok;
+} LDKCResult_ShutdownScriptDecodeErrorZ;
+
+
+
+/**
+ * An error occurring when converting from [`Script`] to [`ShutdownScript`].
+ */
+typedef struct MUST_USE_STRUCT LDKInvalidShutdownScript {
+ /**
+ * 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.
+ */
+ LDKnativeInvalidShutdownScript *inner;
+ /**
+ * Indicates that this is the only struct which contains the same pointer.
+ * Rust functions which take ownership of an object provided via an argument require
+ * this to be true and invalidate the object pointed to by inner.
+ */
+ bool is_owned;
+} LDKInvalidShutdownScript;
+
+/**
+ * The contents of CResult_ShutdownScriptInvalidShutdownScriptZ
+ */
+typedef union LDKCResult_ShutdownScriptInvalidShutdownScriptZPtr {
+ /**
+ * A pointer to the contents in the success state.
+ * Reading from this pointer when `result_ok` is not set is undefined.
+ */
+ struct LDKShutdownScript *result;
+ /**
+ * A pointer to the contents in the error state.
+ * Reading from this pointer when `result_ok` is set is undefined.
+ */
+ struct LDKInvalidShutdownScript *err;
+} LDKCResult_ShutdownScriptInvalidShutdownScriptZPtr;
+
+/**
+ * A CResult_ShutdownScriptInvalidShutdownScriptZ represents the result of a fallible operation,
+ * containing a crate::lightning::ln::script::ShutdownScript on success and a crate::lightning::ln::script::InvalidShutdownScript on failure.
+ * `result_ok` indicates the overall state, and the contents are provided via `contents`.
+ */
+typedef struct LDKCResult_ShutdownScriptInvalidShutdownScriptZ {
+ /**
+ * The contents of this CResult_ShutdownScriptInvalidShutdownScriptZ, accessible via either
+ * `err` or `result` depending on the state of `result_ok`.
+ */
+ union LDKCResult_ShutdownScriptInvalidShutdownScriptZPtr contents;
+ /**
+ * Whether this CResult_ShutdownScriptInvalidShutdownScriptZ represents a success state.
+ */
+ bool result_ok;
+} LDKCResult_ShutdownScriptInvalidShutdownScriptZ;
+
/**
* The contents of CResult_NoneErrorZ
*/
typedef enum LDKSpendableOutputDescriptor_Tag {
/**
* An output to a script which was provided via KeysInterface directly, either from
- * `get_destination_script()` or `get_shutdown_pubkey()`, thus you should already know how to
- * spend it. No secret keys are provided as rust-lightning was never given any key.
+ * `get_destination_script()` or `get_shutdown_scriptpubkey()`, thus you should already know
+ * how to spend it. No secret keys are provided as rust-lightning was never given any key.
* These may include outputs from a transaction punishing our counterparty or claiming an HTLC
* on-chain using the payment preimage or after it has timed out.
*/
* The peer did something harmless that we weren't able to process, just log and ignore
*/
LDKErrorAction_IgnoreError,
+ /**
+ * The peer did something harmless that we weren't able to meaningfully process.
+ * If the error is logged, log it at the given level.
+ */
+ LDKErrorAction_IgnoreAndLog,
/**
* The peer did something incorrect. Tell them.
*/
typedef struct LDKErrorAction_LDKDisconnectPeer_Body {
/**
* An error message which we should make an effort to send before we disconnect.
+ *
+ * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
*/
struct LDKErrorMessage msg;
} LDKErrorAction_LDKDisconnectPeer_Body;
LDKErrorAction_Tag tag;
union {
LDKErrorAction_LDKDisconnectPeer_Body disconnect_peer;
+ struct {
+ enum LDKLevel ignore_and_log;
+ };
LDKErrorAction_LDKSendErrorMessage_Body send_error_message;
};
} LDKErrorAction;
* Used to indicate that a channel_update should be broadcast to all peers.
*/
LDKMessageSendEvent_BroadcastChannelUpdate,
+ /**
+ * Used to indicate that a channel_update should be sent to a single peer.
+ * In contrast to [`Self::BroadcastChannelUpdate`], this is used when the channel is a
+ * private channel and we shouldn't be informing all of our peers of channel parameters.
+ */
+ LDKMessageSendEvent_SendChannelUpdate,
/**
* Broadcast an error downstream to be handled
*/
struct LDKChannelUpdate msg;
} LDKMessageSendEvent_LDKBroadcastChannelUpdate_Body;
+typedef struct LDKMessageSendEvent_LDKSendChannelUpdate_Body {
+ /**
+ * The node_id of the node which should receive this message
+ */
+ struct LDKPublicKey node_id;
+ /**
+ * The channel_update which should be sent.
+ */
+ struct LDKChannelUpdate msg;
+} LDKMessageSendEvent_LDKSendChannelUpdate_Body;
+
typedef struct LDKMessageSendEvent_LDKHandleError_Body {
/**
* The node_id of the node which should receive this message
LDKMessageSendEvent_LDKBroadcastChannelAnnouncement_Body broadcast_channel_announcement;
LDKMessageSendEvent_LDKBroadcastNodeAnnouncement_Body broadcast_node_announcement;
LDKMessageSendEvent_LDKBroadcastChannelUpdate_Body broadcast_channel_update;
+ LDKMessageSendEvent_LDKSendChannelUpdate_Body send_channel_update;
LDKMessageSendEvent_LDKHandleError_Body handle_error;
LDKMessageSendEvent_LDKPaymentFailureNetworkUpdate_Body payment_failure_network_update;
LDKMessageSendEvent_LDKSendChannelRangeQuery_Body send_channel_range_query;
* Implementation of BaseSign for this object.
*/
struct LDKBaseSign BaseSign;
- /**
- * Creates a copy of the BaseSign, for a copy of this Sign.
- * Because BaseSign doesn't natively support copying itself, you have to provide a full copy implementation here.
- */
- struct LDKBaseSign (*BaseSign_clone)(const struct LDKBaseSign *NONNULL_PTR orig_BaseSign);
/**
* Serialize the object into a byte array
*/
struct LDKCVec_u8Z (*write)(const void *this_arg);
/**
- * Creates a copy of the object pointed to by this_arg, for a copy of this Sign.
- * Note that the ultimate copy of the Sign will have all function pointers the same as the original.
- * May be NULL if no action needs to be taken, the this_arg pointer will be copied into the new Sign.
+ * Called, if set, after this Sign has been cloned into a duplicate object.
+ * The new Sign is provided, and should be mutated as needed to perform a
+ * deep copy of the object pointed to by this_arg or avoid any double-freeing.
*/
- void *(*clone)(const void *this_arg);
+ void (*cloned)(struct LDKSign *NONNULL_PTR new_Sign);
/**
* Frees any resources associated with this object given its this_arg pointer.
* Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
bool result_ok;
} LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ;
+/**
+ * An enum which can either contain a u16 or not
+ */
+typedef enum LDKCOption_u16Z_Tag {
+ /**
+ * When we're in this state, this COption_u16Z contains a u16
+ */
+ LDKCOption_u16Z_Some,
+ /**
+ * When we're in this state, this COption_u16Z contains nothing
+ */
+ LDKCOption_u16Z_None,
+ /**
+ * Must be last for serialization purposes
+ */
+ LDKCOption_u16Z_Sentinel,
+} LDKCOption_u16Z_Tag;
+
+typedef struct LDKCOption_u16Z {
+ LDKCOption_u16Z_Tag tag;
+ union {
+ struct {
+ uint16_t some;
+ };
+ };
+} LDKCOption_u16Z;
+
/**
* Indicates an error on the client's part (usually some variant of attempting to use too-low or
* too-high values)
* attempted action to fail.
*/
LDKAPIError_MonitorUpdateFailed,
+ /**
+ * [`KeysInterface::get_shutdown_scriptpubkey`] returned a shutdown scriptpubkey incompatible
+ * with the channel counterparty as negotiated in [`InitFeatures`].
+ *
+ * Using a SegWit v0 script should resolve this issue. If you cannot, you won't be able to open
+ * a channel or cooperatively close one with this peer (and will have to force-close instead).
+ *
+ * [`KeysInterface::get_shutdown_scriptpubkey`]: crate::chain::keysinterface::KeysInterface::get_shutdown_scriptpubkey
+ * [`InitFeatures`]: crate::ln::features::InitFeatures
+ */
+ LDKAPIError_IncompatibleShutdownScript,
/**
* Must be last for serialization purposes
*/
struct LDKStr err;
} LDKAPIError_LDKChannelUnavailable_Body;
+typedef struct LDKAPIError_LDKIncompatibleShutdownScript_Body {
+ /**
+ * The incompatible shutdown script.
+ */
+ struct LDKShutdownScript script;
+} LDKAPIError_LDKIncompatibleShutdownScript_Body;
+
typedef struct MUST_USE_STRUCT LDKAPIError {
LDKAPIError_Tag tag;
union {
LDKAPIError_LDKFeeRateTooHigh_Body fee_rate_too_high;
LDKAPIError_LDKRouteError_Body route_error;
LDKAPIError_LDKChannelUnavailable_Body channel_unavailable;
+ LDKAPIError_LDKIncompatibleShutdownScript_Body incompatible_shutdown_script;
};
} LDKAPIError;
bool result_ok;
} LDKCResult_NonePaymentSendFailureZ;
+/**
+ * The contents of CResult_PaymentHashPaymentSendFailureZ
+ */
+typedef union LDKCResult_PaymentHashPaymentSendFailureZPtr {
+ /**
+ * A pointer to the contents in the success state.
+ * Reading from this pointer when `result_ok` is not set is undefined.
+ */
+ struct LDKThirtyTwoBytes *result;
+ /**
+ * A pointer to the contents in the error state.
+ * Reading from this pointer when `result_ok` is set is undefined.
+ */
+ struct LDKPaymentSendFailure *err;
+} LDKCResult_PaymentHashPaymentSendFailureZPtr;
+
+/**
+ * A CResult_PaymentHashPaymentSendFailureZ represents the result of a fallible operation,
+ * containing a crate::c_types::ThirtyTwoBytes on success and a crate::lightning::ln::channelmanager::PaymentSendFailure on failure.
+ * `result_ok` indicates the overall state, and the contents are provided via `contents`.
+ */
+typedef struct LDKCResult_PaymentHashPaymentSendFailureZ {
+ /**
+ * The contents of this CResult_PaymentHashPaymentSendFailureZ, accessible via either
+ * `err` or `result` depending on the state of `result_ok`.
+ */
+ union LDKCResult_PaymentHashPaymentSendFailureZPtr contents;
+ /**
+ * Whether this CResult_PaymentHashPaymentSendFailureZ represents a success state.
+ */
+ bool result_ok;
+} LDKCResult_PaymentHashPaymentSendFailureZ;
+
/**
* A 4-byte byte array.
*/
*/
struct LDKCVec_u8Z (*get_destination_script)(const void *this_arg);
/**
- * Get a public key which we will send funds to (in the form of a P2WPKH output) when closing
- * a channel.
+ * Get a script pubkey which we will send funds to when closing a channel.
*
* This method should return a different value each time it is called, to avoid linking
* on-chain funds across channels as controlled to the same user.
*/
- struct LDKPublicKey (*get_shutdown_pubkey)(const void *this_arg);
+ struct LDKShutdownScript (*get_shutdown_scriptpubkey)(const void *this_arg);
/**
* Get a new set of Sign for per-channel secrets. These MUST be unique even if you
* restarted with some stale data!
uintptr_t datalen;
} LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ;
+/**
+ * Some information provided on receipt of payment depends on whether the payment received is a
+ * spontaneous payment or a \"conventional\" lightning payment that's paying an invoice.
+ */
+typedef enum LDKPaymentPurpose_Tag {
+ /**
+ * Information for receiving a payment that we generated an invoice for.
+ */
+ LDKPaymentPurpose_InvoicePayment,
+ /**
+ * Because this is a spontaneous payment, the payer generated their own preimage rather than us
+ * (the payee) providing a preimage.
+ */
+ LDKPaymentPurpose_SpontaneousPayment,
+ /**
+ * Must be last for serialization purposes
+ */
+ LDKPaymentPurpose_Sentinel,
+} LDKPaymentPurpose_Tag;
+
+typedef struct LDKPaymentPurpose_LDKInvoicePayment_Body {
+ /**
+ * The preimage to the payment_hash, if the payment hash (and secret) were fetched via
+ * [`ChannelManager::create_inbound_payment`]. If provided, this can be handed directly to
+ * [`ChannelManager::claim_funds`].
+ *
+ * [`ChannelManager::create_inbound_payment`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment
+ * [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds
+ *
+ * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
+ */
+ struct LDKThirtyTwoBytes payment_preimage;
+ /**
+ * The \"payment secret\". This authenticates the sender to the recipient, preventing a
+ * number of deanonymization attacks during the routing process.
+ * It is provided here for your reference, however its accuracy is enforced directly by
+ * [`ChannelManager`] using the values you previously provided to
+ * [`ChannelManager::create_inbound_payment`] or
+ * [`ChannelManager::create_inbound_payment_for_hash`].
+ *
+ * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
+ * [`ChannelManager::create_inbound_payment`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment
+ * [`ChannelManager::create_inbound_payment_for_hash`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash
+ */
+ struct LDKThirtyTwoBytes payment_secret;
+ /**
+ * This is the `user_payment_id` which was provided to
+ * [`ChannelManager::create_inbound_payment_for_hash`] or
+ * [`ChannelManager::create_inbound_payment`]. It has no meaning inside of LDK and is
+ * simply copied here. It may be used to correlate PaymentReceived events with invoice
+ * metadata stored elsewhere.
+ *
+ * [`ChannelManager::create_inbound_payment`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment
+ * [`ChannelManager::create_inbound_payment_for_hash`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash
+ */
+ uint64_t user_payment_id;
+} LDKPaymentPurpose_LDKInvoicePayment_Body;
+
+typedef struct MUST_USE_STRUCT LDKPaymentPurpose {
+ LDKPaymentPurpose_Tag tag;
+ union {
+ LDKPaymentPurpose_LDKInvoicePayment_Body invoice_payment;
+ struct {
+ struct LDKThirtyTwoBytes spontaneous_payment;
+ };
+ };
+} LDKPaymentPurpose;
+
/**
* An Event which you should probably take some action in response to.
*
* somewhere and spend them when you create on-chain transactions.
*/
LDKEvent_SpendableOutputs,
+ /**
+ * This event is generated when a payment has been successfully forwarded through us and a
+ * forwarding fee earned.
+ */
+ LDKEvent_PaymentForwarded,
/**
* Must be last for serialization purposes
*/
* The hash for which the preimage should be handed to the ChannelManager.
*/
struct LDKThirtyTwoBytes payment_hash;
- /**
- * The preimage to the payment_hash, if the payment hash (and secret) were fetched via
- * [`ChannelManager::create_inbound_payment`]. If provided, this can be handed directly to
- * [`ChannelManager::claim_funds`].
- *
- * [`ChannelManager::create_inbound_payment`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment
- * [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds
- */
- struct LDKThirtyTwoBytes payment_preimage;
- /**
- * The \"payment secret\". This authenticates the sender to the recipient, preventing a
- * number of deanonymization attacks during the routing process.
- * It is provided here for your reference, however its accuracy is enforced directly by
- * [`ChannelManager`] using the values you previously provided to
- * [`ChannelManager::create_inbound_payment`] or
- * [`ChannelManager::create_inbound_payment_for_hash`].
- *
- * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
- * [`ChannelManager::create_inbound_payment`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment
- * [`ChannelManager::create_inbound_payment_for_hash`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash
- */
- struct LDKThirtyTwoBytes payment_secret;
/**
* The value, in thousandths of a satoshi, that this payment is for. Note that you must
* compare this to the expected value before accepting the payment (as otherwise you are
*/
uint64_t amt;
/**
- * This is the `user_payment_id` which was provided to
- * [`ChannelManager::create_inbound_payment_for_hash`] or
- * [`ChannelManager::create_inbound_payment`]. It has no meaning inside of LDK and is
- * simply copied here. It may be used to correlate PaymentReceived events with invoice
- * metadata stored elsewhere.
- *
- * [`ChannelManager::create_inbound_payment`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment
- * [`ChannelManager::create_inbound_payment_for_hash`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash
+ * Information for claiming this received payment, based on whether the purpose of the
+ * payment is to pay an invoice or to send a spontaneous payment.
*/
- uint64_t user_payment_id;
+ struct LDKPaymentPurpose purpose;
} LDKEvent_LDKPaymentReceived_Body;
typedef struct LDKEvent_LDKPaymentSent_Body {
struct LDKCVec_SpendableOutputDescriptorZ outputs;
} LDKEvent_LDKSpendableOutputs_Body;
+typedef struct LDKEvent_LDKPaymentForwarded_Body {
+ /**
+ * The fee, in milli-satoshis, which was earned as a result of the payment.
+ *
+ * Note that if we force-closed the channel over which we forwarded an HTLC while the HTLC
+ * was pending, the amount the next hop claimed will have been rounded down to the nearest
+ * whole satoshi. Thus, the fee calculated here may be higher than expected as we still
+ * claimed the full value in millisatoshis from the source. In this case,
+ * `claim_from_onchain_tx` will be set.
+ *
+ * If the channel which sent us the payment has been force-closed, we will claim the funds
+ * via an on-chain transaction. In that case we do not yet know the on-chain transaction
+ * fees which we will spend and will instead set this to `None`. It is possible duplicate
+ * `PaymentForwarded` events are generated for the same payment iff `fee_earned_msat` is
+ * `None`.
+ */
+ struct LDKCOption_u64Z fee_earned_msat;
+ /**
+ * If this is `true`, the forwarded HTLC was claimed by our counterparty via an on-chain
+ * transaction.
+ */
+ bool claim_from_onchain_tx;
+} LDKEvent_LDKPaymentForwarded_Body;
+
typedef struct MUST_USE_STRUCT LDKEvent {
LDKEvent_Tag tag;
union {
LDKEvent_LDKPaymentFailed_Body payment_failed;
LDKEvent_LDKPendingHTLCsForwardable_Body pending_htl_cs_forwardable;
LDKEvent_LDKSpendableOutputs_Body spendable_outputs;
+ LDKEvent_LDKPaymentForwarded_Body payment_forwarded;
};
} LDKEvent;
/**
- * A commitment_signed message to be sent or received from a peer
+ * The minimum and maximum fees which the sender is willing to place on the closing transaction.
+ * This is provided in [`ClosingSigned`] by both sides to indicate the fee range they are willing
+ * to use.
*/
-typedef struct MUST_USE_STRUCT LDKCommitmentSigned {
+typedef struct MUST_USE_STRUCT LDKClosingSignedFeeRange {
/**
* A pointer to the opaque Rust object.
* Nearly everywhere, inner must be non-null, however in places where
* the Rust equivalent takes an Option, it may be set to null to indicate None.
*/
- LDKnativeCommitmentSigned *inner;
+ LDKnativeClosingSignedFeeRange *inner;
/**
* Indicates that this is the only struct which contains the same pointer.
* Rust functions which take ownership of an object provided via an argument require
* this to be true and invalidate the object pointed to by inner.
*/
bool is_owned;
-} LDKCommitmentSigned;
+} LDKClosingSignedFeeRange;
/**
- * The contents of CResult_CommitmentSignedDecodeErrorZ
+ * The contents of CResult_ClosingSignedFeeRangeDecodeErrorZ
*/
-typedef union LDKCResult_CommitmentSignedDecodeErrorZPtr {
+typedef union LDKCResult_ClosingSignedFeeRangeDecodeErrorZPtr {
/**
* A pointer to the contents in the success state.
* Reading from this pointer when `result_ok` is not set is undefined.
*/
- struct LDKCommitmentSigned *result;
+ struct LDKClosingSignedFeeRange *result;
/**
* A pointer to the contents in the error state.
* Reading from this pointer when `result_ok` is set is undefined.
*/
struct LDKDecodeError *err;
-} LDKCResult_CommitmentSignedDecodeErrorZPtr;
+} LDKCResult_ClosingSignedFeeRangeDecodeErrorZPtr;
/**
- * A CResult_CommitmentSignedDecodeErrorZ represents the result of a fallible operation,
+ * A CResult_ClosingSignedFeeRangeDecodeErrorZ represents the result of a fallible operation,
+ * containing a crate::lightning::ln::msgs::ClosingSignedFeeRange on success and a crate::lightning::ln::msgs::DecodeError on failure.
+ * `result_ok` indicates the overall state, and the contents are provided via `contents`.
+ */
+typedef struct LDKCResult_ClosingSignedFeeRangeDecodeErrorZ {
+ /**
+ * The contents of this CResult_ClosingSignedFeeRangeDecodeErrorZ, accessible via either
+ * `err` or `result` depending on the state of `result_ok`.
+ */
+ union LDKCResult_ClosingSignedFeeRangeDecodeErrorZPtr contents;
+ /**
+ * Whether this CResult_ClosingSignedFeeRangeDecodeErrorZ represents a success state.
+ */
+ bool result_ok;
+} LDKCResult_ClosingSignedFeeRangeDecodeErrorZ;
+
+
+
+/**
+ * A commitment_signed message to be sent or received from a peer
+ */
+typedef struct MUST_USE_STRUCT LDKCommitmentSigned {
+ /**
+ * A pointer to the opaque Rust object.
+ * Nearly everywhere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeCommitmentSigned *inner;
+ /**
+ * Indicates that this is the only struct which contains the same pointer.
+ * Rust functions which take ownership of an object provided via an argument require
+ * this to be true and invalidate the object pointed to by inner.
+ */
+ bool is_owned;
+} LDKCommitmentSigned;
+
+/**
+ * The contents of CResult_CommitmentSignedDecodeErrorZ
+ */
+typedef union LDKCResult_CommitmentSignedDecodeErrorZPtr {
+ /**
+ * A pointer to the contents in the success state.
+ * Reading from this pointer when `result_ok` is not set is undefined.
+ */
+ struct LDKCommitmentSigned *result;
+ /**
+ * A pointer to the contents in the error state.
+ * Reading from this pointer when `result_ok` is set is undefined.
+ */
+ struct LDKDecodeError *err;
+} LDKCResult_CommitmentSignedDecodeErrorZPtr;
+
+/**
+ * A CResult_CommitmentSignedDecodeErrorZ represents the result of a fallible operation,
* containing a crate::lightning::ln::msgs::CommitmentSigned on success and a crate::lightning::ln::msgs::DecodeError on failure.
* `result_ok` indicates the overall state, and the contents are provided via `contents`.
*/
bool is_owned;
} LDKUserConfig;
+
+
+/**
+ * The best known block as identified by its hash and height.
+ */
+typedef struct MUST_USE_STRUCT LDKBestBlock {
+ /**
+ * A pointer to the opaque Rust object.
+ * Nearly everywhere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeBestBlock *inner;
+ /**
+ * Indicates that this is the only struct which contains the same pointer.
+ * Rust functions which take ownership of an object provided via an argument require
+ * this to be true and invalidate the object pointed to by inner.
+ */
+ bool is_owned;
+} LDKBestBlock;
+
/**
* The `Access` trait defines behavior for accessing chain data and state, such as blocks and
* UTXOs.
/**
- * The best known block as identified by its hash and height.
+ * Channel parameters which apply to our counterparty. These are split out from [`ChannelDetails`]
+ * to better separate parameters.
*/
-typedef struct MUST_USE_STRUCT LDKBestBlock {
+typedef struct MUST_USE_STRUCT LDKChannelCounterparty {
/**
* A pointer to the opaque Rust object.
* Nearly everywhere, inner must be non-null, however in places where
* the Rust equivalent takes an Option, it may be set to null to indicate None.
*/
- LDKnativeBestBlock *inner;
+ LDKnativeChannelCounterparty *inner;
/**
* Indicates that this is the only struct which contains the same pointer.
* Rust functions which take ownership of an object provided via an argument require
* this to be true and invalidate the object pointed to by inner.
*/
bool is_owned;
-} LDKBestBlock;
+} LDKChannelCounterparty;
/**
* A 3-byte byte array.
* starting at the node *after* the provided publickey and including batch_amount entries
* immediately higher (as defined by <PublicKey as Ord>::cmp) than starting_point.
* If None is provided for starting_point, we start at the first node.
+ *
+ * Note that starting_point (or a relevant inner pointer) may be NULL or all-0s to represent None
*/
struct LDKCVec_NodeAnnouncementZ (*get_next_node_announcements)(const void *this_arg, struct LDKPublicKey starting_point, uint8_t batch_amount);
/**
*
* For efficiency, Clone should be relatively cheap for this type.
*
- * You probably want to just extend an int and put a file descriptor in a struct and implement
- * send_data. Note that if you are using a higher-level net library that may call close() itself,
- * be careful to ensure you don't have races whereby you might register a new connection with an
- * fd which is the same as a previous one which has yet to be removed via
- * PeerManager::socket_disconnected().
+ * Two descriptors may compare equal (by [`cmp::Eq`] and [`hash::Hash`]) as long as the original
+ * has been disconnected, the [`PeerManager`] has been informed of the disconnection (either by it
+ * having triggered the disconnection or a call to [`PeerManager::socket_disconnected`]), and no
+ * further calls to the [`PeerManager`] related to the original socket occur. This allows you to
+ * use a file descriptor for your SocketDescriptor directly, however for simplicity you may wish
+ * to simply use another value which is guaranteed to be globally unique instead.
*/
typedef struct LDKSocketDescriptor {
/**
* Attempts to send some data from the given slice to the peer.
*
* Returns the amount of data which was sent, possibly 0 if the socket has since disconnected.
- * Note that in the disconnected case, socket_disconnected must still fire and further write
- * attempts may occur until that time.
+ * Note that in the disconnected case, [`PeerManager::socket_disconnected`] must still be
+ * called and further write attempts may occur until that time.
*
- * If the returned size is smaller than data.len(), a write_available event must
- * trigger the next time more data can be written. Additionally, until the a send_data event
- * completes fully, no further read_events should trigger on the same peer!
+ * If the returned size is smaller than `data.len()`, a
+ * [`PeerManager::write_buffer_space_avail`] call must be made the next time more data can be
+ * written. Additionally, until a `send_data` event completes fully, no further
+ * [`PeerManager::read_event`] calls should be made for the same peer! Because this is to
+ * prevent denial-of-service issues, you should not read or buffer any data from the socket
+ * until then.
*
- * If a read_event on this descriptor had previously returned true (indicating that read
- * events should be paused to prevent DoS in the send buffer), resume_read may be set
- * indicating that read events on this descriptor should resume. A resume_read of false does
- * *not* imply that further read events should be paused.
+ * If a [`PeerManager::read_event`] call on this descriptor had previously returned true
+ * (indicating that read events should be paused to prevent DoS in the send buffer),
+ * `resume_read` may be set indicating that read events on this descriptor should resume. A
+ * `resume_read` of false carries no meaning, and should not cause any action.
*/
uintptr_t (*send_data)(void *this_arg, struct LDKu8slice data, bool resume_read);
/**
- * Disconnect the socket pointed to by this SocketDescriptor. Once this function returns, no
- * more calls to write_buffer_space_avail, read_event or socket_disconnected may be made with
- * this descriptor. No socket_disconnected call should be generated as a result of this call,
- * though races may occur whereby disconnect_socket is called after a call to
- * socket_disconnected but prior to socket_disconnected returning.
+ * Disconnect the socket pointed to by this SocketDescriptor.
+ *
+ * You do *not* need to call [`PeerManager::socket_disconnected`] with this socket after this
+ * call (doing so is a noop).
*/
void (*disconnect_socket)(void *this_arg);
/**
*/
uint64_t (*hash)(const void *this_arg);
/**
- * Creates a copy of the object pointed to by this_arg, for a copy of this SocketDescriptor.
- * Note that the ultimate copy of the SocketDescriptor will have all function pointers the same as the original.
- * May be NULL if no action needs to be taken, the this_arg pointer will be copied into the new SocketDescriptor.
+ * Called, if set, after this SocketDescriptor has been cloned into a duplicate object.
+ * The new SocketDescriptor is provided, and should be mutated as needed to perform a
+ * deep copy of the object pointed to by this_arg or avoid any double-freeing.
*/
- void *(*clone)(const void *this_arg);
+ void (*cloned)(struct LDKSocketDescriptor *NONNULL_PTR new_SocketDescriptor);
/**
* Frees any resources associated with this object given its this_arg pointer.
* Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
/**
- * A PeerManager manages a set of peers, described by their SocketDescriptor and marshalls socket
- * events into messages which it passes on to its MessageHandlers.
+ * A PeerManager manages a set of peers, described by their [`SocketDescriptor`] and marshalls
+ * socket events into messages which it passes on to its [`MessageHandler`].
+ *
+ * Locks are taken internally, so you must never assume that reentrancy from a
+ * [`SocketDescriptor`] call back into [`PeerManager`] methods will not deadlock.
+ *
+ * Calls to [`read_event`] will decode relevant messages and pass them to the
+ * [`ChannelMessageHandler`], likely doing message processing in-line. Thus, the primary form of
+ * parallelism in Rust-Lightning is in calls to [`read_event`]. Note, however, that calls to any
+ * [`PeerManager`] functions related to the same connection must occur only in serial, making new
+ * calls only after previous ones have returned.
*
* Rather than using a plain PeerManager, it is preferable to use either a SimpleArcPeerManager
* a SimpleRefPeerManager, for conciseness. See their documentation for more details, but
* essentially you should default to using a SimpleRefPeerManager, and use a
* SimpleArcPeerManager when you require a PeerManager with a static lifetime, such as when
* you're using lightning-net-tokio.
+ *
+ * [`read_event`]: PeerManager::read_event
*/
typedef struct MUST_USE_STRUCT LDKPeerManager {
/**
* then there is a risk of channels force-closing on startup when the manager realizes it's
* outdated. However, as long as `ChannelMonitor` backups are sound, no funds besides those used
* for unilateral chain closure fees are at risk.
+ *BackgroundProcessor will immediately stop on drop. It should be stored until shutdown.
*/
typedef struct MUST_USE_STRUCT LDKBackgroundProcessor {
/**
extern const uintptr_t REVOKEABLE_REDEEMSCRIPT_MAX_LENGTH;
+extern const uint64_t DEFAULT_EXPIRY_TIME;
+
+extern const uint64_t DEFAULT_MIN_FINAL_CLTV_EXPIRY;
+
extern const uint8_t TAG_PAYMENT_HASH;
extern const uint8_t TAG_DESCRIPTION;
*/
void Transaction_free(struct LDKTransaction _res);
+/**
+ * Convenience function for constructing a new TxOut
+ */
+struct LDKTxOut TxOut_new(struct LDKCVec_u8Z script_pubkey, uint64_t value);
+
/**
* Frees the data pointed to by script_pubkey.
*/
*/
struct LDKCResult_CVec_SignatureZNoneZ CResult_CVec_SignatureZNoneZ_clone(const struct LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR orig);
+/**
+ * Creates a new CResult_ShutdownScriptDecodeErrorZ in the success state.
+ */
+struct LDKCResult_ShutdownScriptDecodeErrorZ CResult_ShutdownScriptDecodeErrorZ_ok(struct LDKShutdownScript o);
+
+/**
+ * Creates a new CResult_ShutdownScriptDecodeErrorZ in the error state.
+ */
+struct LDKCResult_ShutdownScriptDecodeErrorZ CResult_ShutdownScriptDecodeErrorZ_err(struct LDKDecodeError e);
+
+/**
+ * Frees any resources used by the CResult_ShutdownScriptDecodeErrorZ.
+ */
+void CResult_ShutdownScriptDecodeErrorZ_free(struct LDKCResult_ShutdownScriptDecodeErrorZ _res);
+
+/**
+ * Creates a new CResult_ShutdownScriptDecodeErrorZ which has the same data as `orig`
+ * but with all dynamically-allocated buffers duplicated in new buffers.
+ */
+struct LDKCResult_ShutdownScriptDecodeErrorZ CResult_ShutdownScriptDecodeErrorZ_clone(const struct LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR orig);
+
+/**
+ * Creates a new CResult_ShutdownScriptInvalidShutdownScriptZ in the success state.
+ */
+struct LDKCResult_ShutdownScriptInvalidShutdownScriptZ CResult_ShutdownScriptInvalidShutdownScriptZ_ok(struct LDKShutdownScript o);
+
+/**
+ * Creates a new CResult_ShutdownScriptInvalidShutdownScriptZ in the error state.
+ */
+struct LDKCResult_ShutdownScriptInvalidShutdownScriptZ CResult_ShutdownScriptInvalidShutdownScriptZ_err(struct LDKInvalidShutdownScript e);
+
+/**
+ * Frees any resources used by the CResult_ShutdownScriptInvalidShutdownScriptZ.
+ */
+void CResult_ShutdownScriptInvalidShutdownScriptZ_free(struct LDKCResult_ShutdownScriptInvalidShutdownScriptZ _res);
+
/**
* Creates a new CResult_NoneErrorZ in the success state.
*/
*/
void CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(struct LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ _res);
+/**
+ * Constructs a new COption_u16Z containing a u16
+ */
+struct LDKCOption_u16Z COption_u16Z_some(uint16_t o);
+
+/**
+ * Constructs a new COption_u16Z containing nothing
+ */
+struct LDKCOption_u16Z COption_u16Z_none(void);
+
+/**
+ * Frees any resources associated with the u16, if we are in the Some state
+ */
+void COption_u16Z_free(struct LDKCOption_u16Z _res);
+
+/**
+ * Creates a new COption_u16Z which has the same data as `orig`
+ * but with all dynamically-allocated buffers duplicated in new buffers.
+ */
+struct LDKCOption_u16Z COption_u16Z_clone(const struct LDKCOption_u16Z *NONNULL_PTR orig);
+
/**
* Creates a new CResult_NoneAPIErrorZ in the success state.
*/
*/
struct LDKCResult_NonePaymentSendFailureZ CResult_NonePaymentSendFailureZ_clone(const struct LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR orig);
+/**
+ * Creates a new CResult_PaymentHashPaymentSendFailureZ in the success state.
+ */
+struct LDKCResult_PaymentHashPaymentSendFailureZ CResult_PaymentHashPaymentSendFailureZ_ok(struct LDKThirtyTwoBytes o);
+
+/**
+ * Creates a new CResult_PaymentHashPaymentSendFailureZ in the error state.
+ */
+struct LDKCResult_PaymentHashPaymentSendFailureZ CResult_PaymentHashPaymentSendFailureZ_err(struct LDKPaymentSendFailure e);
+
+/**
+ * Frees any resources used by the CResult_PaymentHashPaymentSendFailureZ.
+ */
+void CResult_PaymentHashPaymentSendFailureZ_free(struct LDKCResult_PaymentHashPaymentSendFailureZ _res);
+
+/**
+ * Creates a new CResult_PaymentHashPaymentSendFailureZ which has the same data as `orig`
+ * but with all dynamically-allocated buffers duplicated in new buffers.
+ */
+struct LDKCResult_PaymentHashPaymentSendFailureZ CResult_PaymentHashPaymentSendFailureZ_clone(const struct LDKCResult_PaymentHashPaymentSendFailureZ *NONNULL_PTR orig);
+
/**
* Frees the buffer pointed to by `data` if `datalen` is non-0.
*/
*/
struct LDKCResult_ClosingSignedDecodeErrorZ CResult_ClosingSignedDecodeErrorZ_clone(const struct LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR orig);
+/**
+ * Creates a new CResult_ClosingSignedFeeRangeDecodeErrorZ in the success state.
+ */
+struct LDKCResult_ClosingSignedFeeRangeDecodeErrorZ CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(struct LDKClosingSignedFeeRange o);
+
+/**
+ * Creates a new CResult_ClosingSignedFeeRangeDecodeErrorZ in the error state.
+ */
+struct LDKCResult_ClosingSignedFeeRangeDecodeErrorZ CResult_ClosingSignedFeeRangeDecodeErrorZ_err(struct LDKDecodeError e);
+
+/**
+ * Frees any resources used by the CResult_ClosingSignedFeeRangeDecodeErrorZ.
+ */
+void CResult_ClosingSignedFeeRangeDecodeErrorZ_free(struct LDKCResult_ClosingSignedFeeRangeDecodeErrorZ _res);
+
+/**
+ * Creates a new CResult_ClosingSignedFeeRangeDecodeErrorZ which has the same data as `orig`
+ * but with all dynamically-allocated buffers duplicated in new buffers.
+ */
+struct LDKCResult_ClosingSignedFeeRangeDecodeErrorZ CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(const struct LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR orig);
+
/**
* Creates a new CResult_CommitmentSignedDecodeErrorZ in the success state.
*/
struct LDKCResult_InvoiceSignOrCreationErrorZ CResult_InvoiceSignOrCreationErrorZ_clone(const struct LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR orig);
/**
- * Frees any resources used by the Event
+ * Frees any resources used by the PaymentPurpose
*/
-void Event_free(struct LDKEvent this_ptr);
+void PaymentPurpose_free(struct LDKPaymentPurpose this_ptr);
/**
- * Creates a copy of the Event
+ * Creates a copy of the PaymentPurpose
*/
-struct LDKEvent Event_clone(const struct LDKEvent *NONNULL_PTR orig);
+struct LDKPaymentPurpose PaymentPurpose_clone(const struct LDKPaymentPurpose *NONNULL_PTR orig);
/**
- * Serialize the Event object into a byte array which can be read by Event_read
+ * Utility method to constructs a new InvoicePayment-variant PaymentPurpose
*/
-struct LDKCVec_u8Z Event_write(const struct LDKEvent *NONNULL_PTR obj);
+struct LDKPaymentPurpose PaymentPurpose_invoice_payment(struct LDKThirtyTwoBytes payment_preimage, struct LDKThirtyTwoBytes payment_secret, uint64_t user_payment_id);
/**
- * Frees any resources used by the MessageSendEvent
+ * Utility method to constructs a new SpontaneousPayment-variant PaymentPurpose
*/
-void MessageSendEvent_free(struct LDKMessageSendEvent this_ptr);
+struct LDKPaymentPurpose PaymentPurpose_spontaneous_payment(struct LDKThirtyTwoBytes a);
/**
- * Creates a copy of the MessageSendEvent
+ * Frees any resources used by the Event
*/
-struct LDKMessageSendEvent MessageSendEvent_clone(const struct LDKMessageSendEvent *NONNULL_PTR orig);
+void Event_free(struct LDKEvent this_ptr);
/**
- * Calls the free function if one is set
+ * Creates a copy of the Event
*/
-void MessageSendEventsProvider_free(struct LDKMessageSendEventsProvider this_ptr);
+struct LDKEvent Event_clone(const struct LDKEvent *NONNULL_PTR orig);
/**
- * Calls the free function if one is set
+ * Utility method to constructs a new FundingGenerationReady-variant Event
*/
-void EventsProvider_free(struct LDKEventsProvider this_ptr);
+struct LDKEvent Event_funding_generation_ready(struct LDKThirtyTwoBytes temporary_channel_id, uint64_t channel_value_satoshis, struct LDKCVec_u8Z output_script, uint64_t user_channel_id);
/**
- * Calls the free function if one is set
+ * Utility method to constructs a new PaymentReceived-variant Event
*/
-void EventHandler_free(struct LDKEventHandler this_ptr);
+struct LDKEvent Event_payment_received(struct LDKThirtyTwoBytes payment_hash, uint64_t amt, struct LDKPaymentPurpose purpose);
/**
- * Frees any resources used by the APIError
+ * Utility method to constructs a new PaymentSent-variant Event
*/
-void APIError_free(struct LDKAPIError this_ptr);
+struct LDKEvent Event_payment_sent(struct LDKThirtyTwoBytes payment_preimage);
/**
- * Creates a copy of the APIError
+ * Utility method to constructs a new PaymentFailed-variant Event
*/
-struct LDKAPIError APIError_clone(const struct LDKAPIError *NONNULL_PTR orig);
+struct LDKEvent Event_payment_failed(struct LDKThirtyTwoBytes payment_hash, bool rejected_by_dest);
/**
- * Creates a digital signature of a message given a SecretKey, like the node's secret.
- * A receiver knowing the PublicKey (e.g. the node's id) and the message can be sure that the signature was generated by the caller.
- * Signatures are EC recoverable, meaning that given the message and the signature the PublicKey of the signer can be extracted.
+ * Utility method to constructs a new PendingHTLCsForwardable-variant Event
*/
-struct LDKCResult_StringErrorZ sign(struct LDKu8slice msg, struct LDKSecretKey sk);
+struct LDKEvent Event_pending_htlcs_forwardable(uint64_t time_forwardable);
/**
- * Recovers the PublicKey of the signer of the message given the message and the signature.
+ * Utility method to constructs a new SpendableOutputs-variant Event
*/
-struct LDKCResult_PublicKeyErrorZ recover_pk(struct LDKu8slice msg, struct LDKStr sig);
+struct LDKEvent Event_spendable_outputs(struct LDKCVec_SpendableOutputDescriptorZ outputs);
/**
- * Verifies a message was signed by a PrivateKey that derives to a given PublicKey, given a message, a signature,
- * and the PublicKey.
+ * Utility method to constructs a new PaymentForwarded-variant Event
*/
-bool verify(struct LDKu8slice msg, struct LDKStr sig, struct LDKPublicKey pk);
+struct LDKEvent Event_payment_forwarded(struct LDKCOption_u64Z fee_earned_msat, bool claim_from_onchain_tx);
/**
- * Creates a copy of the Level
+ * Serialize the Event object into a byte array which can be read by Event_read
*/
-enum LDKLevel Level_clone(const enum LDKLevel *NONNULL_PTR orig);
+struct LDKCVec_u8Z Event_write(const struct LDKEvent *NONNULL_PTR obj);
/**
- * Checks if two Levels contain equal inner contents.
- * This ignores pointers and is_owned flags and looks at the values in fields.
+ * Frees any resources used by the MessageSendEvent
*/
-bool Level_eq(const enum LDKLevel *NONNULL_PTR a, const enum LDKLevel *NONNULL_PTR b);
+void MessageSendEvent_free(struct LDKMessageSendEvent this_ptr);
/**
- * Checks if two Levels contain equal inner contents.
+ * Creates a copy of the MessageSendEvent
*/
-uint64_t Level_hash(const enum LDKLevel *NONNULL_PTR o);
+struct LDKMessageSendEvent MessageSendEvent_clone(const struct LDKMessageSendEvent *NONNULL_PTR orig);
/**
- * Returns the most verbose logging level.
+ * Utility method to constructs a new SendAcceptChannel-variant MessageSendEvent
*/
-MUST_USE_RES enum LDKLevel Level_max(void);
+struct LDKMessageSendEvent MessageSendEvent_send_accept_channel(struct LDKPublicKey node_id, struct LDKAcceptChannel msg);
/**
- * Calls the free function if one is set
+ * Utility method to constructs a new SendOpenChannel-variant MessageSendEvent
*/
-void Logger_free(struct LDKLogger this_ptr);
+struct LDKMessageSendEvent MessageSendEvent_send_open_channel(struct LDKPublicKey node_id, struct LDKOpenChannel msg);
/**
- * Frees any resources used by the ChannelHandshakeConfig, if is_owned is set and inner is non-NULL.
+ * Utility method to constructs a new SendFundingCreated-variant MessageSendEvent
*/
-void ChannelHandshakeConfig_free(struct LDKChannelHandshakeConfig this_obj);
+struct LDKMessageSendEvent MessageSendEvent_send_funding_created(struct LDKPublicKey node_id, struct LDKFundingCreated msg);
/**
- * Confirmations we will wait for before considering the channel locked in.
- * Applied only for inbound channels (see ChannelHandshakeLimits::max_minimum_depth for the
- * equivalent limit applied to outbound channels).
- *
- * Default value: 6.
+ * Utility method to constructs a new SendFundingSigned-variant MessageSendEvent
*/
-uint32_t ChannelHandshakeConfig_get_minimum_depth(const struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr);
+struct LDKMessageSendEvent MessageSendEvent_send_funding_signed(struct LDKPublicKey node_id, struct LDKFundingSigned msg);
/**
- * Confirmations we will wait for before considering the channel locked in.
- * Applied only for inbound channels (see ChannelHandshakeLimits::max_minimum_depth for the
- * equivalent limit applied to outbound channels).
- *
- * Default value: 6.
+ * Utility method to constructs a new SendFundingLocked-variant MessageSendEvent
*/
-void ChannelHandshakeConfig_set_minimum_depth(struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr, uint32_t val);
+struct LDKMessageSendEvent MessageSendEvent_send_funding_locked(struct LDKPublicKey node_id, struct LDKFundingLocked msg);
/**
- * Set to the number of blocks we require our counterparty to wait to claim their money (ie
- * the number of blocks we have to punish our counterparty if they broadcast a revoked
- * transaction).
- *
- * This is one of the main parameters of our security model. We (or one of our watchtowers) MUST
- * be online to check for revoked transactions on-chain at least once every our_to_self_delay
- * blocks (minus some margin to allow us enough time to broadcast and confirm a transaction,
- * possibly with time in between to RBF the spending transaction).
- *
- * Meanwhile, asking for a too high delay, we bother peer to freeze funds for nothing in
- * case of an honest unilateral channel close, which implicitly decrease the economic value of
- * our channel.
- *
- * Default value: [`BREAKDOWN_TIMEOUT`], we enforce it as a minimum at channel opening so you
- * can tweak config to ask for more security, not less.
+ * Utility method to constructs a new SendAnnouncementSignatures-variant MessageSendEvent
*/
-uint16_t ChannelHandshakeConfig_get_our_to_self_delay(const struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr);
+struct LDKMessageSendEvent MessageSendEvent_send_announcement_signatures(struct LDKPublicKey node_id, struct LDKAnnouncementSignatures msg);
/**
- * Set to the number of blocks we require our counterparty to wait to claim their money (ie
- * the number of blocks we have to punish our counterparty if they broadcast a revoked
- * transaction).
- *
- * This is one of the main parameters of our security model. We (or one of our watchtowers) MUST
- * be online to check for revoked transactions on-chain at least once every our_to_self_delay
- * blocks (minus some margin to allow us enough time to broadcast and confirm a transaction,
- * possibly with time in between to RBF the spending transaction).
- *
- * Meanwhile, asking for a too high delay, we bother peer to freeze funds for nothing in
- * case of an honest unilateral channel close, which implicitly decrease the economic value of
- * our channel.
- *
- * Default value: [`BREAKDOWN_TIMEOUT`], we enforce it as a minimum at channel opening so you
- * can tweak config to ask for more security, not less.
+ * Utility method to constructs a new UpdateHTLCs-variant MessageSendEvent
*/
-void ChannelHandshakeConfig_set_our_to_self_delay(struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr, uint16_t val);
+struct LDKMessageSendEvent MessageSendEvent_update_htlcs(struct LDKPublicKey node_id, struct LDKCommitmentUpdate updates);
/**
- * Set to the smallest value HTLC we will accept to process.
- *
- * This value is sent to our counterparty on channel-open and we close the channel any time
- * our counterparty misbehaves by sending us an HTLC with a value smaller than this.
- *
- * Default value: 1. If the value is less than 1, it is ignored and set to 1, as is required
- * by the protocol.
+ * Utility method to constructs a new SendRevokeAndACK-variant MessageSendEvent
*/
-uint64_t ChannelHandshakeConfig_get_our_htlc_minimum_msat(const struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr);
+struct LDKMessageSendEvent MessageSendEvent_send_revoke_and_ack(struct LDKPublicKey node_id, struct LDKRevokeAndACK msg);
/**
- * Set to the smallest value HTLC we will accept to process.
- *
- * This value is sent to our counterparty on channel-open and we close the channel any time
- * our counterparty misbehaves by sending us an HTLC with a value smaller than this.
- *
- * Default value: 1. If the value is less than 1, it is ignored and set to 1, as is required
- * by the protocol.
+ * Utility method to constructs a new SendClosingSigned-variant MessageSendEvent
*/
-void ChannelHandshakeConfig_set_our_htlc_minimum_msat(struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr, uint64_t val);
+struct LDKMessageSendEvent MessageSendEvent_send_closing_signed(struct LDKPublicKey node_id, struct LDKClosingSigned msg);
/**
- * Constructs a new ChannelHandshakeConfig given each field
+ * Utility method to constructs a new SendShutdown-variant MessageSendEvent
*/
-MUST_USE_RES struct LDKChannelHandshakeConfig ChannelHandshakeConfig_new(uint32_t minimum_depth_arg, uint16_t our_to_self_delay_arg, uint64_t our_htlc_minimum_msat_arg);
+struct LDKMessageSendEvent MessageSendEvent_send_shutdown(struct LDKPublicKey node_id, struct LDKShutdown msg);
/**
- * Creates a copy of the ChannelHandshakeConfig
+ * Utility method to constructs a new SendChannelReestablish-variant MessageSendEvent
+ */
+struct LDKMessageSendEvent MessageSendEvent_send_channel_reestablish(struct LDKPublicKey node_id, struct LDKChannelReestablish msg);
+
+/**
+ * Utility method to constructs a new BroadcastChannelAnnouncement-variant MessageSendEvent
+ */
+struct LDKMessageSendEvent MessageSendEvent_broadcast_channel_announcement(struct LDKChannelAnnouncement msg, struct LDKChannelUpdate update_msg);
+
+/**
+ * Utility method to constructs a new BroadcastNodeAnnouncement-variant MessageSendEvent
+ */
+struct LDKMessageSendEvent MessageSendEvent_broadcast_node_announcement(struct LDKNodeAnnouncement msg);
+
+/**
+ * Utility method to constructs a new BroadcastChannelUpdate-variant MessageSendEvent
+ */
+struct LDKMessageSendEvent MessageSendEvent_broadcast_channel_update(struct LDKChannelUpdate msg);
+
+/**
+ * Utility method to constructs a new SendChannelUpdate-variant MessageSendEvent
+ */
+struct LDKMessageSendEvent MessageSendEvent_send_channel_update(struct LDKPublicKey node_id, struct LDKChannelUpdate msg);
+
+/**
+ * Utility method to constructs a new HandleError-variant MessageSendEvent
+ */
+struct LDKMessageSendEvent MessageSendEvent_handle_error(struct LDKPublicKey node_id, struct LDKErrorAction action);
+
+/**
+ * Utility method to constructs a new PaymentFailureNetworkUpdate-variant MessageSendEvent
+ */
+struct LDKMessageSendEvent MessageSendEvent_payment_failure_network_update(struct LDKHTLCFailChannelUpdate update);
+
+/**
+ * Utility method to constructs a new SendChannelRangeQuery-variant MessageSendEvent
+ */
+struct LDKMessageSendEvent MessageSendEvent_send_channel_range_query(struct LDKPublicKey node_id, struct LDKQueryChannelRange msg);
+
+/**
+ * Utility method to constructs a new SendShortIdsQuery-variant MessageSendEvent
+ */
+struct LDKMessageSendEvent MessageSendEvent_send_short_ids_query(struct LDKPublicKey node_id, struct LDKQueryShortChannelIds msg);
+
+/**
+ * Utility method to constructs a new SendReplyChannelRange-variant MessageSendEvent
+ */
+struct LDKMessageSendEvent MessageSendEvent_send_reply_channel_range(struct LDKPublicKey node_id, struct LDKReplyChannelRange msg);
+
+/**
+ * Calls the free function if one is set
+ */
+void MessageSendEventsProvider_free(struct LDKMessageSendEventsProvider this_ptr);
+
+/**
+ * Calls the free function if one is set
+ */
+void EventsProvider_free(struct LDKEventsProvider this_ptr);
+
+/**
+ * Calls the free function if one is set
+ */
+void EventHandler_free(struct LDKEventHandler this_ptr);
+
+/**
+ * Frees any resources used by the APIError
+ */
+void APIError_free(struct LDKAPIError this_ptr);
+
+/**
+ * Creates a copy of the APIError
+ */
+struct LDKAPIError APIError_clone(const struct LDKAPIError *NONNULL_PTR orig);
+
+/**
+ * Utility method to constructs a new APIMisuseError-variant APIError
+ */
+struct LDKAPIError APIError_apimisuse_error(struct LDKStr err);
+
+/**
+ * Utility method to constructs a new FeeRateTooHigh-variant APIError
+ */
+struct LDKAPIError APIError_fee_rate_too_high(struct LDKStr err, uint32_t feerate);
+
+/**
+ * Utility method to constructs a new RouteError-variant APIError
+ */
+struct LDKAPIError APIError_route_error(struct LDKStr err);
+
+/**
+ * Utility method to constructs a new ChannelUnavailable-variant APIError
+ */
+struct LDKAPIError APIError_channel_unavailable(struct LDKStr err);
+
+/**
+ * Utility method to constructs a new MonitorUpdateFailed-variant APIError
+ */
+struct LDKAPIError APIError_monitor_update_failed(void);
+
+/**
+ * Utility method to constructs a new IncompatibleShutdownScript-variant APIError
+ */
+struct LDKAPIError APIError_incompatible_shutdown_script(struct LDKShutdownScript script);
+
+/**
+ * Creates a digital signature of a message given a SecretKey, like the node's secret.
+ * A receiver knowing the PublicKey (e.g. the node's id) and the message can be sure that the signature was generated by the caller.
+ * Signatures are EC recoverable, meaning that given the message and the signature the PublicKey of the signer can be extracted.
+ */
+struct LDKCResult_StringErrorZ sign(struct LDKu8slice msg, const uint8_t (*sk)[32]);
+
+/**
+ * Recovers the PublicKey of the signer of the message given the message and the signature.
+ */
+struct LDKCResult_PublicKeyErrorZ recover_pk(struct LDKu8slice msg, struct LDKStr sig);
+
+/**
+ * Verifies a message was signed by a PrivateKey that derives to a given PublicKey, given a message, a signature,
+ * and the PublicKey.
+ */
+bool verify(struct LDKu8slice msg, struct LDKStr sig, struct LDKPublicKey pk);
+
+/**
+ * Creates a copy of the Level
+ */
+enum LDKLevel Level_clone(const enum LDKLevel *NONNULL_PTR orig);
+
+/**
+ * Utility method to constructs a new Trace-variant Level
+ */
+enum LDKLevel Level_trace(void);
+
+/**
+ * Utility method to constructs a new Debug-variant Level
+ */
+enum LDKLevel Level_debug(void);
+
+/**
+ * Utility method to constructs a new Info-variant Level
+ */
+enum LDKLevel Level_info(void);
+
+/**
+ * Utility method to constructs a new Warn-variant Level
+ */
+enum LDKLevel Level_warn(void);
+
+/**
+ * Utility method to constructs a new Error-variant Level
+ */
+enum LDKLevel Level_error(void);
+
+/**
+ * Checks if two Levels contain equal inner contents.
+ * This ignores pointers and is_owned flags and looks at the values in fields.
+ */
+bool Level_eq(const enum LDKLevel *NONNULL_PTR a, const enum LDKLevel *NONNULL_PTR b);
+
+/**
+ * Checks if two Levels contain equal inner contents.
+ */
+uint64_t Level_hash(const enum LDKLevel *NONNULL_PTR o);
+
+/**
+ * Returns the most verbose logging level.
+ */
+MUST_USE_RES enum LDKLevel Level_max(void);
+
+/**
+ * Calls the free function if one is set
+ */
+void Logger_free(struct LDKLogger this_ptr);
+
+/**
+ * Frees any resources used by the ChannelHandshakeConfig, if is_owned is set and inner is non-NULL.
+ */
+void ChannelHandshakeConfig_free(struct LDKChannelHandshakeConfig this_obj);
+
+/**
+ * Confirmations we will wait for before considering the channel locked in.
+ * Applied only for inbound channels (see ChannelHandshakeLimits::max_minimum_depth for the
+ * equivalent limit applied to outbound channels).
+ *
+ * Default value: 6.
+ */
+uint32_t ChannelHandshakeConfig_get_minimum_depth(const struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr);
+
+/**
+ * Confirmations we will wait for before considering the channel locked in.
+ * Applied only for inbound channels (see ChannelHandshakeLimits::max_minimum_depth for the
+ * equivalent limit applied to outbound channels).
+ *
+ * Default value: 6.
+ */
+void ChannelHandshakeConfig_set_minimum_depth(struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr, uint32_t val);
+
+/**
+ * Set to the number of blocks we require our counterparty to wait to claim their money (ie
+ * the number of blocks we have to punish our counterparty if they broadcast a revoked
+ * transaction).
+ *
+ * This is one of the main parameters of our security model. We (or one of our watchtowers) MUST
+ * be online to check for revoked transactions on-chain at least once every our_to_self_delay
+ * blocks (minus some margin to allow us enough time to broadcast and confirm a transaction,
+ * possibly with time in between to RBF the spending transaction).
+ *
+ * Meanwhile, asking for a too high delay, we bother peer to freeze funds for nothing in
+ * case of an honest unilateral channel close, which implicitly decrease the economic value of
+ * our channel.
+ *
+ * Default value: [`BREAKDOWN_TIMEOUT`], we enforce it as a minimum at channel opening so you
+ * can tweak config to ask for more security, not less.
+ */
+uint16_t ChannelHandshakeConfig_get_our_to_self_delay(const struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr);
+
+/**
+ * Set to the number of blocks we require our counterparty to wait to claim their money (ie
+ * the number of blocks we have to punish our counterparty if they broadcast a revoked
+ * transaction).
+ *
+ * This is one of the main parameters of our security model. We (or one of our watchtowers) MUST
+ * be online to check for revoked transactions on-chain at least once every our_to_self_delay
+ * blocks (minus some margin to allow us enough time to broadcast and confirm a transaction,
+ * possibly with time in between to RBF the spending transaction).
+ *
+ * Meanwhile, asking for a too high delay, we bother peer to freeze funds for nothing in
+ * case of an honest unilateral channel close, which implicitly decrease the economic value of
+ * our channel.
+ *
+ * Default value: [`BREAKDOWN_TIMEOUT`], we enforce it as a minimum at channel opening so you
+ * can tweak config to ask for more security, not less.
+ */
+void ChannelHandshakeConfig_set_our_to_self_delay(struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr, uint16_t val);
+
+/**
+ * Set to the smallest value HTLC we will accept to process.
+ *
+ * This value is sent to our counterparty on channel-open and we close the channel any time
+ * our counterparty misbehaves by sending us an HTLC with a value smaller than this.
+ *
+ * Default value: 1. If the value is less than 1, it is ignored and set to 1, as is required
+ * by the protocol.
+ */
+uint64_t ChannelHandshakeConfig_get_our_htlc_minimum_msat(const struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr);
+
+/**
+ * Set to the smallest value HTLC we will accept to process.
+ *
+ * This value is sent to our counterparty on channel-open and we close the channel any time
+ * our counterparty misbehaves by sending us an HTLC with a value smaller than this.
+ *
+ * Default value: 1. If the value is less than 1, it is ignored and set to 1, as is required
+ * by the protocol.
+ */
+void ChannelHandshakeConfig_set_our_htlc_minimum_msat(struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr, uint64_t val);
+
+/**
+ * Constructs a new ChannelHandshakeConfig given each field
+ */
+MUST_USE_RES struct LDKChannelHandshakeConfig ChannelHandshakeConfig_new(uint32_t minimum_depth_arg, uint16_t our_to_self_delay_arg, uint64_t our_htlc_minimum_msat_arg);
+
+/**
+ * Creates a copy of the ChannelHandshakeConfig
*/
struct LDKChannelHandshakeConfig ChannelHandshakeConfig_clone(const struct LDKChannelHandshakeConfig *NONNULL_PTR orig);
void ChannelHandshakeLimits_set_max_minimum_depth(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, uint32_t val);
/**
- * Set to force the incoming channel to match our announced channel preference in
- * ChannelConfig.
+ * Set to force an incoming channel to match our announced channel preference in
+ * [`ChannelConfig::announced_channel`].
*
- * Default value: true, to make the default that no announced channels are possible (which is
- * appropriate for any nodes which are not online very reliably).
+ * For a node which is not online reliably, this should be set to true and
+ * [`ChannelConfig::announced_channel`] set to false, ensuring that no announced (aka public)
+ * channels will ever be opened.
+ *
+ * Default value: true.
*/
bool ChannelHandshakeLimits_get_force_announced_channel_preference(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr);
/**
- * Set to force the incoming channel to match our announced channel preference in
- * ChannelConfig.
+ * Set to force an incoming channel to match our announced channel preference in
+ * [`ChannelConfig::announced_channel`].
+ *
+ * For a node which is not online reliably, this should be set to true and
+ * [`ChannelConfig::announced_channel`] set to false, ensuring that no announced (aka public)
+ * channels will ever be opened.
*
- * Default value: true, to make the default that no announced channels are possible (which is
- * appropriate for any nodes which are not online very reliably).
+ * Default value: true.
*/
void ChannelHandshakeLimits_set_force_announced_channel_preference(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, bool val);
void ChannelConfig_free(struct LDKChannelConfig this_obj);
/**
- * Amount (in millionths of a satoshi) the channel will charge per transferred satoshi.
+ * Amount (in millionths of a satoshi) charged per satoshi for payments forwarded outbound
+ * over the channel.
* This may be allowed to change at runtime in a later update, however doing so must result in
* update messages sent to notify all nodes of our updated relay fee.
*
* Default value: 0.
*/
-uint32_t ChannelConfig_get_fee_proportional_millionths(const struct LDKChannelConfig *NONNULL_PTR this_ptr);
+uint32_t ChannelConfig_get_forwarding_fee_proportional_millionths(const struct LDKChannelConfig *NONNULL_PTR this_ptr);
/**
- * Amount (in millionths of a satoshi) the channel will charge per transferred satoshi.
+ * Amount (in millionths of a satoshi) charged per satoshi for payments forwarded outbound
+ * over the channel.
* This may be allowed to change at runtime in a later update, however doing so must result in
* update messages sent to notify all nodes of our updated relay fee.
*
* Default value: 0.
*/
-void ChannelConfig_set_fee_proportional_millionths(struct LDKChannelConfig *NONNULL_PTR this_ptr, uint32_t val);
+void ChannelConfig_set_forwarding_fee_proportional_millionths(struct LDKChannelConfig *NONNULL_PTR this_ptr, uint32_t val);
+
+/**
+ * Amount (in milli-satoshi) charged for payments forwarded outbound over the channel, in
+ * excess of [`forwarding_fee_proportional_millionths`].
+ * This may be allowed to change at runtime in a later update, however doing so must result in
+ * update messages sent to notify all nodes of our updated relay fee.
+ *
+ * The default value of a single satoshi roughly matches the market rate on many routing nodes
+ * as of July 2021. Adjusting it upwards or downwards may change whether nodes route through
+ * this node.
+ *
+ * Default value: 1000.
+ *
+ * [`forwarding_fee_proportional_millionths`]: ChannelConfig::forwarding_fee_proportional_millionths
+ */
+uint32_t ChannelConfig_get_forwarding_fee_base_msat(const struct LDKChannelConfig *NONNULL_PTR this_ptr);
+
+/**
+ * Amount (in milli-satoshi) charged for payments forwarded outbound over the channel, in
+ * excess of [`forwarding_fee_proportional_millionths`].
+ * This may be allowed to change at runtime in a later update, however doing so must result in
+ * update messages sent to notify all nodes of our updated relay fee.
+ *
+ * The default value of a single satoshi roughly matches the market rate on many routing nodes
+ * as of July 2021. Adjusting it upwards or downwards may change whether nodes route through
+ * this node.
+ *
+ * Default value: 1000.
+ *
+ * [`forwarding_fee_proportional_millionths`]: ChannelConfig::forwarding_fee_proportional_millionths
+ */
+void ChannelConfig_set_forwarding_fee_base_msat(struct LDKChannelConfig *NONNULL_PTR this_ptr, uint32_t val);
/**
* The difference in the CLTV value between incoming HTLCs and an outbound HTLC forwarded over
* This should only be set to true for nodes which expect to be online reliably.
*
* As the node which funds a channel picks this value this will only apply for new outbound
- * channels unless ChannelHandshakeLimits::force_announced_channel_preferences is set.
+ * channels unless [`ChannelHandshakeLimits::force_announced_channel_preference`] is set.
*
* This cannot be changed after the initial channel handshake.
*
* This should only be set to true for nodes which expect to be online reliably.
*
* As the node which funds a channel picks this value this will only apply for new outbound
- * channels unless ChannelHandshakeLimits::force_announced_channel_preferences is set.
+ * channels unless [`ChannelHandshakeLimits::force_announced_channel_preference`] is set.
*
* This cannot be changed after the initial channel handshake.
*
*/
void ChannelConfig_set_commit_upfront_shutdown_pubkey(struct LDKChannelConfig *NONNULL_PTR this_ptr, bool val);
+/**
+ * Limit our total exposure to in-flight HTLCs which are burned to fees as they are too
+ * small to claim on-chain.
+ *
+ * When an HTLC present in one of our channels is below a \"dust\" threshold, the HTLC will
+ * not be claimable on-chain, instead being turned into additional miner fees if either
+ * party force-closes the channel. Because the threshold is per-HTLC, our total exposure
+ * to such payments may be sustantial if there are many dust HTLCs present when the
+ * channel is force-closed.
+ *
+ * This limit is applied for sent, forwarded, and received HTLCs and limits the total
+ * exposure across all three types per-channel. Setting this too low may prevent the
+ * sending or receipt of low-value HTLCs on high-traffic nodes, and this limit is very
+ * important to prevent stealing of dust HTLCs by miners.
+ *
+ * Default value: 5_000_000 msat.
+ */
+uint64_t ChannelConfig_get_max_dust_htlc_exposure_msat(const struct LDKChannelConfig *NONNULL_PTR this_ptr);
+
+/**
+ * Limit our total exposure to in-flight HTLCs which are burned to fees as they are too
+ * small to claim on-chain.
+ *
+ * When an HTLC present in one of our channels is below a \"dust\" threshold, the HTLC will
+ * not be claimable on-chain, instead being turned into additional miner fees if either
+ * party force-closes the channel. Because the threshold is per-HTLC, our total exposure
+ * to such payments may be sustantial if there are many dust HTLCs present when the
+ * channel is force-closed.
+ *
+ * This limit is applied for sent, forwarded, and received HTLCs and limits the total
+ * exposure across all three types per-channel. Setting this too low may prevent the
+ * sending or receipt of low-value HTLCs on high-traffic nodes, and this limit is very
+ * important to prevent stealing of dust HTLCs by miners.
+ *
+ * Default value: 5_000_000 msat.
+ */
+void ChannelConfig_set_max_dust_htlc_exposure_msat(struct LDKChannelConfig *NONNULL_PTR this_ptr, uint64_t val);
+
+/**
+ * The additional fee we're willing to pay to avoid waiting for the counterparty's
+ * `to_self_delay` to reclaim funds.
+ *
+ * When we close a channel cooperatively with our counterparty, we negotiate a fee for the
+ * closing transaction which both sides find acceptable, ultimately paid by the channel
+ * funder/initiator.
+ *
+ * When we are the funder, because we have to pay the channel closing fee, we bound the
+ * acceptable fee by our [`Background`] and [`Normal`] fees, with the upper bound increased by
+ * this value. Because the on-chain fee we'd pay to force-close the channel is kept near our
+ * [`Normal`] feerate during normal operation, this value represents the additional fee we're
+ * willing to pay in order to avoid waiting for our counterparty's to_self_delay to reclaim our
+ * funds.
+ *
+ * When we are not the funder, we require the closing transaction fee pay at least our
+ * [`Background`] fee estimate, but allow our counterparty to pay as much fee as they like.
+ * Thus, this value is ignored when we are not the funder.
+ *
+ * Default value: 1000 satoshis.
+ *
+ * [`Normal`]: crate::chain::chaininterface::ConfirmationTarget::Normal
+ * [`Background`]: crate::chain::chaininterface::ConfirmationTarget::Background
+ */
+uint64_t ChannelConfig_get_force_close_avoidance_max_fee_satoshis(const struct LDKChannelConfig *NONNULL_PTR this_ptr);
+
+/**
+ * The additional fee we're willing to pay to avoid waiting for the counterparty's
+ * `to_self_delay` to reclaim funds.
+ *
+ * When we close a channel cooperatively with our counterparty, we negotiate a fee for the
+ * closing transaction which both sides find acceptable, ultimately paid by the channel
+ * funder/initiator.
+ *
+ * When we are the funder, because we have to pay the channel closing fee, we bound the
+ * acceptable fee by our [`Background`] and [`Normal`] fees, with the upper bound increased by
+ * this value. Because the on-chain fee we'd pay to force-close the channel is kept near our
+ * [`Normal`] feerate during normal operation, this value represents the additional fee we're
+ * willing to pay in order to avoid waiting for our counterparty's to_self_delay to reclaim our
+ * funds.
+ *
+ * When we are not the funder, we require the closing transaction fee pay at least our
+ * [`Background`] fee estimate, but allow our counterparty to pay as much fee as they like.
+ * Thus, this value is ignored when we are not the funder.
+ *
+ * Default value: 1000 satoshis.
+ *
+ * [`Normal`]: crate::chain::chaininterface::ConfirmationTarget::Normal
+ * [`Background`]: crate::chain::chaininterface::ConfirmationTarget::Background
+ */
+void ChannelConfig_set_force_close_avoidance_max_fee_satoshis(struct LDKChannelConfig *NONNULL_PTR this_ptr, uint64_t val);
+
/**
* Constructs a new ChannelConfig given each field
*/
-MUST_USE_RES struct LDKChannelConfig ChannelConfig_new(uint32_t fee_proportional_millionths_arg, uint16_t cltv_expiry_delta_arg, bool announced_channel_arg, bool commit_upfront_shutdown_pubkey_arg);
+MUST_USE_RES struct LDKChannelConfig ChannelConfig_new(uint32_t forwarding_fee_proportional_millionths_arg, uint32_t forwarding_fee_base_msat_arg, uint16_t cltv_expiry_delta_arg, bool announced_channel_arg, bool commit_upfront_shutdown_pubkey_arg, uint64_t max_dust_htlc_exposure_msat_arg, uint64_t force_close_avoidance_max_fee_satoshis_arg);
/**
* Creates a copy of the ChannelConfig
void UserConfig_free(struct LDKUserConfig this_obj);
/**
- * Channel config that we propose to our counterparty.
+ * Channel config that we propose to our counterparty.
+ */
+struct LDKChannelHandshakeConfig UserConfig_get_own_channel_config(const struct LDKUserConfig *NONNULL_PTR this_ptr);
+
+/**
+ * Channel config that we propose to our counterparty.
+ */
+void UserConfig_set_own_channel_config(struct LDKUserConfig *NONNULL_PTR this_ptr, struct LDKChannelHandshakeConfig val);
+
+/**
+ * Limits applied to our counterparty's proposed channel config settings.
+ */
+struct LDKChannelHandshakeLimits UserConfig_get_peer_channel_config_limits(const struct LDKUserConfig *NONNULL_PTR this_ptr);
+
+/**
+ * Limits applied to our counterparty's proposed channel config settings.
+ */
+void UserConfig_set_peer_channel_config_limits(struct LDKUserConfig *NONNULL_PTR this_ptr, struct LDKChannelHandshakeLimits val);
+
+/**
+ * Channel config which affects behavior during channel lifetime.
+ */
+struct LDKChannelConfig UserConfig_get_channel_options(const struct LDKUserConfig *NONNULL_PTR this_ptr);
+
+/**
+ * Channel config which affects behavior during channel lifetime.
+ */
+void UserConfig_set_channel_options(struct LDKUserConfig *NONNULL_PTR this_ptr, struct LDKChannelConfig val);
+
+/**
+ * If this is set to false, we will reject any HTLCs which were to be forwarded over private
+ * channels. This prevents us from taking on HTLC-forwarding risk when we intend to run as a
+ * node which is not online reliably.
+ *
+ * For nodes which are not online reliably, you should set all channels to *not* be announced
+ * (using [`ChannelConfig::announced_channel`] and
+ * [`ChannelHandshakeLimits::force_announced_channel_preference`]) and set this to false to
+ * ensure you are not exposed to any forwarding risk.
+ *
+ * Note that because you cannot change a channel's announced state after creation, there is no
+ * way to disable forwarding on public channels retroactively. Thus, in order to change a node
+ * from a publicly-announced forwarding node to a private non-forwarding node you must close
+ * all your channels and open new ones. For privacy, you should also change your node_id
+ * (swapping all private and public key material for new ones) at that time.
+ *
+ * Default value: false.
+ */
+bool UserConfig_get_accept_forwards_to_priv_channels(const struct LDKUserConfig *NONNULL_PTR this_ptr);
+
+/**
+ * If this is set to false, we will reject any HTLCs which were to be forwarded over private
+ * channels. This prevents us from taking on HTLC-forwarding risk when we intend to run as a
+ * node which is not online reliably.
+ *
+ * For nodes which are not online reliably, you should set all channels to *not* be announced
+ * (using [`ChannelConfig::announced_channel`] and
+ * [`ChannelHandshakeLimits::force_announced_channel_preference`]) and set this to false to
+ * ensure you are not exposed to any forwarding risk.
+ *
+ * Note that because you cannot change a channel's announced state after creation, there is no
+ * way to disable forwarding on public channels retroactively. Thus, in order to change a node
+ * from a publicly-announced forwarding node to a private non-forwarding node you must close
+ * all your channels and open new ones. For privacy, you should also change your node_id
+ * (swapping all private and public key material for new ones) at that time.
+ *
+ * Default value: false.
+ */
+void UserConfig_set_accept_forwards_to_priv_channels(struct LDKUserConfig *NONNULL_PTR this_ptr, bool val);
+
+/**
+ * Constructs a new UserConfig given each field
+ */
+MUST_USE_RES struct LDKUserConfig UserConfig_new(struct LDKChannelHandshakeConfig own_channel_config_arg, struct LDKChannelHandshakeLimits peer_channel_config_limits_arg, struct LDKChannelConfig channel_options_arg, bool accept_forwards_to_priv_channels_arg);
+
+/**
+ * Creates a copy of the UserConfig
+ */
+struct LDKUserConfig UserConfig_clone(const struct LDKUserConfig *NONNULL_PTR orig);
+
+/**
+ * Creates a "default" UserConfig. See struct and individual field documentaiton for details on which values are used.
*/
-struct LDKChannelHandshakeConfig UserConfig_get_own_channel_config(const struct LDKUserConfig *NONNULL_PTR this_ptr);
+MUST_USE_RES struct LDKUserConfig UserConfig_default(void);
/**
- * Channel config that we propose to our counterparty.
+ * Frees any resources used by the BestBlock, if is_owned is set and inner is non-NULL.
*/
-void UserConfig_set_own_channel_config(struct LDKUserConfig *NONNULL_PTR this_ptr, struct LDKChannelHandshakeConfig val);
+void BestBlock_free(struct LDKBestBlock this_obj);
/**
- * Limits applied to our counterparty's proposed channel config settings.
+ * Creates a copy of the BestBlock
*/
-struct LDKChannelHandshakeLimits UserConfig_get_peer_channel_config_limits(const struct LDKUserConfig *NONNULL_PTR this_ptr);
+struct LDKBestBlock BestBlock_clone(const struct LDKBestBlock *NONNULL_PTR orig);
/**
- * Limits applied to our counterparty's proposed channel config settings.
+ * Constructs a `BestBlock` that represents the genesis block at height 0 of the given
+ * network.
*/
-void UserConfig_set_peer_channel_config_limits(struct LDKUserConfig *NONNULL_PTR this_ptr, struct LDKChannelHandshakeLimits val);
+MUST_USE_RES struct LDKBestBlock BestBlock_from_genesis(enum LDKNetwork network);
/**
- * Channel config which affects behavior during channel lifetime.
+ * Returns a `BestBlock` as identified by the given block hash and height.
*/
-struct LDKChannelConfig UserConfig_get_channel_options(const struct LDKUserConfig *NONNULL_PTR this_ptr);
+MUST_USE_RES struct LDKBestBlock BestBlock_new(struct LDKThirtyTwoBytes block_hash, uint32_t height);
/**
- * Channel config which affects behavior during channel lifetime.
+ * Returns the best block hash.
*/
-void UserConfig_set_channel_options(struct LDKUserConfig *NONNULL_PTR this_ptr, struct LDKChannelConfig val);
+MUST_USE_RES struct LDKThirtyTwoBytes BestBlock_block_hash(const struct LDKBestBlock *NONNULL_PTR this_arg);
/**
- * Constructs a new UserConfig given each field
+ * Returns the best block height.
*/
-MUST_USE_RES struct LDKUserConfig UserConfig_new(struct LDKChannelHandshakeConfig own_channel_config_arg, struct LDKChannelHandshakeLimits peer_channel_config_limits_arg, struct LDKChannelConfig channel_options_arg);
+MUST_USE_RES uint32_t BestBlock_height(const struct LDKBestBlock *NONNULL_PTR this_arg);
/**
- * Creates a copy of the UserConfig
+ * Creates a copy of the AccessError
*/
-struct LDKUserConfig UserConfig_clone(const struct LDKUserConfig *NONNULL_PTR orig);
+enum LDKAccessError AccessError_clone(const enum LDKAccessError *NONNULL_PTR orig);
/**
- * Creates a "default" UserConfig. See struct and individual field documentaiton for details on which values are used.
+ * Utility method to constructs a new UnknownChain-variant AccessError
*/
-MUST_USE_RES struct LDKUserConfig UserConfig_default(void);
+enum LDKAccessError AccessError_unknown_chain(void);
/**
- * Creates a copy of the AccessError
+ * Utility method to constructs a new UnknownTx-variant AccessError
*/
-enum LDKAccessError AccessError_clone(const enum LDKAccessError *NONNULL_PTR orig);
+enum LDKAccessError AccessError_unknown_tx(void);
/**
* Calls the free function if one is set
/**
* First block where the transaction output may have been spent.
+ *
+ * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
*/
struct LDKThirtyTwoBytes WatchedOutput_get_block_hash(const struct LDKWatchedOutput *NONNULL_PTR this_ptr);
/**
* First block where the transaction output may have been spent.
+ *
+ * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
*/
void WatchedOutput_set_block_hash(struct LDKWatchedOutput *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val);
*/
enum LDKConfirmationTarget ConfirmationTarget_clone(const enum LDKConfirmationTarget *NONNULL_PTR orig);
+/**
+ * Utility method to constructs a new Background-variant ConfirmationTarget
+ */
+enum LDKConfirmationTarget ConfirmationTarget_background(void);
+
+/**
+ * Utility method to constructs a new Normal-variant ConfirmationTarget
+ */
+enum LDKConfirmationTarget ConfirmationTarget_normal(void);
+
+/**
+ * Utility method to constructs a new HighPriority-variant ConfirmationTarget
+ */
+enum LDKConfirmationTarget ConfirmationTarget_high_priority(void);
+
+/**
+ * Checks if two ConfirmationTargets contain equal inner contents.
+ * This ignores pointers and is_owned flags and looks at the values in fields.
+ */
+bool ConfirmationTarget_eq(const enum LDKConfirmationTarget *NONNULL_PTR a, const enum LDKConfirmationTarget *NONNULL_PTR b);
+
/**
* Calls the free function if one is set
*/
* pre-filter blocks or only fetch blocks matching a compact filter. Otherwise, clients may
* always need to fetch full blocks absent another means for determining which blocks contain
* transactions relevant to the watched channels.
+ *
+ * Note that chain_source (or a relevant inner pointer) may be NULL or all-0s to represent None
*/
MUST_USE_RES struct LDKChainMonitor ChainMonitor_new(struct LDKFilter *chain_source, struct LDKBroadcasterInterface broadcaster, struct LDKLogger logger, struct LDKFeeEstimator feeest, struct LDKPersist persister);
*/
enum LDKChannelMonitorUpdateErr ChannelMonitorUpdateErr_clone(const enum LDKChannelMonitorUpdateErr *NONNULL_PTR orig);
+/**
+ * Utility method to constructs a new TemporaryFailure-variant ChannelMonitorUpdateErr
+ */
+enum LDKChannelMonitorUpdateErr ChannelMonitorUpdateErr_temporary_failure(void);
+
+/**
+ * Utility method to constructs a new PermanentFailure-variant ChannelMonitorUpdateErr
+ */
+enum LDKChannelMonitorUpdateErr ChannelMonitorUpdateErr_permanent_failure(void);
+
/**
* Frees any resources used by the MonitorUpdateError, if is_owned is set and inner is non-NULL.
*/
*/
struct LDKMonitorEvent MonitorEvent_clone(const struct LDKMonitorEvent *NONNULL_PTR orig);
+/**
+ * Utility method to constructs a new HTLCEvent-variant MonitorEvent
+ */
+struct LDKMonitorEvent MonitorEvent_htlcevent(struct LDKHTLCUpdate a);
+
+/**
+ * Utility method to constructs a new CommitmentTxBroadcasted-variant MonitorEvent
+ */
+struct LDKMonitorEvent MonitorEvent_commitment_tx_broadcasted(struct LDKOutPoint a);
+
/**
* Frees any resources used by the HTLCUpdate, if is_owned is set and inner is non-NULL.
*/
*/
MUST_USE_RES struct LDKCVec_TxidZ ChannelMonitor_get_relevant_txids(const struct LDKChannelMonitor *NONNULL_PTR this_arg);
+/**
+ * Gets the latest best block which was connected either via the [`chain::Listen`] or
+ * [`chain::Confirm`] interfaces.
+ */
+MUST_USE_RES struct LDKBestBlock ChannelMonitor_current_best_block(const struct LDKChannelMonitor *NONNULL_PTR this_arg);
+
/**
* Calls the free function if one is set
*/
*/
struct LDKSpendableOutputDescriptor SpendableOutputDescriptor_clone(const struct LDKSpendableOutputDescriptor *NONNULL_PTR orig);
+/**
+ * Utility method to constructs a new StaticOutput-variant SpendableOutputDescriptor
+ */
+struct LDKSpendableOutputDescriptor SpendableOutputDescriptor_static_output(struct LDKOutPoint outpoint, struct LDKTxOut output);
+
+/**
+ * Utility method to constructs a new DelayedPaymentOutput-variant SpendableOutputDescriptor
+ */
+struct LDKSpendableOutputDescriptor SpendableOutputDescriptor_delayed_payment_output(struct LDKDelayedPaymentOutputDescriptor a);
+
+/**
+ * Utility method to constructs a new StaticPaymentOutput-variant SpendableOutputDescriptor
+ */
+struct LDKSpendableOutputDescriptor SpendableOutputDescriptor_static_payment_output(struct LDKStaticPaymentOutputDescriptor a);
+
/**
* Serialize the SpendableOutputDescriptor object into a byte array which can be read by SpendableOutputDescriptor_read
*/
struct LDKChainParameters ChainParameters_clone(const struct LDKChainParameters *NONNULL_PTR orig);
/**
- * Frees any resources used by the BestBlock, if is_owned is set and inner is non-NULL.
+ * Frees any resources used by the ChannelCounterparty, if is_owned is set and inner is non-NULL.
*/
-void BestBlock_free(struct LDKBestBlock this_obj);
+void ChannelCounterparty_free(struct LDKChannelCounterparty this_obj);
/**
- * Creates a copy of the BestBlock
+ * The node_id of our counterparty
*/
-struct LDKBestBlock BestBlock_clone(const struct LDKBestBlock *NONNULL_PTR orig);
+struct LDKPublicKey ChannelCounterparty_get_node_id(const struct LDKChannelCounterparty *NONNULL_PTR this_ptr);
/**
- * Returns the best block from the genesis of the given network.
+ * The node_id of our counterparty
*/
-MUST_USE_RES struct LDKBestBlock BestBlock_from_genesis(enum LDKNetwork network);
+void ChannelCounterparty_set_node_id(struct LDKChannelCounterparty *NONNULL_PTR this_ptr, struct LDKPublicKey val);
/**
- * Returns the best block as identified by the given block hash and height.
+ * The Features the channel counterparty provided upon last connection.
+ * Useful for routing as it is the most up-to-date copy of the counterparty's features and
+ * many routing-relevant features are present in the init context.
*/
-MUST_USE_RES struct LDKBestBlock BestBlock_new(struct LDKThirtyTwoBytes block_hash, uint32_t height);
+struct LDKInitFeatures ChannelCounterparty_get_features(const struct LDKChannelCounterparty *NONNULL_PTR this_ptr);
/**
- * Returns the best block hash.
+ * The Features the channel counterparty provided upon last connection.
+ * Useful for routing as it is the most up-to-date copy of the counterparty's features and
+ * many routing-relevant features are present in the init context.
*/
-MUST_USE_RES struct LDKThirtyTwoBytes BestBlock_block_hash(const struct LDKBestBlock *NONNULL_PTR this_arg);
+void ChannelCounterparty_set_features(struct LDKChannelCounterparty *NONNULL_PTR this_ptr, struct LDKInitFeatures val);
/**
- * Returns the best block height.
+ * The value, in satoshis, that must always be held in the channel for our counterparty. This
+ * value ensures that if our counterparty broadcasts a revoked state, we can punish them by
+ * claiming at least this value on chain.
+ *
+ * This value is not included in [`inbound_capacity_msat`] as it can never be spent.
+ *
+ * [`inbound_capacity_msat`]: ChannelDetails::inbound_capacity_msat
*/
-MUST_USE_RES uint32_t BestBlock_height(const struct LDKBestBlock *NONNULL_PTR this_arg);
+uint64_t ChannelCounterparty_get_unspendable_punishment_reserve(const struct LDKChannelCounterparty *NONNULL_PTR this_ptr);
+
+/**
+ * The value, in satoshis, that must always be held in the channel for our counterparty. This
+ * value ensures that if our counterparty broadcasts a revoked state, we can punish them by
+ * claiming at least this value on chain.
+ *
+ * This value is not included in [`inbound_capacity_msat`] as it can never be spent.
+ *
+ * [`inbound_capacity_msat`]: ChannelDetails::inbound_capacity_msat
+ */
+void ChannelCounterparty_set_unspendable_punishment_reserve(struct LDKChannelCounterparty *NONNULL_PTR this_ptr, uint64_t val);
+
+/**
+ * Creates a copy of the ChannelCounterparty
+ */
+struct LDKChannelCounterparty ChannelCounterparty_clone(const struct LDKChannelCounterparty *NONNULL_PTR orig);
/**
* Frees any resources used by the ChannelDetails, if is_owned is set and inner is non-NULL.
*/
void ChannelDetails_set_channel_id(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val);
+/**
+ * Parameters which apply to our counterparty. See individual fields for more information.
+ */
+struct LDKChannelCounterparty ChannelDetails_get_counterparty(const struct LDKChannelDetails *NONNULL_PTR this_ptr);
+
+/**
+ * Parameters which apply to our counterparty. See individual fields for more information.
+ */
+void ChannelDetails_set_counterparty(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKChannelCounterparty val);
+
/**
* The Channel's funding transaction output, if we've negotiated the funding transaction with
* our counterparty already.
*
* Note that, if this has been set, `channel_id` will be equivalent to
* `funding_txo.unwrap().to_channel_id()`.
+ *
+ * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
*/
struct LDKOutPoint ChannelDetails_get_funding_txo(const struct LDKChannelDetails *NONNULL_PTR this_ptr);
*
* Note that, if this has been set, `channel_id` will be equivalent to
* `funding_txo.unwrap().to_channel_id()`.
+ *
+ * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
*/
void ChannelDetails_set_funding_txo(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKOutPoint val);
void ChannelDetails_set_short_channel_id(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val);
/**
- * The node_id of our counterparty
- */
-struct LDKPublicKey ChannelDetails_get_remote_network_id(const struct LDKChannelDetails *NONNULL_PTR this_ptr);
-
-/**
- * The node_id of our counterparty
- */
-void ChannelDetails_set_remote_network_id(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKPublicKey val);
-
-/**
- * The Features the channel counterparty provided upon last connection.
- * Useful for routing as it is the most up-to-date copy of the counterparty's features and
- * many routing-relevant features are present in the init context.
+ * The value, in satoshis, of this channel as appears in the funding output
*/
-struct LDKInitFeatures ChannelDetails_get_counterparty_features(const struct LDKChannelDetails *NONNULL_PTR this_ptr);
+uint64_t ChannelDetails_get_channel_value_satoshis(const struct LDKChannelDetails *NONNULL_PTR this_ptr);
/**
- * The Features the channel counterparty provided upon last connection.
- * Useful for routing as it is the most up-to-date copy of the counterparty's features and
- * many routing-relevant features are present in the init context.
+ * The value, in satoshis, of this channel as appears in the funding output
*/
-void ChannelDetails_set_counterparty_features(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKInitFeatures val);
+void ChannelDetails_set_channel_value_satoshis(struct LDKChannelDetails *NONNULL_PTR this_ptr, uint64_t val);
/**
- * The value, in satoshis, of this channel as appears in the funding output
+ * The value, in satoshis, that must always be held in the channel for us. This value ensures
+ * that if we broadcast a revoked state, our counterparty can punish us by claiming at least
+ * this value on chain.
+ *
+ * This value is not included in [`outbound_capacity_msat`] as it can never be spent.
+ *
+ * This value will be `None` for outbound channels until the counterparty accepts the channel.
+ *
+ * [`outbound_capacity_msat`]: ChannelDetails::outbound_capacity_msat
*/
-uint64_t ChannelDetails_get_channel_value_satoshis(const struct LDKChannelDetails *NONNULL_PTR this_ptr);
+struct LDKCOption_u64Z ChannelDetails_get_unspendable_punishment_reserve(const struct LDKChannelDetails *NONNULL_PTR this_ptr);
/**
- * The value, in satoshis, of this channel as appears in the funding output
+ * The value, in satoshis, that must always be held in the channel for us. This value ensures
+ * that if we broadcast a revoked state, our counterparty can punish us by claiming at least
+ * this value on chain.
+ *
+ * This value is not included in [`outbound_capacity_msat`] as it can never be spent.
+ *
+ * This value will be `None` for outbound channels until the counterparty accepts the channel.
+ *
+ * [`outbound_capacity_msat`]: ChannelDetails::outbound_capacity_msat
*/
-void ChannelDetails_set_channel_value_satoshis(struct LDKChannelDetails *NONNULL_PTR this_ptr, uint64_t val);
+void ChannelDetails_set_unspendable_punishment_reserve(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val);
/**
* The user_id passed in to create_channel, or 0 if the channel was inbound.
* any pending HTLCs which are not yet fully resolved (and, thus, who's balance is not
* available for inclusion in new outbound HTLCs). This further does not include any pending
* outgoing HTLCs which are awaiting some other resolution to be sent.
+ *
+ * This value is not exact. Due to various in-flight changes, feerate changes, and our
+ * conflict-avoidance policy, exactly this amount is not likely to be spendable. However, we
+ * should be able to spend nearly this amount.
*/
uint64_t ChannelDetails_get_outbound_capacity_msat(const struct LDKChannelDetails *NONNULL_PTR this_ptr);
* any pending HTLCs which are not yet fully resolved (and, thus, who's balance is not
* available for inclusion in new outbound HTLCs). This further does not include any pending
* outgoing HTLCs which are awaiting some other resolution to be sent.
+ *
+ * This value is not exact. Due to various in-flight changes, feerate changes, and our
+ * conflict-avoidance policy, exactly this amount is not likely to be spendable. However, we
+ * should be able to spend nearly this amount.
*/
void ChannelDetails_set_outbound_capacity_msat(struct LDKChannelDetails *NONNULL_PTR this_ptr, uint64_t val);
* available for inclusion in new inbound HTLCs).
* Note that there are some corner cases not fully handled here, so the actual available
* inbound capacity may be slightly higher than this.
+ *
+ * This value is not exact. Due to various in-flight changes, feerate changes, and our
+ * counterparty's conflict-avoidance policy, exactly this amount is not likely to be spendable.
+ * However, our counterparty should be able to spend nearly this amount.
*/
uint64_t ChannelDetails_get_inbound_capacity_msat(const struct LDKChannelDetails *NONNULL_PTR this_ptr);
* available for inclusion in new inbound HTLCs).
* Note that there are some corner cases not fully handled here, so the actual available
* inbound capacity may be slightly higher than this.
+ *
+ * This value is not exact. Due to various in-flight changes, feerate changes, and our
+ * counterparty's conflict-avoidance policy, exactly this amount is not likely to be spendable.
+ * However, our counterparty should be able to spend nearly this amount.
*/
void ChannelDetails_set_inbound_capacity_msat(struct LDKChannelDetails *NONNULL_PTR this_ptr, uint64_t val);
+/**
+ * The number of required confirmations on the funding transaction before the funding will be
+ * considered \"locked\". This number is selected by the channel fundee (i.e. us if
+ * [`is_outbound`] is *not* set), and can be selected for inbound channels with
+ * [`ChannelHandshakeConfig::minimum_depth`] or limited for outbound channels with
+ * [`ChannelHandshakeLimits::max_minimum_depth`].
+ *
+ * This value will be `None` for outbound channels until the counterparty accepts the channel.
+ *
+ * [`is_outbound`]: ChannelDetails::is_outbound
+ * [`ChannelHandshakeConfig::minimum_depth`]: crate::util::config::ChannelHandshakeConfig::minimum_depth
+ * [`ChannelHandshakeLimits::max_minimum_depth`]: crate::util::config::ChannelHandshakeLimits::max_minimum_depth
+ */
+struct LDKCOption_u32Z ChannelDetails_get_confirmations_required(const struct LDKChannelDetails *NONNULL_PTR this_ptr);
+
+/**
+ * The number of required confirmations on the funding transaction before the funding will be
+ * considered \"locked\". This number is selected by the channel fundee (i.e. us if
+ * [`is_outbound`] is *not* set), and can be selected for inbound channels with
+ * [`ChannelHandshakeConfig::minimum_depth`] or limited for outbound channels with
+ * [`ChannelHandshakeLimits::max_minimum_depth`].
+ *
+ * This value will be `None` for outbound channels until the counterparty accepts the channel.
+ *
+ * [`is_outbound`]: ChannelDetails::is_outbound
+ * [`ChannelHandshakeConfig::minimum_depth`]: crate::util::config::ChannelHandshakeConfig::minimum_depth
+ * [`ChannelHandshakeLimits::max_minimum_depth`]: crate::util::config::ChannelHandshakeLimits::max_minimum_depth
+ */
+void ChannelDetails_set_confirmations_required(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u32Z val);
+
+/**
+ * The number of blocks (after our commitment transaction confirms) that we will need to wait
+ * until we can claim our funds after we force-close the channel. During this time our
+ * counterparty is allowed to punish us if we broadcasted a stale state. If our counterparty
+ * force-closes the channel and broadcasts a commitment transaction we do not have to wait any
+ * time to claim our non-HTLC-encumbered funds.
+ *
+ * This value will be `None` for outbound channels until the counterparty accepts the channel.
+ */
+struct LDKCOption_u16Z ChannelDetails_get_force_close_spend_delay(const struct LDKChannelDetails *NONNULL_PTR this_ptr);
+
+/**
+ * The number of blocks (after our commitment transaction confirms) that we will need to wait
+ * until we can claim our funds after we force-close the channel. During this time our
+ * counterparty is allowed to punish us if we broadcasted a stale state. If our counterparty
+ * force-closes the channel and broadcasts a commitment transaction we do not have to wait any
+ * time to claim our non-HTLC-encumbered funds.
+ *
+ * This value will be `None` for outbound channels until the counterparty accepts the channel.
+ */
+void ChannelDetails_set_force_close_spend_delay(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u16Z val);
+
/**
* True if the channel was initiated (and thus funded) by us.
*/
* True if the channel is confirmed, funding_locked messages have been exchanged, and the
* channel is not currently being shut down. `funding_locked` message exchange implies the
* required confirmation count has been reached (and we were connected to the peer at some
- * point after the funding transaction received enough confirmations).
+ * point after the funding transaction received enough confirmations). The required
+ * confirmation count is provided in [`confirmations_required`].
+ *
+ * [`confirmations_required`]: ChannelDetails::confirmations_required
*/
bool ChannelDetails_get_is_funding_locked(const struct LDKChannelDetails *NONNULL_PTR this_ptr);
* True if the channel is confirmed, funding_locked messages have been exchanged, and the
* channel is not currently being shut down. `funding_locked` message exchange implies the
* required confirmation count has been reached (and we were connected to the peer at some
- * point after the funding transaction received enough confirmations).
+ * point after the funding transaction received enough confirmations). The required
+ * confirmation count is provided in [`confirmations_required`].
+ *
+ * [`confirmations_required`]: ChannelDetails::confirmations_required
*/
void ChannelDetails_set_is_funding_locked(struct LDKChannelDetails *NONNULL_PTR this_ptr, bool val);
/**
* True if the channel is (a) confirmed and funding_locked messages have been exchanged, (b)
- * the peer is connected, (c) no monitor update failure is pending resolution, and (d) the
- * channel is not currently negotiating a shutdown.
+ * the peer is connected, and (c) the channel is not currently negotiating a shutdown.
*
* This is a strict superset of `is_funding_locked`.
*/
/**
* True if the channel is (a) confirmed and funding_locked messages have been exchanged, (b)
- * the peer is connected, (c) no monitor update failure is pending resolution, and (d) the
- * channel is not currently negotiating a shutdown.
+ * the peer is connected, and (c) the channel is not currently negotiating a shutdown.
*
* This is a strict superset of `is_funding_locked`.
*/
*/
void ChannelDetails_set_is_public(struct LDKChannelDetails *NONNULL_PTR this_ptr, bool val);
+/**
+ * Constructs a new ChannelDetails given each field
+ */
+MUST_USE_RES struct LDKChannelDetails ChannelDetails_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKChannelCounterparty counterparty_arg, struct LDKOutPoint funding_txo_arg, struct LDKCOption_u64Z short_channel_id_arg, uint64_t channel_value_satoshis_arg, struct LDKCOption_u64Z unspendable_punishment_reserve_arg, uint64_t user_id_arg, uint64_t outbound_capacity_msat_arg, uint64_t inbound_capacity_msat_arg, struct LDKCOption_u32Z confirmations_required_arg, struct LDKCOption_u16Z force_close_spend_delay_arg, bool is_outbound_arg, bool is_funding_locked_arg, bool is_usable_arg, bool is_public_arg);
+
/**
* Creates a copy of the ChannelDetails
*/
*/
struct LDKPaymentSendFailure PaymentSendFailure_clone(const struct LDKPaymentSendFailure *NONNULL_PTR orig);
+/**
+ * Utility method to constructs a new ParameterError-variant PaymentSendFailure
+ */
+struct LDKPaymentSendFailure PaymentSendFailure_parameter_error(struct LDKAPIError a);
+
+/**
+ * Utility method to constructs a new PathParameterError-variant PaymentSendFailure
+ */
+struct LDKPaymentSendFailure PaymentSendFailure_path_parameter_error(struct LDKCVec_CResult_NoneAPIErrorZZ a);
+
+/**
+ * Utility method to constructs a new AllFailedRetrySafe-variant PaymentSendFailure
+ */
+struct LDKPaymentSendFailure PaymentSendFailure_all_failed_retry_safe(struct LDKCVec_APIErrorZ a);
+
+/**
+ * Utility method to constructs a new PartialFailure-variant PaymentSendFailure
+ */
+struct LDKPaymentSendFailure PaymentSendFailure_partial_failure(struct LDKCVec_CResult_NoneAPIErrorZZ a);
+
/**
* Constructs a new ChannelManager to hold several channels and route between them.
*
*
* Raises APIError::APIMisuseError when channel_value_satoshis > 2**24 or push_msat is
* greater than channel_value_satoshis * 1k or channel_value_satoshis is < 1000.
+ *
+ * Note that we do not check if you are currently connected to the given peer. If no
+ * connection is available, the outbound `open_channel` message may fail to send, resulting in
+ * the channel eventually being silently forgotten.
+ *
+ * Note that override_config (or a relevant inner pointer) may be NULL or all-0s to represent None
*/
MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_create_channel(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKPublicKey their_network_key, uint64_t channel_value_satoshis, uint64_t push_msat, uint64_t user_id, struct LDKUserConfig override_config);
* will be accepted on the given channel, and after additional timeout/the closing of all
* pending HTLCs, the channel will be closed on chain.
*
+ * * If we are the channel initiator, we will pay between our [`Background`] and
+ * [`ChannelConfig::force_close_avoidance_max_fee_satoshis`] plus our [`Normal`] fee
+ * estimate.
+ * * If our counterparty is the channel initiator, we will require a channel closing
+ * transaction feerate of at least our [`Background`] feerate or the feerate which
+ * would appear on a force-closure transaction, whichever is lower. We will allow our
+ * counterparty to pay as much fee as they'd like, however.
+ *
* May generate a SendShutdown message event on success, which should be relayed.
+ *
+ * [`ChannelConfig::force_close_avoidance_max_fee_satoshis`]: crate::util::config::ChannelConfig::force_close_avoidance_max_fee_satoshis
+ * [`Background`]: crate::chain::chaininterface::ConfirmationTarget::Background
+ * [`Normal`]: crate::chain::chaininterface::ConfirmationTarget::Normal
*/
MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_close_channel(const struct LDKChannelManager *NONNULL_PTR this_arg, const uint8_t (*channel_id)[32]);
+/**
+ * Begins the process of closing a channel. After this call (plus some timeout), no new HTLCs
+ * will be accepted on the given channel, and after additional timeout/the closing of all
+ * pending HTLCs, the channel will be closed on chain.
+ *
+ * `target_feerate_sat_per_1000_weight` has different meanings depending on if we initiated
+ * the channel being closed or not:
+ * * If we are the channel initiator, we will pay at least this feerate on the closing
+ * transaction. The upper-bound is set by
+ * [`ChannelConfig::force_close_avoidance_max_fee_satoshis`] plus our [`Normal`] fee
+ * estimate (or `target_feerate_sat_per_1000_weight`, if it is greater).
+ * * If our counterparty is the channel initiator, we will refuse to accept a channel closure
+ * transaction feerate below `target_feerate_sat_per_1000_weight` (or the feerate which
+ * will appear on a force-closure transaction, whichever is lower).
+ *
+ * May generate a SendShutdown message event on success, which should be relayed.
+ *
+ * [`ChannelConfig::force_close_avoidance_max_fee_satoshis`]: crate::util::config::ChannelConfig::force_close_avoidance_max_fee_satoshis
+ * [`Background`]: crate::chain::chaininterface::ConfirmationTarget::Background
+ * [`Normal`]: crate::chain::chaininterface::ConfirmationTarget::Normal
+ */
+MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_close_channel_with_target_feerate(const struct LDKChannelManager *NONNULL_PTR this_arg, const uint8_t (*channel_id)[32], uint32_t target_feerate_sats_per_1000_weight);
+
/**
* Force closes a channel, immediately broadcasting the latest local commitment transaction to
* the chain and rejecting new HTLCs on the given channel. Fails if channel_id is unknown to the manager.
* If a payment_secret *is* provided, we assume that the invoice had the payment_secret feature
* bit set (either as required or as available). If multiple paths are present in the Route,
* we assume the invoice had the basic_mpp feature set.
+ *
+ * Note that payment_secret (or a relevant inner pointer) may be NULL or all-0s to represent None
*/
MUST_USE_RES struct LDKCResult_NonePaymentSendFailureZ ChannelManager_send_payment(const struct LDKChannelManager *NONNULL_PTR this_arg, const struct LDKRoute *NONNULL_PTR route, struct LDKThirtyTwoBytes payment_hash, struct LDKThirtyTwoBytes payment_secret);
+/**
+ * Send a spontaneous payment, which is a payment that does not require the recipient to have
+ * generated an invoice. Optionally, you may specify the preimage. If you do choose to specify
+ * the preimage, it must be a cryptographically secure random value that no intermediate node
+ * would be able to guess -- otherwise, an intermediate node may claim the payment and it will
+ * never reach the recipient.
+ *
+ * See [`send_payment`] documentation for more details on the return value of this function.
+ *
+ * Similar to regular payments, you MUST NOT reuse a `payment_preimage` value. See
+ * [`send_payment`] for more information about the risks of duplicate preimage usage.
+ *
+ * Note that `route` must have exactly one path.
+ *
+ * [`send_payment`]: Self::send_payment
+ *
+ * Note that payment_preimage (or a relevant inner pointer) may be NULL or all-0s to represent None
+ */
+MUST_USE_RES struct LDKCResult_PaymentHashPaymentSendFailureZ ChannelManager_send_spontaneous_payment(const struct LDKChannelManager *NONNULL_PTR this_arg, const struct LDKRoute *NONNULL_PTR route, struct LDKThirtyTwoBytes payment_preimage);
+
/**
* Call this upon creation of a funding transaction for the given channel.
*
void ChannelManager_process_pending_htlc_forwards(const struct LDKChannelManager *NONNULL_PTR this_arg);
/**
- * If a peer is disconnected we mark any channels with that peer as 'disabled'.
- * After some time, if channels are still disabled we need to broadcast a ChannelUpdate
- * to inform the network about the uselessness of these channels.
+ * Performs actions which should happen on startup and roughly once per minute thereafter.
*
- * This method handles all the details, and must be called roughly once per minute.
+ * This currently includes:
+ * * Increasing or decreasing the on-chain feerate estimates for our outbound channels,
+ * * Broadcasting `ChannelUpdate` messages if we've been disconnected from our peer for more
+ * than a minute, informing the network that they should no longer attempt to route over
+ * the channel.
*
- * Note that in some rare cases this may generate a `chain::Watch::update_channel` call.
+ * Note that this may cause reentrancy through `chain::Watch::update_channel` calls or feerate
+ * estimate fetches.
*/
void ChannelManager_timer_tick_occurred(const struct LDKChannelManager *NONNULL_PTR this_arg);
* The [`PaymentHash`] (and corresponding [`PaymentPreimage`]) must be globally unique. This
* method may return an Err if another payment with the same payment_hash is still pending.
*
- * `user_payment_id` will be provided back in [`PaymentReceived::user_payment_id`] events to
+ * `user_payment_id` will be provided back in [`PaymentPurpose::InvoicePayment::user_payment_id`] events to
* allow tracking of which events correspond with which calls to this and
* [`create_inbound_payment`]. `user_payment_id` has no meaning inside of LDK, it is simply
* copied to events and otherwise ignored. It may be used to correlate PaymentReceived events
*
* [`create_inbound_payment`]: Self::create_inbound_payment
* [`PaymentReceived`]: events::Event::PaymentReceived
- * [`PaymentReceived::user_payment_id`]: events::Event::PaymentReceived::user_payment_id
+ * [`PaymentPurpose::InvoicePayment::user_payment_id`]: events::PaymentPurpose::InvoicePayment::user_payment_id
*/
MUST_USE_RES struct LDKCResult_PaymentSecretAPIErrorZ ChannelManager_create_inbound_payment_for_hash(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes payment_hash, struct LDKCOption_u64Z min_value_msat, uint32_t invoice_expiry_delta_secs, uint64_t user_payment_id);
*/
void ChannelManager_await_persistable_update(const struct LDKChannelManager *NONNULL_PTR this_arg);
+/**
+ * Gets the latest best block which was connected either via the [`chain::Listen`] or
+ * [`chain::Confirm`] interfaces.
+ */
+MUST_USE_RES struct LDKBestBlock ChannelManager_current_best_block(const struct LDKChannelManager *NONNULL_PTR this_arg);
+
/**
* Constructs a new ChannelMessageHandler which calls the relevant methods on this_arg.
* This copies the `inner` pointer in this_arg and thus the returned ChannelMessageHandler must be freed before this_arg is
*/
struct LDKShutdown Shutdown_clone(const struct LDKShutdown *NONNULL_PTR orig);
+/**
+ * Frees any resources used by the ClosingSignedFeeRange, if is_owned is set and inner is non-NULL.
+ */
+void ClosingSignedFeeRange_free(struct LDKClosingSignedFeeRange this_obj);
+
+/**
+ * The minimum absolute fee, in satoshis, which the sender is willing to place on the closing
+ * transaction.
+ */
+uint64_t ClosingSignedFeeRange_get_min_fee_satoshis(const struct LDKClosingSignedFeeRange *NONNULL_PTR this_ptr);
+
+/**
+ * The minimum absolute fee, in satoshis, which the sender is willing to place on the closing
+ * transaction.
+ */
+void ClosingSignedFeeRange_set_min_fee_satoshis(struct LDKClosingSignedFeeRange *NONNULL_PTR this_ptr, uint64_t val);
+
+/**
+ * The maximum absolute fee, in satoshis, which the sender is willing to place on the closing
+ * transaction.
+ */
+uint64_t ClosingSignedFeeRange_get_max_fee_satoshis(const struct LDKClosingSignedFeeRange *NONNULL_PTR this_ptr);
+
+/**
+ * The maximum absolute fee, in satoshis, which the sender is willing to place on the closing
+ * transaction.
+ */
+void ClosingSignedFeeRange_set_max_fee_satoshis(struct LDKClosingSignedFeeRange *NONNULL_PTR this_ptr, uint64_t val);
+
+/**
+ * Constructs a new ClosingSignedFeeRange given each field
+ */
+MUST_USE_RES struct LDKClosingSignedFeeRange ClosingSignedFeeRange_new(uint64_t min_fee_satoshis_arg, uint64_t max_fee_satoshis_arg);
+
+/**
+ * Creates a copy of the ClosingSignedFeeRange
+ */
+struct LDKClosingSignedFeeRange ClosingSignedFeeRange_clone(const struct LDKClosingSignedFeeRange *NONNULL_PTR orig);
+
/**
* Frees any resources used by the ClosingSigned, if is_owned is set and inner is non-NULL.
*/
*/
void ClosingSigned_set_signature(struct LDKClosingSigned *NONNULL_PTR this_ptr, struct LDKSignature val);
+/**
+ * The minimum and maximum fees which the sender is willing to accept, provided only by new
+ * nodes.
+ *
+ * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
+ */
+struct LDKClosingSignedFeeRange ClosingSigned_get_fee_range(const struct LDKClosingSigned *NONNULL_PTR this_ptr);
+
+/**
+ * The minimum and maximum fees which the sender is willing to accept, provided only by new
+ * nodes.
+ *
+ * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
+ */
+void ClosingSigned_set_fee_range(struct LDKClosingSigned *NONNULL_PTR this_ptr, struct LDKClosingSignedFeeRange val);
+
/**
* Constructs a new ClosingSigned given each field
*/
-MUST_USE_RES struct LDKClosingSigned ClosingSigned_new(struct LDKThirtyTwoBytes channel_id_arg, uint64_t fee_satoshis_arg, struct LDKSignature signature_arg);
+MUST_USE_RES struct LDKClosingSigned ClosingSigned_new(struct LDKThirtyTwoBytes channel_id_arg, uint64_t fee_satoshis_arg, struct LDKSignature signature_arg, struct LDKClosingSignedFeeRange fee_range_arg);
/**
* Creates a copy of the ClosingSigned
void AnnouncementSignatures_set_bitcoin_signature(struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr, struct LDKSignature val);
/**
- * Constructs a new AnnouncementSignatures given each field
+ * Constructs a new AnnouncementSignatures given each field
+ */
+MUST_USE_RES struct LDKAnnouncementSignatures AnnouncementSignatures_new(struct LDKThirtyTwoBytes channel_id_arg, uint64_t short_channel_id_arg, struct LDKSignature node_signature_arg, struct LDKSignature bitcoin_signature_arg);
+
+/**
+ * Creates a copy of the AnnouncementSignatures
+ */
+struct LDKAnnouncementSignatures AnnouncementSignatures_clone(const struct LDKAnnouncementSignatures *NONNULL_PTR orig);
+
+/**
+ * Frees any resources used by the NetAddress
+ */
+void NetAddress_free(struct LDKNetAddress this_ptr);
+
+/**
+ * Creates a copy of the NetAddress
+ */
+struct LDKNetAddress NetAddress_clone(const struct LDKNetAddress *NONNULL_PTR orig);
+
+/**
+ * Utility method to constructs a new IPv4-variant NetAddress
*/
-MUST_USE_RES struct LDKAnnouncementSignatures AnnouncementSignatures_new(struct LDKThirtyTwoBytes channel_id_arg, uint64_t short_channel_id_arg, struct LDKSignature node_signature_arg, struct LDKSignature bitcoin_signature_arg);
+struct LDKNetAddress NetAddress_ipv4(struct LDKFourBytes addr, uint16_t port);
/**
- * Creates a copy of the AnnouncementSignatures
+ * Utility method to constructs a new IPv6-variant NetAddress
*/
-struct LDKAnnouncementSignatures AnnouncementSignatures_clone(const struct LDKAnnouncementSignatures *NONNULL_PTR orig);
+struct LDKNetAddress NetAddress_ipv6(struct LDKSixteenBytes addr, uint16_t port);
/**
- * Frees any resources used by the NetAddress
+ * Utility method to constructs a new OnionV2-variant NetAddress
*/
-void NetAddress_free(struct LDKNetAddress this_ptr);
+struct LDKNetAddress NetAddress_onion_v2(struct LDKTenBytes addr, uint16_t port);
/**
- * Creates a copy of the NetAddress
+ * Utility method to constructs a new OnionV3-variant NetAddress
*/
-struct LDKNetAddress NetAddress_clone(const struct LDKNetAddress *NONNULL_PTR orig);
+struct LDKNetAddress NetAddress_onion_v3(struct LDKThirtyTwoBytes ed25519_pubkey, uint16_t checksum, uint8_t version, uint16_t port);
/**
* Serialize the NetAddress object into a byte array which can be read by NetAddress_read
*/
struct LDKErrorAction ErrorAction_clone(const struct LDKErrorAction *NONNULL_PTR orig);
+/**
+ * Utility method to constructs a new DisconnectPeer-variant ErrorAction
+ */
+struct LDKErrorAction ErrorAction_disconnect_peer(struct LDKErrorMessage msg);
+
+/**
+ * Utility method to constructs a new IgnoreError-variant ErrorAction
+ */
+struct LDKErrorAction ErrorAction_ignore_error(void);
+
+/**
+ * Utility method to constructs a new IgnoreAndLog-variant ErrorAction
+ */
+struct LDKErrorAction ErrorAction_ignore_and_log(enum LDKLevel a);
+
+/**
+ * Utility method to constructs a new SendErrorMessage-variant ErrorAction
+ */
+struct LDKErrorAction ErrorAction_send_error_message(struct LDKErrorMessage msg);
+
/**
* Frees any resources used by the LightningError, if is_owned is set and inner is non-NULL.
*/
/**
* An update_fee message which should be sent
+ *
+ * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
*/
struct LDKUpdateFee CommitmentUpdate_get_update_fee(const struct LDKCommitmentUpdate *NONNULL_PTR this_ptr);
/**
* An update_fee message which should be sent
+ *
+ * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
*/
void CommitmentUpdate_set_update_fee(struct LDKCommitmentUpdate *NONNULL_PTR this_ptr, struct LDKUpdateFee val);
*/
struct LDKHTLCFailChannelUpdate HTLCFailChannelUpdate_clone(const struct LDKHTLCFailChannelUpdate *NONNULL_PTR orig);
+/**
+ * Utility method to constructs a new ChannelUpdateMessage-variant HTLCFailChannelUpdate
+ */
+struct LDKHTLCFailChannelUpdate HTLCFailChannelUpdate_channel_update_message(struct LDKChannelUpdate msg);
+
+/**
+ * Utility method to constructs a new ChannelClosed-variant HTLCFailChannelUpdate
+ */
+struct LDKHTLCFailChannelUpdate HTLCFailChannelUpdate_channel_closed(uint64_t short_channel_id, bool is_permanent);
+
+/**
+ * Utility method to constructs a new NodeFailure-variant HTLCFailChannelUpdate
+ */
+struct LDKHTLCFailChannelUpdate HTLCFailChannelUpdate_node_failure(struct LDKPublicKey node_id, bool is_permanent);
+
/**
* Calls the free function if one is set
*/
*/
struct LDKCResult_ClosingSignedDecodeErrorZ ClosingSigned_read(struct LDKu8slice ser);
+/**
+ * Serialize the ClosingSignedFeeRange object into a byte array which can be read by ClosingSignedFeeRange_read
+ */
+struct LDKCVec_u8Z ClosingSignedFeeRange_write(const struct LDKClosingSignedFeeRange *NONNULL_PTR obj);
+
+/**
+ * Read a ClosingSignedFeeRange from a byte array, created by ClosingSignedFeeRange_write
+ */
+struct LDKCResult_ClosingSignedFeeRangeDecodeErrorZ ClosingSignedFeeRange_read(struct LDKu8slice ser);
+
/**
* Serialize the CommitmentSigned object into a byte array which can be read by CommitmentSigned_read
*/
/**
* A message handler which handles messages specific to channels. Usually this is just a
- * ChannelManager object or a ErroringMessageHandler.
+ * [`ChannelManager`] object or an [`ErroringMessageHandler`].
+ *
+ * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
*/
const struct LDKChannelMessageHandler *MessageHandler_get_chan_handler(const struct LDKMessageHandler *NONNULL_PTR this_ptr);
/**
* A message handler which handles messages specific to channels. Usually this is just a
- * ChannelManager object or a ErroringMessageHandler.
+ * [`ChannelManager`] object or an [`ErroringMessageHandler`].
+ *
+ * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
*/
void MessageHandler_set_chan_handler(struct LDKMessageHandler *NONNULL_PTR this_ptr, struct LDKChannelMessageHandler val);
/**
* A message handler which handles messages updating our knowledge of the network channel
- * graph. Usually this is just a NetGraphMsgHandlerMonitor object or an IgnoringMessageHandler.
+ * graph. Usually this is just a [`NetGraphMsgHandler`] object or an
+ * [`IgnoringMessageHandler`].
+ *
+ * [`NetGraphMsgHandler`]: crate::routing::network_graph::NetGraphMsgHandler
*/
const struct LDKRoutingMessageHandler *MessageHandler_get_route_handler(const struct LDKMessageHandler *NONNULL_PTR this_ptr);
/**
* A message handler which handles messages updating our knowledge of the network channel
- * graph. Usually this is just a NetGraphMsgHandlerMonitor object or an IgnoringMessageHandler.
+ * graph. Usually this is just a [`NetGraphMsgHandler`] object or an
+ * [`IgnoringMessageHandler`].
+ *
+ * [`NetGraphMsgHandler`]: crate::routing::network_graph::NetGraphMsgHandler
*/
void MessageHandler_set_route_handler(struct LDKMessageHandler *NONNULL_PTR this_ptr, struct LDKRoutingMessageHandler val);
*
* Returns a small number of bytes to send to the remote node (currently always 50).
*
- * Panics if descriptor is duplicative with some other descriptor which has not yet had a
- * socket_disconnected().
+ * Panics if descriptor is duplicative with some other descriptor which has not yet been
+ * [`socket_disconnected()`].
+ *
+ * [`socket_disconnected()`]: PeerManager::socket_disconnected
*/
MUST_USE_RES struct LDKCResult_CVec_u8ZPeerHandleErrorZ PeerManager_new_outbound_connection(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKPublicKey their_node_id, struct LDKSocketDescriptor descriptor);
* call socket_disconnected for the new descriptor but must disconnect the connection
* immediately.
*
- * Panics if descriptor is duplicative with some other descriptor which has not yet had
- * socket_disconnected called.
+ * Panics if descriptor is duplicative with some other descriptor which has not yet been
+ * [`socket_disconnected()`].
+ *
+ * [`socket_disconnected()`]: PeerManager::socket_disconnected
*/
MUST_USE_RES struct LDKCResult_NonePeerHandleErrorZ PeerManager_new_inbound_connection(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKSocketDescriptor descriptor);
*
* May return an Err to indicate that the connection should be closed.
*
- * Will most likely call send_data on the descriptor passed in (or the descriptor handed into
- * new_*\\_connection) before returning. Thus, be very careful with reentrancy issues! The
- * invariants around calling write_buffer_space_avail in case a write did not fully complete
- * must still hold - be ready to call write_buffer_space_avail again if a write call generated
- * here isn't sufficient! Panics if the descriptor was not previously registered in a
- * new_\\*_connection event.
+ * May call [`send_data`] on the descriptor passed in (or an equal descriptor) before
+ * returning. Thus, be very careful with reentrancy issues! The invariants around calling
+ * [`write_buffer_space_avail`] in case a write did not fully complete must still hold - be
+ * ready to call `[write_buffer_space_avail`] again if a write call generated here isn't
+ * sufficient!
+ *
+ * [`send_data`]: SocketDescriptor::send_data
+ * [`write_buffer_space_avail`]: PeerManager::write_buffer_space_avail
*/
MUST_USE_RES struct LDKCResult_NonePeerHandleErrorZ PeerManager_write_buffer_space_avail(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKSocketDescriptor *NONNULL_PTR descriptor);
*
* May return an Err to indicate that the connection should be closed.
*
- * Will *not* call back into send_data on any descriptors to avoid reentrancy complexity.
- * Thus, however, you almost certainly want to call process_events() after any read_event to
- * generate send_data calls to handle responses.
+ * Will *not* call back into [`send_data`] on any descriptors to avoid reentrancy complexity.
+ * Thus, however, you should call [`process_events`] after any `read_event` to generate
+ * [`send_data`] calls to handle responses.
*
- * If Ok(true) is returned, further read_events should not be triggered until a send_data call
- * on this file descriptor has resume_read set (preventing DoS issues in the send buffer).
+ * If `Ok(true)` is returned, further read_events should not be triggered until a
+ * [`send_data`] call on this descriptor has `resume_read` set (preventing DoS issues in the
+ * send buffer).
*
- * Panics if the descriptor was not previously registered in a new_*_connection event.
+ * [`send_data`]: SocketDescriptor::send_data
+ * [`process_events`]: PeerManager::process_events
*/
MUST_USE_RES struct LDKCResult_boolPeerHandleErrorZ PeerManager_read_event(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKSocketDescriptor *NONNULL_PTR peer_descriptor, struct LDKu8slice data);
/**
* Checks for any events generated by our handlers and processes them. Includes sending most
* response messages as well as messages generated by calls to handler functions directly (eg
- * functions like ChannelManager::process_pending_htlc_forward or send_payment).
+ * functions like [`ChannelManager::process_pending_htlc_forwards`] or [`send_payment`]).
+ *
+ * May call [`send_data`] on [`SocketDescriptor`]s. Thus, be very careful with reentrancy
+ * issues!
+ *
+ * [`send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
+ * [`ChannelManager::process_pending_htlc_forwards`]: crate::ln::channelmanager::ChannelManager::process_pending_htlc_forwards
+ * [`send_data`]: SocketDescriptor::send_data
*/
void PeerManager_process_events(const struct LDKPeerManager *NONNULL_PTR this_arg);
/**
* Indicates that the given socket descriptor's connection is now closed.
- *
- * This must only be called if the socket has been disconnected by the peer or your own
- * decision to disconnect it and must NOT be called in any case where other parts of this
- * library (eg PeerHandleError, explicit disconnect_socket calls) instruct you to disconnect
- * the peer.
- *
- * Panics if the descriptor was not previously registered in a successful new_*_connection event.
*/
void PeerManager_socket_disconnected(const struct LDKPeerManager *NONNULL_PTR this_arg, const struct LDKSocketDescriptor *NONNULL_PTR descriptor);
/**
* Disconnect a peer given its node id.
*
- * Set no_connection_possible to true to prevent any further connection with this peer,
+ * Set `no_connection_possible` to true to prevent any further connection with this peer,
* force-closing any channels we have with it.
*
- * If a peer is connected, this will call `disconnect_socket` on the descriptor for the peer,
- * so be careful about reentrancy issues.
+ * If a peer is connected, this will call [`disconnect_socket`] on the descriptor for the
+ * peer. Thus, be very careful about reentrancy issues.
+ *
+ * [`disconnect_socket`]: SocketDescriptor::disconnect_socket
*/
void PeerManager_disconnect_by_node_id(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKPublicKey node_id, bool no_connection_possible);
/**
- * This function should be called roughly once every 30 seconds.
- * It will send pings to each peer and disconnect those which did not respond to the last round of pings.
- * Will most likely call send_data on all of the registered descriptors, thus, be very careful with reentrancy issues!
+ * Send pings to each peer and disconnect those which did not respond to the last round of
+ * pings.
+ *
+ * This may be called on any timescale you want, however, roughly once every five to ten
+ * seconds is preferred. The call rate determines both how often we send a ping to our peers
+ * and how much time they have to respond before we disconnect them.
+ *
+ * May call [`send_data`] on all [`SocketDescriptor`]s. Thus, be very careful with reentrancy
+ * issues!
+ *
+ * [`send_data`]: SocketDescriptor::send_data
*/
void PeerManager_timer_tick_occurred(const struct LDKPeerManager *NONNULL_PTR this_arg);
/**
* The late-bound counterparty channel transaction parameters.
* These parameters are populated at the point in the protocol where the counterparty provides them.
+ *
+ * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
*/
struct LDKCounterpartyChannelTransactionParameters ChannelTransactionParameters_get_counterparty_parameters(const struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr);
/**
* The late-bound counterparty channel transaction parameters.
* These parameters are populated at the point in the protocol where the counterparty provides them.
+ *
+ * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
*/
void ChannelTransactionParameters_set_counterparty_parameters(struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr, struct LDKCounterpartyChannelTransactionParameters val);
/**
* The late-bound funding outpoint
+ *
+ * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
*/
struct LDKOutPoint ChannelTransactionParameters_get_funding_outpoint(const struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr);
/**
* The late-bound funding outpoint
+ *
+ * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
*/
void ChannelTransactionParameters_set_funding_outpoint(struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr, struct LDKOutPoint val);
*/
struct LDKCResult_InvoiceFeaturesDecodeErrorZ InvoiceFeatures_read(struct LDKu8slice ser);
+/**
+ * Frees any resources used by the ShutdownScript, if is_owned is set and inner is non-NULL.
+ */
+void ShutdownScript_free(struct LDKShutdownScript this_obj);
+
+/**
+ * Creates a copy of the ShutdownScript
+ */
+struct LDKShutdownScript ShutdownScript_clone(const struct LDKShutdownScript *NONNULL_PTR orig);
+
+/**
+ * Frees any resources used by the InvalidShutdownScript, if is_owned is set and inner is non-NULL.
+ */
+void InvalidShutdownScript_free(struct LDKInvalidShutdownScript this_obj);
+
+/**
+ * The script that did not meet the requirements from [BOLT #2].
+ *
+ * [BOLT #2]: https://github.com/lightningnetwork/lightning-rfc/blob/master/02-peer-protocol.md
+ */
+struct LDKu8slice InvalidShutdownScript_get_script(const struct LDKInvalidShutdownScript *NONNULL_PTR this_ptr);
+
+/**
+ * The script that did not meet the requirements from [BOLT #2].
+ *
+ * [BOLT #2]: https://github.com/lightningnetwork/lightning-rfc/blob/master/02-peer-protocol.md
+ */
+void InvalidShutdownScript_set_script(struct LDKInvalidShutdownScript *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val);
+
+/**
+ * Constructs a new InvalidShutdownScript given each field
+ */
+MUST_USE_RES struct LDKInvalidShutdownScript InvalidShutdownScript_new(struct LDKCVec_u8Z script_arg);
+
+/**
+ * Serialize the ShutdownScript object into a byte array which can be read by ShutdownScript_read
+ */
+struct LDKCVec_u8Z ShutdownScript_write(const struct LDKShutdownScript *NONNULL_PTR obj);
+
+/**
+ * Read a ShutdownScript from a byte array, created by ShutdownScript_write
+ */
+struct LDKCResult_ShutdownScriptDecodeErrorZ ShutdownScript_read(struct LDKu8slice ser);
+
+/**
+ * Generates a P2PKH script pubkey from the given [`PubkeyHash`].
+ */
+MUST_USE_RES struct LDKShutdownScript ShutdownScript_new_p2pkh(const uint8_t (*pubkey_hash)[20]);
+
+/**
+ * Generates a P2SH script pubkey from the given [`ScriptHash`].
+ */
+MUST_USE_RES struct LDKShutdownScript ShutdownScript_new_p2sh(const uint8_t (*script_hash)[20]);
+
+/**
+ * Generates a P2WPKH script pubkey from the given [`WPubkeyHash`].
+ */
+MUST_USE_RES struct LDKShutdownScript ShutdownScript_new_p2wpkh(const uint8_t (*pubkey_hash)[20]);
+
+/**
+ * Generates a P2WSH script pubkey from the given [`WScriptHash`].
+ */
+MUST_USE_RES struct LDKShutdownScript ShutdownScript_new_p2wsh(const uint8_t (*script_hash)[32]);
+
+/**
+ * Generates a witness script pubkey from the given segwit version and program.
+ *
+ * Note for version-zero witness scripts you must use [`ShutdownScript::new_p2wpkh`] or
+ * [`ShutdownScript::new_p2wsh`] instead.
+ *
+ * # Errors
+ *
+ * This function may return an error if `program` is invalid for the segwit `version`.
+ */
+MUST_USE_RES struct LDKCResult_ShutdownScriptInvalidShutdownScriptZ ShutdownScript_new_witness_program(uint8_t version, struct LDKu8slice program);
+
+/**
+ * Converts the shutdown script into the underlying [`Script`].
+ */
+MUST_USE_RES struct LDKCVec_u8Z ShutdownScript_into_inner(struct LDKShutdownScript this_arg);
+
+/**
+ * Returns the [`PublicKey`] used for a P2WPKH shutdown script if constructed directly from it.
+ *
+ * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
+ */
+MUST_USE_RES struct LDKPublicKey ShutdownScript_as_legacy_pubkey(const struct LDKShutdownScript *NONNULL_PTR this_arg);
+
+/**
+ * Returns whether the shutdown script is compatible with the features as defined by BOLT #2.
+ *
+ * Specifically, checks for compliance with feature `option_shutdown_anysegwit`.
+ */
+MUST_USE_RES bool ShutdownScript_is_compatible(const struct LDKShutdownScript *NONNULL_PTR this_arg, const struct LDKInitFeatures *NONNULL_PTR features);
+
/**
* Frees any resources used by the RouteHop, if is_owned is set and inner is non-NULL.
*/
*/
struct LDKRouteHintHop RouteHintHop_clone(const struct LDKRouteHintHop *NONNULL_PTR orig);
+/**
+ * Gets a keysend route from us (payer) to the given target node (payee). This is needed because
+ * keysend payments do not have an invoice from which to pull the payee's supported features, which
+ * makes it tricky to otherwise supply the `payee_features` parameter of `get_route`.
+ *
+ * Note that first_hops (or a relevant inner pointer) may be NULL or all-0s to represent None
+ */
+struct LDKCResult_RouteLightningErrorZ get_keysend_route(struct LDKPublicKey our_node_id, const struct LDKNetworkGraph *NONNULL_PTR network, struct LDKPublicKey payee, struct LDKCVec_ChannelDetailsZ *first_hops, struct LDKCVec_RouteHintZ last_hops, uint64_t final_value_msat, uint32_t final_cltv, struct LDKLogger logger);
+
/**
* Gets a route from us (payer) to the given target node (payee).
*
* The fees on channels from us to next-hops are ignored (as they are assumed to all be
* equal), however the enabled/disabled bit on such channels as well as the
* htlc_minimum_msat/htlc_maximum_msat *are* checked as they may change based on the receiving node.
+ *
+ * Note that payee_features (or a relevant inner pointer) may be NULL or all-0s to represent None
+ * Note that first_hops (or a relevant inner pointer) may be NULL or all-0s to represent None
*/
struct LDKCResult_RouteLightningErrorZ get_route(struct LDKPublicKey our_node_id, const struct LDKNetworkGraph *NONNULL_PTR network, struct LDKPublicKey payee, struct LDKInvoiceFeatures payee_features, struct LDKCVec_ChannelDetailsZ *first_hops, struct LDKCVec_RouteHintZ last_hops, uint64_t final_value_msat, uint32_t final_cltv, struct LDKLogger logger);
* Chain monitor is used to make sure announced channels exist on-chain,
* channel data is correct, and that the announcement is signed with
* channel owners' keys.
+ *
+ * Note that chain_access (or a relevant inner pointer) may be NULL or all-0s to represent None
*/
MUST_USE_RES struct LDKNetGraphMsgHandler NetGraphMsgHandler_new(struct LDKThirtyTwoBytes genesis_hash, struct LDKAccess *chain_access, struct LDKLogger logger);
/**
* Creates a new tracker of the actual state of the network of channels and nodes,
* assuming an existing Network Graph.
+ *
+ * Note that chain_access (or a relevant inner pointer) may be NULL or all-0s to represent None
*/
MUST_USE_RES struct LDKNetGraphMsgHandler NetGraphMsgHandler_from_net_graph(struct LDKAccess *chain_access, struct LDKLogger logger, struct LDKNetworkGraph network_graph);
* Adds a provider used to check new announcements. Does not affect
* existing announcements unless they are updated.
* Add, update or remove the provider would replace the current one.
+ *
+ * Note that chain_access (or a relevant inner pointer) may be NULL or all-0s to represent None
*/
void NetGraphMsgHandler_add_chain_access(struct LDKNetGraphMsgHandler *NONNULL_PTR this_arg, struct LDKAccess *chain_access);
* Mostly redundant with the data we store in fields explicitly.
* Everything else is useful only for sending out for initial routing sync.
* Not stored if contains excess data to prevent DoS.
+ *
+ * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
*/
struct LDKChannelUpdate DirectionalChannelInfo_get_last_update_message(const struct LDKDirectionalChannelInfo *NONNULL_PTR this_ptr);
* Mostly redundant with the data we store in fields explicitly.
* Everything else is useful only for sending out for initial routing sync.
* Not stored if contains excess data to prevent DoS.
+ *
+ * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
*/
void DirectionalChannelInfo_set_last_update_message(struct LDKDirectionalChannelInfo *NONNULL_PTR this_ptr, struct LDKChannelUpdate val);
/**
* Details about the first direction of a channel
+ *
+ * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
*/
struct LDKDirectionalChannelInfo ChannelInfo_get_one_to_two(const struct LDKChannelInfo *NONNULL_PTR this_ptr);
/**
* Details about the first direction of a channel
+ *
+ * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
*/
void ChannelInfo_set_one_to_two(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKDirectionalChannelInfo val);
/**
* Details about the second direction of a channel
+ *
+ * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
*/
struct LDKDirectionalChannelInfo ChannelInfo_get_two_to_one(const struct LDKChannelInfo *NONNULL_PTR this_ptr);
/**
* Details about the second direction of a channel
+ *
+ * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
*/
void ChannelInfo_set_two_to_one(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKDirectionalChannelInfo val);
* Mostly redundant with the data we store in fields explicitly.
* Everything else is useful only for sending out for initial routing sync.
* Not stored if contains excess data to prevent DoS.
+ *
+ * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
*/
struct LDKChannelAnnouncement ChannelInfo_get_announcement_message(const struct LDKChannelInfo *NONNULL_PTR this_ptr);
* Mostly redundant with the data we store in fields explicitly.
* Everything else is useful only for sending out for initial routing sync.
* Not stored if contains excess data to prevent DoS.
+ *
+ * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
*/
void ChannelInfo_set_announcement_message(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKChannelAnnouncement val);
* Mostly redundant with the data we store in fields explicitly.
* Everything else is useful only for sending out for initial routing sync.
* Not stored if contains excess data to prevent DoS.
+ *
+ * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
*/
struct LDKNodeAnnouncement NodeAnnouncementInfo_get_announcement_message(const struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr);
* Mostly redundant with the data we store in fields explicitly.
* Everything else is useful only for sending out for initial routing sync.
* Not stored if contains excess data to prevent DoS.
+ *
+ * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
*/
void NodeAnnouncementInfo_set_announcement_message(struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr, struct LDKNodeAnnouncement val);
* Lowest fees enabling routing via any of the enabled, known channels to a node.
* The two fields (flat and proportional fee) are independent,
* meaning they don't have to refer to the same channel.
+ *
+ * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
*/
struct LDKRoutingFees NodeInfo_get_lowest_inbound_channel_fees(const struct LDKNodeInfo *NONNULL_PTR this_ptr);
* Lowest fees enabling routing via any of the enabled, known channels to a node.
* The two fields (flat and proportional fee) are independent,
* meaning they don't have to refer to the same channel.
+ *
+ * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
*/
void NodeInfo_set_lowest_inbound_channel_fees(struct LDKNodeInfo *NONNULL_PTR this_ptr, struct LDKRoutingFees val);
* More information about a node from node_announcement.
* Optional because we store a Node entry after learning about it from
* a channel announcement, but before receiving a node announcement.
+ *
+ * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
*/
struct LDKNodeAnnouncementInfo NodeInfo_get_announcement_info(const struct LDKNodeInfo *NONNULL_PTR this_ptr);
* More information about a node from node_announcement.
* Optional because we store a Node entry after learning about it from
* a channel announcement, but before receiving a node announcement.
+ *
+ * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
*/
void NodeInfo_set_announcement_info(struct LDKNodeInfo *NONNULL_PTR this_ptr, struct LDKNodeAnnouncementInfo val);
*
* If a `chain::Access` object is provided via `chain_access`, it will be called to verify
* the corresponding UTXO exists on chain and is correctly-formatted.
+ *
+ * Note that chain_access (or a relevant inner pointer) may be NULL or all-0s to represent None
*/
MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel_from_announcement(struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKChannelAnnouncement *NONNULL_PTR msg, struct LDKAccess *chain_access);
*
* If a `chain::Access` object is provided via `chain_access`, it will be called to verify
* the corresponding UTXO exists on chain and is correctly-formatted.
+ *
+ * Note that chain_access (or a relevant inner pointer) may be NULL or all-0s to represent None
*/
MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel_from_unsigned_announcement(struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR msg, struct LDKAccess *chain_access);
void ChannelManagerPersister_free(struct LDKChannelManagerPersister this_ptr);
/**
- * Start a background thread that takes care of responsibilities enumerated in the top-level
- * documentation.
+ * Start a background thread that takes care of responsibilities enumerated in the [top-level
+ * documentation].
+ *
+ * The thread runs indefinitely unless the object is dropped, [`stop`] is called, or
+ * `persist_manager` returns an error. In case of an error, the error is retrieved by calling
+ * either [`join`] or [`stop`].
*
- * If `persist_manager` returns an error, then this thread will return said error (and
- * `start()` will need to be called again to restart the `BackgroundProcessor`). Users should
- * wait on [`thread_handle`]'s `join()` method to be able to tell if and when an error is
- * returned, or implement `persist_manager` such that an error is never returned to the
- * `BackgroundProcessor`
+ * Typically, users should either implement [`ChannelManagerPersister`] to never return an
+ * error or call [`join`] and handle any error that may arise. For the latter case, the
+ * `BackgroundProcessor` must be restarted by calling `start` again after handling the error.
*
* `persist_manager` is responsible for writing out the [`ChannelManager`] to disk, and/or
* uploading to one or more backup services. See [`ChannelManager::write`] for writing out a
* [`ChannelManager`]. See [`FilesystemPersister::persist_manager`] for Rust-Lightning's
* provided implementation.
*
- * [`thread_handle`]: BackgroundProcessor::thread_handle
+ * [top-level documentation]: Self
+ * [`join`]: Self::join
+ * [`stop`]: Self::stop
* [`ChannelManager`]: lightning::ln::channelmanager::ChannelManager
* [`ChannelManager::write`]: lightning::ln::channelmanager::ChannelManager#impl-Writeable
* [`FilesystemPersister::persist_manager`]: lightning_persister::FilesystemPersister::persist_manager
MUST_USE_RES struct LDKBackgroundProcessor BackgroundProcessor_start(struct LDKChannelManagerPersister persister, struct LDKEventHandler event_handler, const struct LDKChainMonitor *NONNULL_PTR chain_monitor, const struct LDKChannelManager *NONNULL_PTR channel_manager, const struct LDKPeerManager *NONNULL_PTR peer_manager, struct LDKLogger logger);
/**
- * Stop `BackgroundProcessor`'s thread.
+ * Join `BackgroundProcessor`'s thread, returning any error that occurred while persisting
+ * [`ChannelManager`].
+ *
+ * # Panics
+ *
+ * This function panics if the background thread has panicked such as while persisting or
+ * handling events.
+ *
+ * [`ChannelManager`]: lightning::ln::channelmanager::ChannelManager
+ */
+MUST_USE_RES struct LDKCResult_NoneErrorZ BackgroundProcessor_join(struct LDKBackgroundProcessor this_arg);
+
+/**
+ * Stop `BackgroundProcessor`'s thread, returning any error that occurred while persisting
+ * [`ChannelManager`].
+ *
+ * # Panics
+ *
+ * This function panics if the background thread has panicked such as while persisting or
+ * handling events.
+ *
+ * [`ChannelManager`]: lightning::ln::channelmanager::ChannelManager
*/
MUST_USE_RES struct LDKCResult_NoneErrorZ BackgroundProcessor_stop(struct LDKBackgroundProcessor this_arg);
*/
enum LDKSiPrefix SiPrefix_clone(const enum LDKSiPrefix *NONNULL_PTR orig);
+/**
+ * Utility method to constructs a new Milli-variant SiPrefix
+ */
+enum LDKSiPrefix SiPrefix_milli(void);
+
+/**
+ * Utility method to constructs a new Micro-variant SiPrefix
+ */
+enum LDKSiPrefix SiPrefix_micro(void);
+
+/**
+ * Utility method to constructs a new Nano-variant SiPrefix
+ */
+enum LDKSiPrefix SiPrefix_nano(void);
+
+/**
+ * Utility method to constructs a new Pico-variant SiPrefix
+ */
+enum LDKSiPrefix SiPrefix_pico(void);
+
/**
* Checks if two SiPrefixs contain equal inner contents.
* This ignores pointers and is_owned flags and looks at the values in fields.
*/
enum LDKCurrency Currency_clone(const enum LDKCurrency *NONNULL_PTR orig);
+/**
+ * Utility method to constructs a new Bitcoin-variant Currency
+ */
+enum LDKCurrency Currency_bitcoin(void);
+
+/**
+ * Utility method to constructs a new BitcoinTestnet-variant Currency
+ */
+enum LDKCurrency Currency_bitcoin_testnet(void);
+
+/**
+ * Utility method to constructs a new Regtest-variant Currency
+ */
+enum LDKCurrency Currency_regtest(void);
+
+/**
+ * Utility method to constructs a new Simnet-variant Currency
+ */
+enum LDKCurrency Currency_simnet(void);
+
+/**
+ * Utility method to constructs a new Signet-variant Currency
+ */
+enum LDKCurrency Currency_signet(void);
+
/**
* Checks if two Currencys contain equal inner contents.
* This ignores pointers and is_owned flags and looks at the values in fields.
*/
struct LDKFallback Fallback_clone(const struct LDKFallback *NONNULL_PTR orig);
+/**
+ * Utility method to constructs a new SegWitProgram-variant Fallback
+ */
+struct LDKFallback Fallback_seg_wit_program(struct LDKu5 version, struct LDKCVec_u8Z program);
+
+/**
+ * Utility method to constructs a new PubKeyHash-variant Fallback
+ */
+struct LDKFallback Fallback_pub_key_hash(struct LDKTwentyBytes a);
+
+/**
+ * Utility method to constructs a new ScriptHash-variant Fallback
+ */
+struct LDKFallback Fallback_script_hash(struct LDKTwentyBytes a);
+
/**
* Checks if two Fallbacks contain equal inner contents.
* This ignores pointers and is_owned flags and looks at the values in fields.
*/
MUST_USE_RES struct LDKThirtyTwoBytes RawInvoice_hash(const struct LDKRawInvoice *NONNULL_PTR this_arg);
+/**
+ *
+ * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
+ */
MUST_USE_RES struct LDKSha256 RawInvoice_payment_hash(const struct LDKRawInvoice *NONNULL_PTR this_arg);
+/**
+ *
+ * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
+ */
MUST_USE_RES struct LDKDescription RawInvoice_description(const struct LDKRawInvoice *NONNULL_PTR this_arg);
+/**
+ *
+ * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
+ */
MUST_USE_RES struct LDKPayeePubKey RawInvoice_payee_pub_key(const struct LDKRawInvoice *NONNULL_PTR this_arg);
+/**
+ *
+ * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
+ */
MUST_USE_RES struct LDKSha256 RawInvoice_description_hash(const struct LDKRawInvoice *NONNULL_PTR this_arg);
+/**
+ *
+ * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
+ */
MUST_USE_RES struct LDKExpiryTime RawInvoice_expiry_time(const struct LDKRawInvoice *NONNULL_PTR this_arg);
+/**
+ *
+ * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
+ */
MUST_USE_RES struct LDKMinFinalCltvExpiry RawInvoice_min_final_cltv_expiry(const struct LDKRawInvoice *NONNULL_PTR this_arg);
+/**
+ *
+ * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
+ */
MUST_USE_RES struct LDKThirtyTwoBytes RawInvoice_payment_secret(const struct LDKRawInvoice *NONNULL_PTR this_arg);
+/**
+ *
+ * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
+ */
MUST_USE_RES struct LDKInvoiceFeatures RawInvoice_features(const struct LDKRawInvoice *NONNULL_PTR this_arg);
MUST_USE_RES struct LDKCVec_PrivateRouteZ RawInvoice_private_routes(const struct LDKRawInvoice *NONNULL_PTR this_arg);
/**
* Get the payee's public key if one was included in the invoice
+ *
+ * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
*/
MUST_USE_RES struct LDKPublicKey Invoice_payee_pub_key(const struct LDKInvoice *NONNULL_PTR this_arg);
/**
* Get the payment secret if one was included in the invoice
+ *
+ * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
*/
MUST_USE_RES struct LDKThirtyTwoBytes Invoice_payment_secret(const struct LDKInvoice *NONNULL_PTR this_arg);
/**
* Get the invoice features if they were included in the invoice
+ *
+ * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
*/
MUST_USE_RES struct LDKInvoiceFeatures Invoice_features(const struct LDKInvoice *NONNULL_PTR this_arg);
*/
enum LDKCreationError CreationError_clone(const enum LDKCreationError *NONNULL_PTR orig);
+/**
+ * Utility method to constructs a new DescriptionTooLong-variant CreationError
+ */
+enum LDKCreationError CreationError_description_too_long(void);
+
+/**
+ * Utility method to constructs a new RouteTooLong-variant CreationError
+ */
+enum LDKCreationError CreationError_route_too_long(void);
+
+/**
+ * Utility method to constructs a new TimestampOutOfBounds-variant CreationError
+ */
+enum LDKCreationError CreationError_timestamp_out_of_bounds(void);
+
+/**
+ * Utility method to constructs a new ExpiryTimeOutOfBounds-variant CreationError
+ */
+enum LDKCreationError CreationError_expiry_time_out_of_bounds(void);
+
/**
* Checks if two CreationErrors contain equal inner contents.
* This ignores pointers and is_owned flags and looks at the values in fields.
*/
enum LDKSemanticError SemanticError_clone(const enum LDKSemanticError *NONNULL_PTR orig);
+/**
+ * Utility method to constructs a new NoPaymentHash-variant SemanticError
+ */
+enum LDKSemanticError SemanticError_no_payment_hash(void);
+
+/**
+ * Utility method to constructs a new MultiplePaymentHashes-variant SemanticError
+ */
+enum LDKSemanticError SemanticError_multiple_payment_hashes(void);
+
+/**
+ * Utility method to constructs a new NoDescription-variant SemanticError
+ */
+enum LDKSemanticError SemanticError_no_description(void);
+
+/**
+ * Utility method to constructs a new MultipleDescriptions-variant SemanticError
+ */
+enum LDKSemanticError SemanticError_multiple_descriptions(void);
+
+/**
+ * Utility method to constructs a new MultiplePaymentSecrets-variant SemanticError
+ */
+enum LDKSemanticError SemanticError_multiple_payment_secrets(void);
+
+/**
+ * Utility method to constructs a new InvalidFeatures-variant SemanticError
+ */
+enum LDKSemanticError SemanticError_invalid_features(void);
+
+/**
+ * Utility method to constructs a new InvalidRecoveryId-variant SemanticError
+ */
+enum LDKSemanticError SemanticError_invalid_recovery_id(void);
+
+/**
+ * Utility method to constructs a new InvalidSignature-variant SemanticError
+ */
+enum LDKSemanticError SemanticError_invalid_signature(void);
+
/**
* Checks if two SemanticErrors contain equal inner contents.
* This ignores pointers and is_owned flags and looks at the values in fields.
*/
struct LDKSignOrCreationError SignOrCreationError_clone(const struct LDKSignOrCreationError *NONNULL_PTR orig);
+/**
+ * Utility method to constructs a new SignError-variant SignOrCreationError
+ */
+struct LDKSignOrCreationError SignOrCreationError_sign_error(void);
+
+/**
+ * Utility method to constructs a new CreationError-variant SignOrCreationError
+ */
+struct LDKSignOrCreationError SignOrCreationError_creation_error(enum LDKCreationError a);
+
/**
* Checks if two SignOrCreationErrors contain equal inner contents.
* This ignores pointers and is_owned flags and looks at the values in fields.
#endif /* LDK_C_BINDINGS_H */
-#include <ldk_ver.h>
+#include "ldk_ver.h"