#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 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;
* 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_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.
*/
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;
* 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);
/**
*/
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.
* 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 {
/**
*/
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_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_InvoiceSignOrCreationErrorZ CResult_InvoiceSignOrCreationErrorZ_clone(const struct LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR orig);
+/**
+ * Frees any resources used by the PaymentPurpose
+ */
+void PaymentPurpose_free(struct LDKPaymentPurpose this_ptr);
+
+/**
+ * Creates a copy of the PaymentPurpose
+ */
+struct LDKPaymentPurpose PaymentPurpose_clone(const struct LDKPaymentPurpose *NONNULL_PTR orig);
+
+/**
+ * Utility method to constructs a new InvoicePayment-variant PaymentPurpose
+ */
+struct LDKPaymentPurpose PaymentPurpose_invoice_payment(struct LDKThirtyTwoBytes payment_preimage, struct LDKThirtyTwoBytes payment_secret, uint64_t user_payment_id);
+
+/**
+ * Utility method to constructs a new SpontaneousPayment-variant PaymentPurpose
+ */
+struct LDKPaymentPurpose PaymentPurpose_spontaneous_payment(struct LDKThirtyTwoBytes a);
+
/**
* Frees any resources used by the Event
*/
*/
struct LDKEvent Event_clone(const struct LDKEvent *NONNULL_PTR orig);
+/**
+ * Utility method to constructs a new FundingGenerationReady-variant Event
+ */
+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);
+
+/**
+ * Utility method to constructs a new PaymentReceived-variant Event
+ */
+struct LDKEvent Event_payment_received(struct LDKThirtyTwoBytes payment_hash, uint64_t amt, struct LDKPaymentPurpose purpose);
+
+/**
+ * Utility method to constructs a new PaymentSent-variant Event
+ */
+struct LDKEvent Event_payment_sent(struct LDKThirtyTwoBytes payment_preimage);
+
+/**
+ * Utility method to constructs a new PaymentFailed-variant Event
+ */
+struct LDKEvent Event_payment_failed(struct LDKThirtyTwoBytes payment_hash, bool rejected_by_dest);
+
+/**
+ * Utility method to constructs a new PendingHTLCsForwardable-variant Event
+ */
+struct LDKEvent Event_pending_htlcs_forwardable(uint64_t time_forwardable);
+
+/**
+ * Utility method to constructs a new SpendableOutputs-variant Event
+ */
+struct LDKEvent Event_spendable_outputs(struct LDKCVec_SpendableOutputDescriptorZ outputs);
+
+/**
+ * Utility method to constructs a new PaymentForwarded-variant Event
+ */
+struct LDKEvent Event_payment_forwarded(struct LDKCOption_u64Z fee_earned_msat, bool claim_from_onchain_tx);
+
/**
* Serialize the Event object into a byte array which can be read by Event_read
*/
*/
struct LDKMessageSendEvent MessageSendEvent_clone(const struct LDKMessageSendEvent *NONNULL_PTR orig);
+/**
+ * Utility method to constructs a new SendAcceptChannel-variant MessageSendEvent
+ */
+struct LDKMessageSendEvent MessageSendEvent_send_accept_channel(struct LDKPublicKey node_id, struct LDKAcceptChannel msg);
+
+/**
+ * Utility method to constructs a new SendOpenChannel-variant MessageSendEvent
+ */
+struct LDKMessageSendEvent MessageSendEvent_send_open_channel(struct LDKPublicKey node_id, struct LDKOpenChannel msg);
+
+/**
+ * Utility method to constructs a new SendFundingCreated-variant MessageSendEvent
+ */
+struct LDKMessageSendEvent MessageSendEvent_send_funding_created(struct LDKPublicKey node_id, struct LDKFundingCreated msg);
+
+/**
+ * Utility method to constructs a new SendFundingSigned-variant MessageSendEvent
+ */
+struct LDKMessageSendEvent MessageSendEvent_send_funding_signed(struct LDKPublicKey node_id, struct LDKFundingSigned msg);
+
+/**
+ * Utility method to constructs a new SendFundingLocked-variant MessageSendEvent
+ */
+struct LDKMessageSendEvent MessageSendEvent_send_funding_locked(struct LDKPublicKey node_id, struct LDKFundingLocked msg);
+
+/**
+ * Utility method to constructs a new SendAnnouncementSignatures-variant MessageSendEvent
+ */
+struct LDKMessageSendEvent MessageSendEvent_send_announcement_signatures(struct LDKPublicKey node_id, struct LDKAnnouncementSignatures msg);
+
+/**
+ * Utility method to constructs a new UpdateHTLCs-variant MessageSendEvent
+ */
+struct LDKMessageSendEvent MessageSendEvent_update_htlcs(struct LDKPublicKey node_id, struct LDKCommitmentUpdate updates);
+
+/**
+ * Utility method to constructs a new SendRevokeAndACK-variant MessageSendEvent
+ */
+struct LDKMessageSendEvent MessageSendEvent_send_revoke_and_ack(struct LDKPublicKey node_id, struct LDKRevokeAndACK msg);
+
+/**
+ * Utility method to constructs a new SendClosingSigned-variant MessageSendEvent
+ */
+struct LDKMessageSendEvent MessageSendEvent_send_closing_signed(struct LDKPublicKey node_id, struct LDKClosingSigned msg);
+
+/**
+ * Utility method to constructs a new SendShutdown-variant MessageSendEvent
+ */
+struct LDKMessageSendEvent MessageSendEvent_send_shutdown(struct LDKPublicKey node_id, struct LDKShutdown msg);
+
+/**
+ * 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
*/
*/
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);
+
/**
* 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.
*/
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.
*/
enum LDKAccessError AccessError_clone(const enum LDKAccessError *NONNULL_PTR orig);
+/**
+ * Utility method to constructs a new UnknownChain-variant AccessError
+ */
+enum LDKAccessError AccessError_unknown_chain(void);
+
+/**
+ * Utility method to constructs a new UnknownTx-variant AccessError
+ */
+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);
+
/**
* 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.
*/
*/
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
*/
*
* 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);
*/
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.
*
* 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);
* 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.
+ *
+ * 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.
+ *
+ * [`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.
*
* 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);
*/
struct LDKNetAddress NetAddress_clone(const struct LDKNetAddress *NONNULL_PTR orig);
+/**
+ * Utility method to constructs a new IPv4-variant NetAddress
+ */
+struct LDKNetAddress NetAddress_ipv4(struct LDKFourBytes addr, uint16_t port);
+
+/**
+ * Utility method to constructs a new IPv6-variant NetAddress
+ */
+struct LDKNetAddress NetAddress_ipv6(struct LDKSixteenBytes addr, uint16_t port);
+
+/**
+ * Utility method to constructs a new OnionV2-variant NetAddress
+ */
+struct LDKNetAddress NetAddress_onion_v2(struct LDKTenBytes addr, uint16_t port);
+
+/**
+ * Utility method to constructs a new OnionV3-variant NetAddress
+ */
+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
*/
/**
* 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 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"