#ifndef LDK_C_BINDINGS_H
#define LDK_C_BINDINGS_H
-/* Generated with cbindgen:0.19.0 */
+/* Generated with cbindgen:0.20.0 */
/* Warning, this file is autogenerated by cbindgen. Don't modify this manually. */
LDKAccessError_Sentinel,
} LDKAccessError;
+/**
+ * An enum which can either contain a or not
+ */
+typedef enum LDKCOption_NoneZ {
+ /**
+ * When we're in this state, this COption_NoneZ contains a
+ */
+ LDKCOption_NoneZ_Some,
+ /**
+ * When we're in this state, this COption_NoneZ contains nothing
+ */
+ LDKCOption_NoneZ_None,
+ /**
+ * Must be last for serialization purposes
+ */
+ LDKCOption_NoneZ_Sentinel,
+} LDKCOption_NoneZ;
+
/**
* An error enum representing a failure to persist a channel monitor update.
*/
* The supplied expiry time could cause an overflow if added to a `PositiveTimestamp`
*/
LDKCreationError_ExpiryTimeOutOfBounds,
+ /**
+ * The supplied millisatoshi amount was greater than the total bitcoin supply.
+ */
+ LDKCreationError_InvalidAmount,
/**
* Must be last for serialization purposes
*/
* An enum representing the available verbosity levels of the logger.
*/
typedef enum LDKLevel {
+ /**
+ * Designates extremely verbose information, including gossip-induced messages
+ */
+ LDKLevel_Gossip,
/**
* Designates very low priority, often extremely verbose, information
*/
};
} LDKCOption_C2Tuple_usizeTransactionZZ;
+/**
+ * The reason the channel was closed. See individual variants more details.
+ */
+typedef enum LDKClosureReason_Tag {
+ /**
+ * Closure generated from receiving a peer error message.
+ *
+ * Our counterparty may have broadcasted their latest commitment state, and we have
+ * as well.
+ */
+ LDKClosureReason_CounterpartyForceClosed,
+ /**
+ * Closure generated from [`ChannelManager::force_close_channel`], called by the user.
+ *
+ * [`ChannelManager::force_close_channel`]: crate::ln::channelmanager::ChannelManager::force_close_channel.
+ */
+ LDKClosureReason_HolderForceClosed,
+ /**
+ * The channel was closed after negotiating a cooperative close and we've now broadcasted
+ * the cooperative close transaction. Note the shutdown may have been initiated by us.
+ */
+ LDKClosureReason_CooperativeClosure,
+ /**
+ * A commitment transaction was confirmed on chain, closing the channel. Most likely this
+ * commitment transaction came from our counterparty, but it may also have come from
+ * a copy of our own `ChannelMonitor`.
+ */
+ LDKClosureReason_CommitmentTxConfirmed,
+ /**
+ * The funding transaction failed to confirm in a timely manner on an inbound channel.
+ */
+ LDKClosureReason_FundingTimedOut,
+ /**
+ * Closure generated from processing an event, likely a HTLC forward/relay/reception.
+ */
+ LDKClosureReason_ProcessingError,
+ /**
+ * The `PeerManager` informed us that we've disconnected from the peer. We close channels
+ * if the `PeerManager` informed us that it is unlikely we'll be able to connect to the
+ * peer again in the future or if the peer disconnected before we finished negotiating
+ * the channel open. The first case may be caused by incompatible features which our
+ * counterparty, or we, require.
+ */
+ LDKClosureReason_DisconnectedPeer,
+ /**
+ * Closure generated from `ChannelManager::read` if the ChannelMonitor is newer than
+ * the ChannelManager deserialized.
+ */
+ LDKClosureReason_OutdatedChannelManager,
+ /**
+ * Must be last for serialization purposes
+ */
+ LDKClosureReason_Sentinel,
+} LDKClosureReason_Tag;
+
+typedef struct LDKClosureReason_LDKCounterpartyForceClosed_Body {
+ /**
+ * The error which the peer sent us.
+ *
+ * The string should be sanitized before it is used (e.g emitted to logs
+ * or printed to stdout). Otherwise, a well crafted error message may exploit
+ * a security vulnerability in the terminal emulator or the logging subsystem.
+ */
+ struct LDKStr peer_msg;
+} LDKClosureReason_LDKCounterpartyForceClosed_Body;
+
+typedef struct LDKClosureReason_LDKProcessingError_Body {
+ /**
+ * A developer-readable error message which we generated.
+ */
+ struct LDKStr err;
+} LDKClosureReason_LDKProcessingError_Body;
+
+typedef struct MUST_USE_STRUCT LDKClosureReason {
+ LDKClosureReason_Tag tag;
+ union {
+ LDKClosureReason_LDKCounterpartyForceClosed_Body counterparty_force_closed;
+ LDKClosureReason_LDKProcessingError_Body processing_error;
+ };
+} LDKClosureReason;
+
+/**
+ * An enum which can either contain a crate::lightning::util::events::ClosureReason or not
+ */
+typedef enum LDKCOption_ClosureReasonZ_Tag {
+ /**
+ * When we're in this state, this COption_ClosureReasonZ contains a crate::lightning::util::events::ClosureReason
+ */
+ LDKCOption_ClosureReasonZ_Some,
+ /**
+ * When we're in this state, this COption_ClosureReasonZ contains nothing
+ */
+ LDKCOption_ClosureReasonZ_None,
+ /**
+ * Must be last for serialization purposes
+ */
+ LDKCOption_ClosureReasonZ_Sentinel,
+} LDKCOption_ClosureReasonZ_Tag;
+
+typedef struct LDKCOption_ClosureReasonZ {
+ LDKCOption_ClosureReasonZ_Tag tag;
+ union {
+ struct {
+ struct LDKClosureReason some;
+ };
+ };
+} LDKCOption_ClosureReasonZ;
+
+/**
+ * The contents of CResult_COption_ClosureReasonZDecodeErrorZ
+ */
+typedef union LDKCResult_COption_ClosureReasonZDecodeErrorZPtr {
+ /**
+ * A pointer to the contents in the success state.
+ * Reading from this pointer when `result_ok` is not set is undefined.
+ */
+ struct LDKCOption_ClosureReasonZ *result;
+ /**
+ * A pointer to the contents in the error state.
+ * Reading from this pointer when `result_ok` is set is undefined.
+ */
+ struct LDKDecodeError *err;
+} LDKCResult_COption_ClosureReasonZDecodeErrorZPtr;
+
+/**
+ * A CResult_COption_ClosureReasonZDecodeErrorZ represents the result of a fallible operation,
+ * containing a crate::c_types::derived::COption_ClosureReasonZ on success and a crate::lightning::ln::msgs::DecodeError on failure.
+ * `result_ok` indicates the overall state, and the contents are provided via `contents`.
+ */
+typedef struct LDKCResult_COption_ClosureReasonZDecodeErrorZ {
+ /**
+ * The contents of this CResult_COption_ClosureReasonZDecodeErrorZ, accessible via either
+ * `err` or `result` depending on the state of `result_ok`.
+ */
+ union LDKCResult_COption_ClosureReasonZDecodeErrorZPtr contents;
+ /**
+ * Whether this CResult_COption_ClosureReasonZDecodeErrorZ represents a success state.
+ */
+ bool result_ok;
+} LDKCResult_COption_ClosureReasonZDecodeErrorZ;
+
/**
uintptr_t datalen;
} LDKCVec_SpendableOutputDescriptorZ;
-
-
/**
- * An accept_channel message to be sent or received from a peer
+ * 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 struct MUST_USE_STRUCT LDKAcceptChannel {
+typedef enum LDKPaymentPurpose_Tag {
/**
- * A pointer to the opaque Rust object.
- * Nearly everywhere, inner must be non-null, however in places where
- * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ * Information for receiving a payment that we generated an invoice for.
*/
- LDKnativeAcceptChannel *inner;
+ LDKPaymentPurpose_InvoicePayment,
/**
- * 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.
+ * Because this is a spontaneous payment, the payer generated their own preimage rather than us
+ * (the payee) providing a preimage.
*/
- bool is_owned;
-} LDKAcceptChannel;
-
-
+ LDKPaymentPurpose_SpontaneousPayment,
+ /**
+ * Must be last for serialization purposes
+ */
+ LDKPaymentPurpose_Sentinel,
+} LDKPaymentPurpose_Tag;
-/**
- * An open_channel message to be sent or received from a peer
- */
-typedef struct MUST_USE_STRUCT LDKOpenChannel {
+typedef struct LDKPaymentPurpose_LDKInvoicePayment_Body {
/**
- * A pointer to the opaque Rust object.
- * Nearly everywhere, inner must be non-null, however in places where
- * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ * The 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
*/
- LDKnativeOpenChannel *inner;
+ struct LDKThirtyTwoBytes payment_preimage;
/**
- * Indicates that this is the only struct which contains the same pointer.
- * Rust functions which take ownership of an object provided via an argument require
- * this to be true and invalidate the object pointed to by inner.
+ * The \"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
*/
- bool is_owned;
-} LDKOpenChannel;
-
+ struct LDKThirtyTwoBytes payment_secret;
+} LDKPaymentPurpose_LDKInvoicePayment_Body;
+typedef struct MUST_USE_STRUCT LDKPaymentPurpose {
+ LDKPaymentPurpose_Tag tag;
+ union {
+ LDKPaymentPurpose_LDKInvoicePayment_Body invoice_payment;
+ struct {
+ struct LDKThirtyTwoBytes spontaneous_payment;
+ };
+ };
+} LDKPaymentPurpose;
/**
- * A funding_created message to be sent or received from a peer
+ * An Event which you should probably take some action in response to.
+ *
+ * Note that while Writeable and Readable are implemented for Event, you probably shouldn't use
+ * them directly as they don't round-trip exactly (for example FundingGenerationReady is never
+ * written as it makes no sense to respond to it after reconnecting to peers).
*/
-typedef struct MUST_USE_STRUCT LDKFundingCreated {
+typedef enum LDKEvent_Tag {
/**
- * A pointer to the opaque Rust object.
- * Nearly everywhere, inner must be non-null, however in places where
- * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ * Used to indicate that the client should generate a funding transaction with the given
+ * parameters and then call [`ChannelManager::funding_transaction_generated`].
+ * Generated in [`ChannelManager`] message handling.
+ * Note that *all inputs* in the funding transaction must spend SegWit outputs or your
+ * counterparty can steal your funds!
+ *
+ * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
+ * [`ChannelManager::funding_transaction_generated`]: crate::ln::channelmanager::ChannelManager::funding_transaction_generated
*/
- LDKnativeFundingCreated *inner;
+ LDKEvent_FundingGenerationReady,
/**
- * 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.
+ * Indicates we've received money! Just gotta dig out that payment preimage and feed it to
+ * [`ChannelManager::claim_funds`] to get it....
+ * Note that if the preimage is not known, you should call
+ * [`ChannelManager::fail_htlc_backwards`] to free up resources for this HTLC and avoid
+ * network congestion.
+ * If you fail to call either [`ChannelManager::claim_funds`] or
+ * [`ChannelManager::fail_htlc_backwards`] within the HTLC's timeout, the HTLC will be
+ * automatically failed.
+ *
+ * # Note
+ * LDK will not stop an inbound payment from being paid multiple times, so multiple
+ * `PaymentReceived` events may be generated for the same payment.
+ *
+ * [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds
+ * [`ChannelManager::fail_htlc_backwards`]: crate::ln::channelmanager::ChannelManager::fail_htlc_backwards
*/
- bool is_owned;
-} LDKFundingCreated;
-
-
-
-/**
- * A funding_signed message to be sent or received from a peer
- */
-typedef struct MUST_USE_STRUCT LDKFundingSigned {
+ LDKEvent_PaymentReceived,
/**
- * A pointer to the opaque Rust object.
- * Nearly everywhere, inner must be non-null, however in places where
- * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ * Indicates an outbound payment we made succeeded (i.e. it made it all the way to its target
+ * and we got back the payment preimage for it).
+ *
+ * Note for MPP payments: in rare cases, this event may be preceded by a `PaymentPathFailed`
+ * event. In this situation, you SHOULD treat this payment as having succeeded.
*/
- LDKnativeFundingSigned *inner;
+ LDKEvent_PaymentSent,
+ /**
+ * Indicates an outbound HTLC we sent failed. Probably some intermediary node dropped
+ * something. You may wish to retry with a different route.
+ *
+ * Note that this does *not* indicate that all paths for an MPP payment have failed, see
+ * [`Event::PaymentFailed`] and [`all_paths_failed`].
+ *
+ * [`all_paths_failed`]: Self::all_paths_failed
+ */
+ LDKEvent_PaymentPathFailed,
+ /**
+ * Indicates an outbound payment failed. Individual [`Event::PaymentPathFailed`] events
+ * provide failure information for each MPP part in the payment.
+ *
+ * This event is provided once there are no further pending HTLCs for the payment and the
+ * payment is no longer retryable, either due to a several-block timeout or because
+ * [`ChannelManager::abandon_payment`] was previously called for the corresponding payment.
+ *
+ * [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment
+ */
+ LDKEvent_PaymentFailed,
+ /**
+ * Used to indicate that [`ChannelManager::process_pending_htlc_forwards`] should be called at
+ * a time in the future.
+ *
+ * [`ChannelManager::process_pending_htlc_forwards`]: crate::ln::channelmanager::ChannelManager::process_pending_htlc_forwards
+ */
+ LDKEvent_PendingHTLCsForwardable,
+ /**
+ * Used to indicate that an output which you should know how to spend was confirmed on chain
+ * and is now spendable.
+ * Such an output will *not* ever be spent by rust-lightning, and are not at risk of your
+ * counterparty spending them due to some kind of timeout. Thus, you need to store them
+ * 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,
+ /**
+ * Used to indicate that a channel with the given `channel_id` is in the process of closure.
+ */
+ LDKEvent_ChannelClosed,
+ /**
+ * Used to indicate to the user that they can abandon the funding transaction and recycle the
+ * inputs for another purpose.
+ */
+ LDKEvent_DiscardFunding,
+ /**
+ * Indicates that a path for an outbound payment was successful.
+ *
+ * Always generated after [`Event::PaymentSent`] and thus useful for scoring channels. See
+ * [`Event::PaymentSent`] for obtaining the payment preimage.
+ */
+ LDKEvent_PaymentPathSuccessful,
+ /**
+ * Must be last for serialization purposes
+ */
+ LDKEvent_Sentinel,
+} LDKEvent_Tag;
+
+typedef struct LDKEvent_LDKFundingGenerationReady_Body {
+ /**
+ * The random channel_id we picked which you'll need to pass into
+ * ChannelManager::funding_transaction_generated.
+ */
+ struct LDKThirtyTwoBytes temporary_channel_id;
+ /**
+ * The value, in satoshis, that the output should have.
+ */
+ uint64_t channel_value_satoshis;
+ /**
+ * The script which should be used in the transaction output.
+ */
+ struct LDKCVec_u8Z output_script;
+ /**
+ * The `user_channel_id` value passed in to [`ChannelManager::create_channel`], or 0 for
+ * an inbound channel.
+ *
+ * [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
+ */
+ uint64_t user_channel_id;
+} LDKEvent_LDKFundingGenerationReady_Body;
+
+typedef struct LDKEvent_LDKPaymentReceived_Body {
+ /**
+ * The hash for which the preimage should be handed to the ChannelManager. Note that LDK will
+ * not stop you from registering duplicate payment hashes for inbound payments.
+ */
+ struct LDKThirtyTwoBytes payment_hash;
+ /**
+ * The value, in thousandths of a satoshi, that this payment is for.
+ */
+ uint64_t amt;
+ /**
+ * 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.
+ */
+ struct LDKPaymentPurpose purpose;
+} LDKEvent_LDKPaymentReceived_Body;
+
+typedef struct LDKEvent_LDKPaymentSent_Body {
+ /**
+ * The id returned by [`ChannelManager::send_payment`] and used with
+ * [`ChannelManager::retry_payment`].
+ *
+ * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
+ * [`ChannelManager::retry_payment`]: crate::ln::channelmanager::ChannelManager::retry_payment
+ *
+ * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
+ */
+ struct LDKThirtyTwoBytes payment_id;
+ /**
+ * The preimage to the hash given to ChannelManager::send_payment.
+ * Note that this serves as a payment receipt, if you wish to have such a thing, you must
+ * store it somehow!
+ */
+ struct LDKThirtyTwoBytes payment_preimage;
+ /**
+ * The hash that was given to [`ChannelManager::send_payment`].
+ *
+ * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
+ */
+ struct LDKThirtyTwoBytes payment_hash;
+ /**
+ * The total fee which was spent at intermediate hops in this payment, across all paths.
+ *
+ * Note that, like [`Route::get_total_fees`] this does *not* include any potential
+ * overpayment to the recipient node.
+ *
+ * If the recipient or an intermediate node misbehaves and gives us free money, this may
+ * overstate the amount paid, though this is unlikely.
+ *
+ * [`Route::get_total_fees`]: crate::routing::router::Route::get_total_fees
+ */
+ struct LDKCOption_u64Z fee_paid_msat;
+} LDKEvent_LDKPaymentSent_Body;
+
+typedef struct LDKEvent_LDKPaymentPathFailed_Body {
+ /**
+ * The id returned by [`ChannelManager::send_payment`] and used with
+ * [`ChannelManager::retry_payment`] and [`ChannelManager::abandon_payment`].
+ *
+ * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
+ * [`ChannelManager::retry_payment`]: crate::ln::channelmanager::ChannelManager::retry_payment
+ * [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment
+ *
+ * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
+ */
+ struct LDKThirtyTwoBytes payment_id;
+ /**
+ * The hash that was given to [`ChannelManager::send_payment`].
+ *
+ * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
+ */
+ struct LDKThirtyTwoBytes payment_hash;
+ /**
+ * Indicates the payment was rejected for some reason by the recipient. This implies that
+ * the payment has failed, not just the route in question. If this is not set, you may
+ * retry the payment via a different route.
+ */
+ bool rejected_by_dest;
+ /**
+ * Any failure information conveyed via the Onion return packet by a node along the failed
+ * payment route.
+ *
+ * Should be applied to the [`NetworkGraph`] so that routing decisions can take into
+ * account the update. [`NetGraphMsgHandler`] is capable of doing this.
+ *
+ * [`NetworkGraph`]: crate::routing::network_graph::NetworkGraph
+ * [`NetGraphMsgHandler`]: crate::routing::network_graph::NetGraphMsgHandler
+ */
+ struct LDKCOption_NetworkUpdateZ network_update;
+ /**
+ * For both single-path and multi-path payments, this is set if all paths of the payment have
+ * failed. This will be set to false if (1) this is an MPP payment and (2) other parts of the
+ * larger MPP payment were still in flight when this event was generated.
+ *
+ * Note that if you are retrying individual MPP parts, using this value to determine if a
+ * payment has fully failed is race-y. Because multiple failures can happen prior to events
+ * being processed, you may retry in response to a first failure, with a second failure
+ * (with `all_paths_failed` set) still pending. Then, when the second failure is processed
+ * you will see `all_paths_failed` set even though the retry of the first failure still
+ * has an associated in-flight HTLC. See (1) for an example of such a failure.
+ *
+ * If you wish to retry individual MPP parts and learn when a payment has failed, you must
+ * call [`ChannelManager::abandon_payment`] and wait for a [`Event::PaymentFailed`] event.
+ *
+ * (1) <https://github.com/lightningdevkit/rust-lightning/issues/1164>
+ *
+ * [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment
+ */
+ bool all_paths_failed;
+ /**
+ * The payment path that failed.
+ */
+ struct LDKCVec_RouteHopZ path;
+ /**
+ * The channel responsible for the failed payment path.
+ *
+ * If this is `Some`, then the corresponding channel should be avoided when the payment is
+ * retried. May be `None` for older [`Event`] serializations.
+ */
+ struct LDKCOption_u64Z short_channel_id;
+ /**
+ * Parameters needed to compute a new [`Route`] when retrying the failed payment path.
+ *
+ * See [`find_route`] for details.
+ *
+ * [`Route`]: crate::routing::router::Route
+ * [`find_route`]: crate::routing::router::find_route
+ *
+ * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
+ */
+ struct LDKRouteParameters retry;
+} LDKEvent_LDKPaymentPathFailed_Body;
+
+typedef struct LDKEvent_LDKPaymentFailed_Body {
+ /**
+ * The id returned by [`ChannelManager::send_payment`] and used with
+ * [`ChannelManager::retry_payment`] and [`ChannelManager::abandon_payment`].
+ *
+ * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
+ * [`ChannelManager::retry_payment`]: crate::ln::channelmanager::ChannelManager::retry_payment
+ * [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment
+ */
+ struct LDKThirtyTwoBytes payment_id;
+ /**
+ * The hash that was given to [`ChannelManager::send_payment`].
+ *
+ * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
+ */
+ struct LDKThirtyTwoBytes payment_hash;
+} LDKEvent_LDKPaymentFailed_Body;
+
+typedef struct LDKEvent_LDKPendingHTLCsForwardable_Body {
+ /**
+ * The minimum amount of time that should be waited prior to calling
+ * process_pending_htlc_forwards. To increase the effort required to correlate payments,
+ * you should wait a random amount of time in roughly the range (now + time_forwardable,
+ * now + 5*time_forwardable).
+ */
+ uint64_t time_forwardable;
+} LDKEvent_LDKPendingHTLCsForwardable_Body;
+
+typedef struct LDKEvent_LDKSpendableOutputs_Body {
+ /**
+ * The outputs which you should store as spendable by you.
+ */
+ 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 LDKEvent_LDKChannelClosed_Body {
+ /**
+ * The channel_id of the channel which has been closed. Note that on-chain transactions
+ * resolving the channel are likely still awaiting confirmation.
+ */
+ struct LDKThirtyTwoBytes channel_id;
+ /**
+ * The `user_channel_id` value passed in to [`ChannelManager::create_channel`], or 0 for
+ * an inbound channel. This will always be zero for objects serialized with LDK versions
+ * prior to 0.0.102.
+ *
+ * [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
+ */
+ uint64_t user_channel_id;
+ /**
+ * The reason the channel was closed.
+ */
+ struct LDKClosureReason reason;
+} LDKEvent_LDKChannelClosed_Body;
+
+typedef struct LDKEvent_LDKDiscardFunding_Body {
+ /**
+ * The channel_id of the channel which has been closed.
+ */
+ struct LDKThirtyTwoBytes channel_id;
+ /**
+ * The full transaction received from the user
+ */
+ struct LDKTransaction transaction;
+} LDKEvent_LDKDiscardFunding_Body;
+
+typedef struct LDKEvent_LDKPaymentPathSuccessful_Body {
+ /**
+ * The id returned by [`ChannelManager::send_payment`] and used with
+ * [`ChannelManager::retry_payment`].
+ *
+ * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
+ * [`ChannelManager::retry_payment`]: crate::ln::channelmanager::ChannelManager::retry_payment
+ */
+ struct LDKThirtyTwoBytes payment_id;
+ /**
+ * The hash that was given to [`ChannelManager::send_payment`].
+ *
+ * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
+ *
+ * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
+ */
+ struct LDKThirtyTwoBytes payment_hash;
+ /**
+ * The payment path that was successful.
+ *
+ * May contain a closed channel if the HTLC sent along the path was fulfilled on chain.
+ */
+ struct LDKCVec_RouteHopZ path;
+} LDKEvent_LDKPaymentPathSuccessful_Body;
+
+typedef struct MUST_USE_STRUCT LDKEvent {
+ LDKEvent_Tag tag;
+ union {
+ LDKEvent_LDKFundingGenerationReady_Body funding_generation_ready;
+ LDKEvent_LDKPaymentReceived_Body payment_received;
+ LDKEvent_LDKPaymentSent_Body payment_sent;
+ LDKEvent_LDKPaymentPathFailed_Body payment_path_failed;
+ LDKEvent_LDKPaymentFailed_Body payment_failed;
+ LDKEvent_LDKPendingHTLCsForwardable_Body pending_htl_cs_forwardable;
+ LDKEvent_LDKSpendableOutputs_Body spendable_outputs;
+ LDKEvent_LDKPaymentForwarded_Body payment_forwarded;
+ LDKEvent_LDKChannelClosed_Body channel_closed;
+ LDKEvent_LDKDiscardFunding_Body discard_funding;
+ LDKEvent_LDKPaymentPathSuccessful_Body payment_path_successful;
+ };
+} LDKEvent;
+
+/**
+ * An enum which can either contain a crate::lightning::util::events::Event or not
+ */
+typedef enum LDKCOption_EventZ_Tag {
+ /**
+ * When we're in this state, this COption_EventZ contains a crate::lightning::util::events::Event
+ */
+ LDKCOption_EventZ_Some,
+ /**
+ * When we're in this state, this COption_EventZ contains nothing
+ */
+ LDKCOption_EventZ_None,
+ /**
+ * Must be last for serialization purposes
+ */
+ LDKCOption_EventZ_Sentinel,
+} LDKCOption_EventZ_Tag;
+
+typedef struct LDKCOption_EventZ {
+ LDKCOption_EventZ_Tag tag;
+ union {
+ struct {
+ struct LDKEvent some;
+ };
+ };
+} LDKCOption_EventZ;
+
+/**
+ * The contents of CResult_COption_EventZDecodeErrorZ
+ */
+typedef union LDKCResult_COption_EventZDecodeErrorZPtr {
+ /**
+ * A pointer to the contents in the success state.
+ * Reading from this pointer when `result_ok` is not set is undefined.
+ */
+ struct LDKCOption_EventZ *result;
+ /**
+ * A pointer to the contents in the error state.
+ * Reading from this pointer when `result_ok` is set is undefined.
+ */
+ struct LDKDecodeError *err;
+} LDKCResult_COption_EventZDecodeErrorZPtr;
+
+/**
+ * A CResult_COption_EventZDecodeErrorZ represents the result of a fallible operation,
+ * containing a crate::c_types::derived::COption_EventZ on success and a crate::lightning::ln::msgs::DecodeError on failure.
+ * `result_ok` indicates the overall state, and the contents are provided via `contents`.
+ */
+typedef struct LDKCResult_COption_EventZDecodeErrorZ {
+ /**
+ * The contents of this CResult_COption_EventZDecodeErrorZ, accessible via either
+ * `err` or `result` depending on the state of `result_ok`.
+ */
+ union LDKCResult_COption_EventZDecodeErrorZPtr contents;
+ /**
+ * Whether this CResult_COption_EventZDecodeErrorZ represents a success state.
+ */
+ bool result_ok;
+} LDKCResult_COption_EventZDecodeErrorZ;
+
+
+
+/**
+ * An accept_channel message to be sent or received from a peer
+ */
+typedef struct MUST_USE_STRUCT LDKAcceptChannel {
+ /**
+ * 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.
+ */
+ LDKnativeAcceptChannel *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;
+} LDKAcceptChannel;
+
+
+
+/**
+ * An open_channel message to be sent or received from a peer
+ */
+typedef struct MUST_USE_STRUCT LDKOpenChannel {
+ /**
+ * 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.
+ */
+ LDKnativeOpenChannel *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;
+} LDKOpenChannel;
+
+
+
+/**
+ * A funding_created message to be sent or received from a peer
+ */
+typedef struct MUST_USE_STRUCT LDKFundingCreated {
+ /**
+ * 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.
+ */
+ LDKnativeFundingCreated *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;
+} LDKFundingCreated;
+
+
+
+/**
+ * A funding_signed message to be sent or received from a peer
+ */
+typedef struct MUST_USE_STRUCT LDKFundingSigned {
+ /**
+ * 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.
+ */
+ LDKnativeFundingSigned *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
* If the error is logged, log it at the given level.
*/
LDKErrorAction_IgnoreAndLog,
+ /**
+ * The peer provided us with a gossip message which we'd already seen. In most cases this
+ * should be ignored, but it may result in the message being forwarded if it is a duplicate of
+ * our own channel announcements.
+ */
+ LDKErrorAction_IgnoreDuplicateGossip,
/**
* The peer did something incorrect. Tell them.
*/
typedef struct LDKMessageSendEvent_LDKSendShortIdsQuery_Body {
/**
- * The node_id of this message recipient
- */
- struct LDKPublicKey node_id;
- /**
- * The query_short_channel_ids which should be sent.
- */
- struct LDKQueryShortChannelIds msg;
-} LDKMessageSendEvent_LDKSendShortIdsQuery_Body;
-
-typedef struct LDKMessageSendEvent_LDKSendReplyChannelRange_Body {
- /**
- * The node_id of this message recipient
- */
- struct LDKPublicKey node_id;
- /**
- * The reply_channel_range which should be sent.
- */
- struct LDKReplyChannelRange msg;
-} LDKMessageSendEvent_LDKSendReplyChannelRange_Body;
-
-typedef struct MUST_USE_STRUCT LDKMessageSendEvent {
- LDKMessageSendEvent_Tag tag;
- union {
- LDKMessageSendEvent_LDKSendAcceptChannel_Body send_accept_channel;
- LDKMessageSendEvent_LDKSendOpenChannel_Body send_open_channel;
- LDKMessageSendEvent_LDKSendFundingCreated_Body send_funding_created;
- LDKMessageSendEvent_LDKSendFundingSigned_Body send_funding_signed;
- LDKMessageSendEvent_LDKSendFundingLocked_Body send_funding_locked;
- LDKMessageSendEvent_LDKSendAnnouncementSignatures_Body send_announcement_signatures;
- LDKMessageSendEvent_LDKUpdateHTLCs_Body update_htl_cs;
- LDKMessageSendEvent_LDKSendRevokeAndACK_Body send_revoke_and_ack;
- LDKMessageSendEvent_LDKSendClosingSigned_Body send_closing_signed;
- LDKMessageSendEvent_LDKSendShutdown_Body send_shutdown;
- LDKMessageSendEvent_LDKSendChannelReestablish_Body send_channel_reestablish;
- LDKMessageSendEvent_LDKBroadcastChannelAnnouncement_Body broadcast_channel_announcement;
- LDKMessageSendEvent_LDKBroadcastNodeAnnouncement_Body broadcast_node_announcement;
- LDKMessageSendEvent_LDKBroadcastChannelUpdate_Body broadcast_channel_update;
- LDKMessageSendEvent_LDKSendChannelUpdate_Body send_channel_update;
- LDKMessageSendEvent_LDKHandleError_Body handle_error;
- LDKMessageSendEvent_LDKSendChannelRangeQuery_Body send_channel_range_query;
- LDKMessageSendEvent_LDKSendShortIdsQuery_Body send_short_ids_query;
- LDKMessageSendEvent_LDKSendReplyChannelRange_Body send_reply_channel_range;
- };
-} LDKMessageSendEvent;
-
-/**
- * A dynamically-allocated array of crate::lightning::util::events::MessageSendEvents of arbitrary size.
- * This corresponds to std::vector in C++
- */
-typedef struct LDKCVec_MessageSendEventZ {
- /**
- * The elements in the array.
- * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc().
- */
- struct LDKMessageSendEvent *data;
- /**
- * The number of elements pointed to by `data`.
- */
- uintptr_t datalen;
-} LDKCVec_MessageSendEventZ;
-
-
-
-/**
- * Features used within an `init` message.
- */
-typedef struct MUST_USE_STRUCT LDKInitFeatures {
- /**
- * 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.
- */
- LDKnativeInitFeatures *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;
-} LDKInitFeatures;
-
-/**
- * The contents of CResult_InitFeaturesDecodeErrorZ
- */
-typedef union LDKCResult_InitFeaturesDecodeErrorZPtr {
- /**
- * A pointer to the contents in the success state.
- * Reading from this pointer when `result_ok` is not set is undefined.
- */
- struct LDKInitFeatures *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_InitFeaturesDecodeErrorZPtr;
-
-/**
- * A CResult_InitFeaturesDecodeErrorZ represents the result of a fallible operation,
- * containing a crate::lightning::ln::features::InitFeatures 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_InitFeaturesDecodeErrorZ {
- /**
- * The contents of this CResult_InitFeaturesDecodeErrorZ, accessible via either
- * `err` or `result` depending on the state of `result_ok`.
- */
- union LDKCResult_InitFeaturesDecodeErrorZPtr contents;
- /**
- * Whether this CResult_InitFeaturesDecodeErrorZ represents a success state.
- */
- bool result_ok;
-} LDKCResult_InitFeaturesDecodeErrorZ;
-
-
-
-/**
- * Features used within a `node_announcement` message.
- */
-typedef struct MUST_USE_STRUCT LDKNodeFeatures {
- /**
- * 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.
- */
- LDKnativeNodeFeatures *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;
-} LDKNodeFeatures;
-
-/**
- * The contents of CResult_NodeFeaturesDecodeErrorZ
- */
-typedef union LDKCResult_NodeFeaturesDecodeErrorZPtr {
- /**
- * A pointer to the contents in the success state.
- * Reading from this pointer when `result_ok` is not set is undefined.
- */
- struct LDKNodeFeatures *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_NodeFeaturesDecodeErrorZPtr;
-
-/**
- * A CResult_NodeFeaturesDecodeErrorZ represents the result of a fallible operation,
- * containing a crate::lightning::ln::features::NodeFeatures 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_NodeFeaturesDecodeErrorZ {
- /**
- * The contents of this CResult_NodeFeaturesDecodeErrorZ, accessible via either
- * `err` or `result` depending on the state of `result_ok`.
- */
- union LDKCResult_NodeFeaturesDecodeErrorZPtr contents;
- /**
- * Whether this CResult_NodeFeaturesDecodeErrorZ represents a success state.
- */
- bool result_ok;
-} LDKCResult_NodeFeaturesDecodeErrorZ;
-
-
-
-/**
- * Features used within a `channel_announcement` message.
- */
-typedef struct MUST_USE_STRUCT LDKChannelFeatures {
- /**
- * 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.
- */
- LDKnativeChannelFeatures *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;
-} LDKChannelFeatures;
-
-/**
- * The contents of CResult_ChannelFeaturesDecodeErrorZ
- */
-typedef union LDKCResult_ChannelFeaturesDecodeErrorZPtr {
- /**
- * A pointer to the contents in the success state.
- * Reading from this pointer when `result_ok` is not set is undefined.
- */
- struct LDKChannelFeatures *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_ChannelFeaturesDecodeErrorZPtr;
-
-/**
- * A CResult_ChannelFeaturesDecodeErrorZ represents the result of a fallible operation,
- * containing a crate::lightning::ln::features::ChannelFeatures 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_ChannelFeaturesDecodeErrorZ {
- /**
- * The contents of this CResult_ChannelFeaturesDecodeErrorZ, accessible via either
- * `err` or `result` depending on the state of `result_ok`.
- */
- union LDKCResult_ChannelFeaturesDecodeErrorZPtr contents;
- /**
- * Whether this CResult_ChannelFeaturesDecodeErrorZ represents a success state.
- */
- bool result_ok;
-} LDKCResult_ChannelFeaturesDecodeErrorZ;
-
-
-
-/**
- * Features used within an invoice.
- */
-typedef struct MUST_USE_STRUCT LDKInvoiceFeatures {
- /**
- * A pointer to the opaque Rust object.
- * Nearly everywhere, inner must be non-null, however in places where
- * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ * The node_id of this message recipient
*/
- LDKnativeInvoiceFeatures *inner;
+ struct LDKPublicKey node_id;
/**
- * Indicates that this is the only struct which contains the same pointer.
- * Rust functions which take ownership of an object provided via an argument require
- * this to be true and invalidate the object pointed to by inner.
+ * The query_short_channel_ids which should be sent.
*/
- bool is_owned;
-} LDKInvoiceFeatures;
+ struct LDKQueryShortChannelIds msg;
+} LDKMessageSendEvent_LDKSendShortIdsQuery_Body;
-/**
- * The contents of CResult_InvoiceFeaturesDecodeErrorZ
- */
-typedef union LDKCResult_InvoiceFeaturesDecodeErrorZPtr {
+typedef struct LDKMessageSendEvent_LDKSendReplyChannelRange_Body {
/**
- * A pointer to the contents in the success state.
- * Reading from this pointer when `result_ok` is not set is undefined.
+ * The node_id of this message recipient
*/
- struct LDKInvoiceFeatures *result;
+ struct LDKPublicKey node_id;
/**
- * A pointer to the contents in the error state.
- * Reading from this pointer when `result_ok` is set is undefined.
+ * The reply_channel_range which should be sent.
*/
- struct LDKDecodeError *err;
-} LDKCResult_InvoiceFeaturesDecodeErrorZPtr;
+ struct LDKReplyChannelRange msg;
+} LDKMessageSendEvent_LDKSendReplyChannelRange_Body;
+
+typedef struct MUST_USE_STRUCT LDKMessageSendEvent {
+ LDKMessageSendEvent_Tag tag;
+ union {
+ LDKMessageSendEvent_LDKSendAcceptChannel_Body send_accept_channel;
+ LDKMessageSendEvent_LDKSendOpenChannel_Body send_open_channel;
+ LDKMessageSendEvent_LDKSendFundingCreated_Body send_funding_created;
+ LDKMessageSendEvent_LDKSendFundingSigned_Body send_funding_signed;
+ LDKMessageSendEvent_LDKSendFundingLocked_Body send_funding_locked;
+ LDKMessageSendEvent_LDKSendAnnouncementSignatures_Body send_announcement_signatures;
+ LDKMessageSendEvent_LDKUpdateHTLCs_Body update_htl_cs;
+ LDKMessageSendEvent_LDKSendRevokeAndACK_Body send_revoke_and_ack;
+ LDKMessageSendEvent_LDKSendClosingSigned_Body send_closing_signed;
+ LDKMessageSendEvent_LDKSendShutdown_Body send_shutdown;
+ LDKMessageSendEvent_LDKSendChannelReestablish_Body send_channel_reestablish;
+ LDKMessageSendEvent_LDKBroadcastChannelAnnouncement_Body broadcast_channel_announcement;
+ LDKMessageSendEvent_LDKBroadcastNodeAnnouncement_Body broadcast_node_announcement;
+ LDKMessageSendEvent_LDKBroadcastChannelUpdate_Body broadcast_channel_update;
+ LDKMessageSendEvent_LDKSendChannelUpdate_Body send_channel_update;
+ LDKMessageSendEvent_LDKHandleError_Body handle_error;
+ LDKMessageSendEvent_LDKSendChannelRangeQuery_Body send_channel_range_query;
+ LDKMessageSendEvent_LDKSendShortIdsQuery_Body send_short_ids_query;
+ LDKMessageSendEvent_LDKSendReplyChannelRange_Body send_reply_channel_range;
+ };
+} LDKMessageSendEvent;
/**
- * A CResult_InvoiceFeaturesDecodeErrorZ represents the result of a fallible operation,
- * containing a crate::lightning::ln::features::InvoiceFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure.
- * `result_ok` indicates the overall state, and the contents are provided via `contents`.
+ * A dynamically-allocated array of crate::lightning::util::events::MessageSendEvents of arbitrary size.
+ * This corresponds to std::vector in C++
*/
-typedef struct LDKCResult_InvoiceFeaturesDecodeErrorZ {
+typedef struct LDKCVec_MessageSendEventZ {
/**
- * The contents of this CResult_InvoiceFeaturesDecodeErrorZ, accessible via either
- * `err` or `result` depending on the state of `result_ok`.
+ * The elements in the array.
+ * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc().
*/
- union LDKCResult_InvoiceFeaturesDecodeErrorZPtr contents;
+ struct LDKMessageSendEvent *data;
/**
- * Whether this CResult_InvoiceFeaturesDecodeErrorZ represents a success state.
+ * The number of elements pointed to by `data`.
*/
- bool result_ok;
-} LDKCResult_InvoiceFeaturesDecodeErrorZ;
+ uintptr_t datalen;
+} LDKCVec_MessageSendEventZ;
/**
* A CResult_ScoringParametersDecodeErrorZ represents the result of a fallible operation,
- * containing a crate::lightning::routing::scorer::ScoringParameters on success and a crate::lightning::ln::msgs::DecodeError on failure.
+ * containing a crate::lightning::routing::scoring::ScoringParameters on success and a crate::lightning::ln::msgs::DecodeError on failure.
* `result_ok` indicates the overall state, and the contents are provided via `contents`.
*/
typedef struct LDKCResult_ScoringParametersDecodeErrorZ {
/**
- * [`routing::Score`] implementation that provides reasonable default behavior.
+ * [`Score`] implementation that provides reasonable default behavior.
*
* Used to apply a fixed penalty to each channel, thus avoiding long paths when shorter paths with
* slightly higher fees are available. Will further penalize channels that fail to relay payments.
*
* See [module-level documentation] for usage.
*
- * [module-level documentation]: crate::routing::scorer
+ * [module-level documentation]: crate::routing::scoring
*/
typedef struct MUST_USE_STRUCT LDKScorer {
/**
/**
* A CResult_ScorerDecodeErrorZ represents the result of a fallible operation,
- * containing a crate::lightning::routing::scorer::Scorer on success and a crate::lightning::ln::msgs::DecodeError on failure.
+ * containing a crate::lightning::routing::scoring::Scorer on success and a crate::lightning::ln::msgs::DecodeError on failure.
* `result_ok` indicates the overall state, and the contents are provided via `contents`.
*/
typedef struct LDKCResult_ScorerDecodeErrorZ {
bool result_ok;
} LDKCResult_ScorerDecodeErrorZ;
-/**
- * The contents of CResult_DelayedPaymentOutputDescriptorDecodeErrorZ
- */
-typedef union LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZPtr {
- /**
- * A pointer to the contents in the success state.
- * Reading from this pointer when `result_ok` is not set is undefined.
- */
- struct LDKDelayedPaymentOutputDescriptor *result;
- /**
- * A pointer to the contents in the error state.
- * Reading from this pointer when `result_ok` is set is undefined.
- */
- struct LDKDecodeError *err;
-} LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZPtr;
-
-/**
- * A CResult_DelayedPaymentOutputDescriptorDecodeErrorZ represents the result of a fallible operation,
- * containing a crate::lightning::chain::keysinterface::DelayedPaymentOutputDescriptor on success and a crate::lightning::ln::msgs::DecodeError on failure.
- * `result_ok` indicates the overall state, and the contents are provided via `contents`.
- */
-typedef struct LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ {
- /**
- * The contents of this CResult_DelayedPaymentOutputDescriptorDecodeErrorZ, accessible via either
- * `err` or `result` depending on the state of `result_ok`.
- */
- union LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZPtr contents;
- /**
- * Whether this CResult_DelayedPaymentOutputDescriptorDecodeErrorZ represents a success state.
- */
- bool result_ok;
-} LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ;
-
-/**
- * The contents of CResult_StaticPaymentOutputDescriptorDecodeErrorZ
- */
-typedef union LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZPtr {
- /**
- * A pointer to the contents in the success state.
- * Reading from this pointer when `result_ok` is not set is undefined.
- */
- struct LDKStaticPaymentOutputDescriptor *result;
- /**
- * A pointer to the contents in the error state.
- * Reading from this pointer when `result_ok` is set is undefined.
- */
- struct LDKDecodeError *err;
-} LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZPtr;
-
-/**
- * A CResult_StaticPaymentOutputDescriptorDecodeErrorZ represents the result of a fallible operation,
- * containing a crate::lightning::chain::keysinterface::StaticPaymentOutputDescriptor on success and a crate::lightning::ln::msgs::DecodeError on failure.
- * `result_ok` indicates the overall state, and the contents are provided via `contents`.
- */
-typedef struct LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ {
- /**
- * The contents of this CResult_StaticPaymentOutputDescriptorDecodeErrorZ, accessible via either
- * `err` or `result` depending on the state of `result_ok`.
- */
- union LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZPtr contents;
- /**
- * Whether this CResult_StaticPaymentOutputDescriptorDecodeErrorZ represents a success state.
- */
- bool result_ok;
-} LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ;
-
-/**
- * The contents of CResult_SpendableOutputDescriptorDecodeErrorZ
- */
-typedef union LDKCResult_SpendableOutputDescriptorDecodeErrorZPtr {
- /**
- * A pointer to the contents in the success state.
- * Reading from this pointer when `result_ok` is not set is undefined.
- */
- struct LDKSpendableOutputDescriptor *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_SpendableOutputDescriptorDecodeErrorZPtr;
-
-/**
- * A CResult_SpendableOutputDescriptorDecodeErrorZ represents the result of a fallible operation,
- * containing a crate::lightning::chain::keysinterface::SpendableOutputDescriptor on success and a crate::lightning::ln::msgs::DecodeError on failure.
- * `result_ok` indicates the overall state, and the contents are provided via `contents`.
- */
-typedef struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ {
- /**
- * The contents of this CResult_SpendableOutputDescriptorDecodeErrorZ, accessible via either
- * `err` or `result` depending on the state of `result_ok`.
- */
- union LDKCResult_SpendableOutputDescriptorDecodeErrorZPtr contents;
- /**
- * Whether this CResult_SpendableOutputDescriptorDecodeErrorZ represents a success state.
- */
- bool result_ok;
-} LDKCResult_SpendableOutputDescriptorDecodeErrorZ;
-
-/**
- * The contents of CResult_NoneNoneZ
- */
-typedef union LDKCResult_NoneNoneZPtr {
- /**
- * Note that this value is always NULL, as there are no contents in the OK variant
- */
- void *result;
- /**
- * Note that this value is always NULL, as there are no contents in the Err variant
- */
- void *err;
-} LDKCResult_NoneNoneZPtr;
-
-/**
- * A CResult_NoneNoneZ represents the result of a fallible operation,
- * containing a () on success and a () on failure.
- * `result_ok` indicates the overall state, and the contents are provided via `contents`.
- */
-typedef struct LDKCResult_NoneNoneZ {
- /**
- * The contents of this CResult_NoneNoneZ, accessible via either
- * `err` or `result` depending on the state of `result_ok`.
- */
- union LDKCResult_NoneNoneZPtr contents;
- /**
- * Whether this CResult_NoneNoneZ represents a success state.
- */
- bool result_ok;
-} LDKCResult_NoneNoneZ;
-
-/**
- * A tuple of 2 elements. See the individual fields for the types contained.
- */
-typedef struct LDKC2Tuple_SignatureCVec_SignatureZZ {
- /**
- * The element at position 0
- */
- struct LDKSignature a;
- /**
- * The element at position 1
- */
- struct LDKCVec_SignatureZ b;
-} LDKC2Tuple_SignatureCVec_SignatureZZ;
-/**
- * The contents of CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ
- */
-typedef union LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr {
- /**
- * A pointer to the contents in the success state.
- * Reading from this pointer when `result_ok` is not set is undefined.
- */
- struct LDKC2Tuple_SignatureCVec_SignatureZZ *result;
- /**
- * Note that this value is always NULL, as there are no contents in the Err variant
- */
- void *err;
-} LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr;
/**
- * A CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ represents the result of a fallible operation,
- * containing a crate::c_types::derived::C2Tuple_SignatureCVec_SignatureZZ on success and a () on failure.
- * `result_ok` indicates the overall state, and the contents are provided via `contents`.
+ * Features used within an `init` message.
*/
-typedef struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ {
+typedef struct MUST_USE_STRUCT LDKInitFeatures {
/**
- * The contents of this CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ, accessible via either
- * `err` or `result` depending on the state of `result_ok`.
+ * A pointer to the opaque Rust object.
+ * Nearly everywhere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
*/
- union LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr contents;
+ LDKnativeInitFeatures *inner;
/**
- * Whether this CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ represents a success state.
+ * Indicates that this is the only struct which contains the same pointer.
+ * Rust functions which take ownership of an object provided via an argument require
+ * this to be true and invalidate the object pointed to by inner.
*/
- bool result_ok;
-} LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ;
+ bool is_owned;
+} LDKInitFeatures;
/**
- * The contents of CResult_SignatureNoneZ
+ * The contents of CResult_InitFeaturesDecodeErrorZ
*/
-typedef union LDKCResult_SignatureNoneZPtr {
+typedef union LDKCResult_InitFeaturesDecodeErrorZPtr {
/**
* A pointer to the contents in the success state.
* Reading from this pointer when `result_ok` is not set is undefined.
*/
- struct LDKSignature *result;
+ struct LDKInitFeatures *result;
/**
- * Note that this value is always NULL, as there are no contents in the Err variant
+ * A pointer to the contents in the error state.
+ * Reading from this pointer when `result_ok` is set is undefined.
*/
- void *err;
-} LDKCResult_SignatureNoneZPtr;
+ struct LDKDecodeError *err;
+} LDKCResult_InitFeaturesDecodeErrorZPtr;
/**
- * A CResult_SignatureNoneZ represents the result of a fallible operation,
- * containing a crate::c_types::Signature on success and a () on failure.
+ * A CResult_InitFeaturesDecodeErrorZ represents the result of a fallible operation,
+ * containing a crate::lightning::ln::features::InitFeatures 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_SignatureNoneZ {
+typedef struct LDKCResult_InitFeaturesDecodeErrorZ {
/**
- * The contents of this CResult_SignatureNoneZ, accessible via either
+ * The contents of this CResult_InitFeaturesDecodeErrorZ, accessible via either
* `err` or `result` depending on the state of `result_ok`.
*/
- union LDKCResult_SignatureNoneZPtr contents;
+ union LDKCResult_InitFeaturesDecodeErrorZPtr contents;
/**
- * Whether this CResult_SignatureNoneZ represents a success state.
+ * Whether this CResult_InitFeaturesDecodeErrorZ represents a success state.
*/
bool result_ok;
-} LDKCResult_SignatureNoneZ;
+} LDKCResult_InitFeaturesDecodeErrorZ;
/**
- * This class tracks the per-transaction information needed to build a closing transaction and will
- * actually build it and sign.
- *
- * This class can be used inside a signer implementation to generate a signature given the relevant
- * secret key.
+ * Features used within a `channel_announcement` message.
*/
-typedef struct MUST_USE_STRUCT LDKClosingTransaction {
+typedef struct MUST_USE_STRUCT LDKChannelFeatures {
/**
* A pointer to the opaque Rust object.
* Nearly everywhere, inner must be non-null, however in places where
* the Rust equivalent takes an Option, it may be set to null to indicate None.
*/
- LDKnativeClosingTransaction *inner;
+ LDKnativeChannelFeatures *inner;
/**
* Indicates that this is the only struct which contains the same pointer.
* Rust functions which take ownership of an object provided via an argument require
* this to be true and invalidate the object pointed to by inner.
*/
bool is_owned;
-} LDKClosingTransaction;
+} LDKChannelFeatures;
+
+/**
+ * The contents of CResult_ChannelFeaturesDecodeErrorZ
+ */
+typedef union LDKCResult_ChannelFeaturesDecodeErrorZPtr {
+ /**
+ * A pointer to the contents in the success state.
+ * Reading from this pointer when `result_ok` is not set is undefined.
+ */
+ struct LDKChannelFeatures *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_ChannelFeaturesDecodeErrorZPtr;
+
+/**
+ * A CResult_ChannelFeaturesDecodeErrorZ represents the result of a fallible operation,
+ * containing a crate::lightning::ln::features::ChannelFeatures 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_ChannelFeaturesDecodeErrorZ {
+ /**
+ * The contents of this CResult_ChannelFeaturesDecodeErrorZ, accessible via either
+ * `err` or `result` depending on the state of `result_ok`.
+ */
+ union LDKCResult_ChannelFeaturesDecodeErrorZPtr contents;
+ /**
+ * Whether this CResult_ChannelFeaturesDecodeErrorZ represents a success state.
+ */
+ bool result_ok;
+} LDKCResult_ChannelFeaturesDecodeErrorZ;
/**
- * The unsigned part of a channel_announcement
+ * Features used within a `node_announcement` message.
*/
-typedef struct MUST_USE_STRUCT LDKUnsignedChannelAnnouncement {
+typedef struct MUST_USE_STRUCT LDKNodeFeatures {
/**
* A pointer to the opaque Rust object.
* Nearly everywhere, inner must be non-null, however in places where
* the Rust equivalent takes an Option, it may be set to null to indicate None.
*/
- LDKnativeUnsignedChannelAnnouncement *inner;
+ LDKnativeNodeFeatures *inner;
/**
* Indicates that this is the only struct which contains the same pointer.
* Rust functions which take ownership of an object provided via an argument require
* this to be true and invalidate the object pointed to by inner.
*/
bool is_owned;
-} LDKUnsignedChannelAnnouncement;
+} LDKNodeFeatures;
/**
- * A trait to sign lightning channel transactions as described in BOLT 3.
- *
- * Signing services could be implemented on a hardware wallet. In this case,
- * the current Sign would be a front-end on top of a communication
- * channel connected to your secure device and lightning key material wouldn't
- * reside on a hot server. Nevertheless, a this deployment would still need
- * to trust the ChannelManager to avoid loss of funds as this latest component
- * could ask to sign commitment transaction with HTLCs paying to attacker pubkeys.
- *
- * A more secure iteration would be to use hashlock (or payment points) to pair
- * invoice/incoming HTLCs with outgoing HTLCs to implement a no-trust-ChannelManager
- * at the price of more state and computation on the hardware wallet side. In the future,
- * we are looking forward to design such interface.
- *
- * In any case, ChannelMonitor or fallback watchtowers are always going to be trusted
- * to act, as liveness and breach reply correctness are always going to be hard requirements
- * of LN security model, orthogonal of key management issues.
+ * The contents of CResult_NodeFeaturesDecodeErrorZ
*/
-typedef struct LDKBaseSign {
- /**
- * An opaque pointer which is passed to your function implementations as an argument.
- * This has no meaning in the LDK, and can be NULL or any other value.
- */
- void *this_arg;
- /**
- * Gets the per-commitment point for a specific commitment number
- *
- * Note that the commitment number starts at (1 << 48) - 1 and counts backwards.
- */
- struct LDKPublicKey (*get_per_commitment_point)(const void *this_arg, uint64_t idx);
- /**
- * Gets the commitment secret for a specific commitment number as part of the revocation process
- *
- * An external signer implementation should error here if the commitment was already signed
- * and should refuse to sign it in the future.
- *
- * May be called more than once for the same index.
- *
- * Note that the commitment number starts at (1 << 48) - 1 and counts backwards.
- */
- struct LDKThirtyTwoBytes (*release_commitment_secret)(const void *this_arg, uint64_t idx);
- /**
- * Validate the counterparty's signatures on the holder commitment transaction and HTLCs.
- *
- * This is required in order for the signer to make sure that releasing a commitment
- * secret won't leave us without a broadcastable holder transaction.
- * Policy checks should be implemented in this function, including checking the amount
- * sent to us and checking the HTLCs.
- */
- struct LDKCResult_NoneNoneZ (*validate_holder_commitment)(const void *this_arg, const struct LDKHolderCommitmentTransaction *NONNULL_PTR holder_tx);
- /**
- * Gets the holder's channel public keys and basepoints
- */
- struct LDKChannelPublicKeys pubkeys;
- /**
- * Fill in the pubkeys field as a reference to it will be given to Rust after this returns
- * Note that this takes a pointer to this object, not the this_ptr like other methods do
- * This function pointer may be NULL if pubkeys is filled in when this object is created and never needs updating.
- */
- void (*set_pubkeys)(const struct LDKBaseSign*NONNULL_PTR );
- /**
- * Gets an arbitrary identifier describing the set of keys which are provided back to you in
- * some SpendableOutputDescriptor types. This should be sufficient to identify this
- * Sign object uniquely and lookup or re-derive its keys.
- */
- struct LDKThirtyTwoBytes (*channel_keys_id)(const void *this_arg);
+typedef union LDKCResult_NodeFeaturesDecodeErrorZPtr {
/**
- * Create a signature for a counterparty's commitment transaction and associated HTLC transactions.
- *
- * Note that if signing fails or is rejected, the channel will be force-closed.
- *
- * Policy checks should be implemented in this function, including checking the amount
- * sent to us and checking the HTLCs.
+ * A pointer to the contents in the success state.
+ * Reading from this pointer when `result_ok` is not set is undefined.
*/
- struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ (*sign_counterparty_commitment)(const void *this_arg, const struct LDKCommitmentTransaction *NONNULL_PTR commitment_tx);
+ struct LDKNodeFeatures *result;
/**
- * Validate the counterparty's revocation.
- *
- * This is required in order for the signer to make sure that the state has moved
- * forward and it is safe to sign the next counterparty commitment.
+ * A pointer to the contents in the error state.
+ * Reading from this pointer when `result_ok` is set is undefined.
*/
- struct LDKCResult_NoneNoneZ (*validate_counterparty_revocation)(const void *this_arg, uint64_t idx, const uint8_t (*secret)[32]);
+ struct LDKDecodeError *err;
+} LDKCResult_NodeFeaturesDecodeErrorZPtr;
+
+/**
+ * A CResult_NodeFeaturesDecodeErrorZ represents the result of a fallible operation,
+ * containing a crate::lightning::ln::features::NodeFeatures 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_NodeFeaturesDecodeErrorZ {
/**
- * Create a signatures for a holder's commitment transaction and its claiming HTLC transactions.
- * This will only ever be called with a non-revoked commitment_tx. This will be called with the
- * latest commitment_tx when we initiate a force-close.
- * This will be called with the previous latest, just to get claiming HTLC signatures, if we are
- * reacting to a ChannelMonitor replica that decided to broadcast before it had been updated to
- * the latest.
- * This may be called multiple times for the same transaction.
- *
- * An external signer implementation should check that the commitment has not been revoked.
- *
- * May return Err if key derivation fails. Callers, such as ChannelMonitor, will panic in such a case.
+ * The contents of this CResult_NodeFeaturesDecodeErrorZ, accessible via either
+ * `err` or `result` depending on the state of `result_ok`.
*/
- struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ (*sign_holder_commitment_and_htlcs)(const void *this_arg, const struct LDKHolderCommitmentTransaction *NONNULL_PTR commitment_tx);
+ union LDKCResult_NodeFeaturesDecodeErrorZPtr contents;
/**
- * Create a signature for the given input in a transaction spending an HTLC transaction output
- * or a commitment transaction `to_local` output when our counterparty broadcasts an old state.
- *
- * A justice transaction may claim multiple outputs at the same time if timelocks are
- * similar, but only a signature for the input at index `input` should be signed for here.
- * It may be called multiple times for same output(s) if a fee-bump is needed with regards
- * to an upcoming timelock expiration.
- *
- * Amount is value of the output spent by this input, committed to in the BIP 143 signature.
- *
- * per_commitment_key is revocation secret which was provided by our counterparty when they
- * revoked the state which they eventually broadcast. It's not a _holder_ secret key and does
- * not allow the spending of any funds by itself (you need our holder revocation_secret to do
- * so).
+ * Whether this CResult_NodeFeaturesDecodeErrorZ represents a success state.
*/
- struct LDKCResult_SignatureNoneZ (*sign_justice_revoked_output)(const void *this_arg, struct LDKTransaction justice_tx, uintptr_t input, uint64_t amount, const uint8_t (*per_commitment_key)[32]);
+ bool result_ok;
+} LDKCResult_NodeFeaturesDecodeErrorZ;
+
+
+
+/**
+ * Features used within an invoice.
+ */
+typedef struct MUST_USE_STRUCT LDKInvoiceFeatures {
/**
- * Create a signature for the given input in a transaction spending a commitment transaction
- * HTLC output when our counterparty broadcasts an old state.
- *
- * A justice transaction may claim multiple outputs at the same time if timelocks are
- * similar, but only a signature for the input at index `input` should be signed for here.
- * It may be called multiple times for same output(s) if a fee-bump is needed with regards
- * to an upcoming timelock expiration.
- *
- * Amount is value of the output spent by this input, committed to in the BIP 143 signature.
- *
- * per_commitment_key is revocation secret which was provided by our counterparty when they
- * revoked the state which they eventually broadcast. It's not a _holder_ secret key and does
- * not allow the spending of any funds by itself (you need our holder revocation_secret to do
- * so).
- *
- * htlc holds HTLC elements (hash, timelock), thus changing the format of the witness script
- * (which is committed to in the BIP 143 signatures).
+ * A pointer to the opaque Rust object.
+ * Nearly everywhere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
*/
- struct LDKCResult_SignatureNoneZ (*sign_justice_revoked_htlc)(const void *this_arg, struct LDKTransaction justice_tx, uintptr_t input, uint64_t amount, const uint8_t (*per_commitment_key)[32], const struct LDKHTLCOutputInCommitment *NONNULL_PTR htlc);
+ LDKnativeInvoiceFeatures *inner;
/**
- * Create a signature for a claiming transaction for a HTLC output on a counterparty's commitment
- * transaction, either offered or received.
- *
- * Such a transaction may claim multiples offered outputs at same time if we know the
- * preimage for each when we create it, but only the input at index `input` should be
- * signed for here. It may be called multiple times for same output(s) if a fee-bump is
- * needed with regards to an upcoming timelock expiration.
- *
- * Witness_script is either a offered or received script as defined in BOLT3 for HTLC
- * outputs.
- *
- * Amount is value of the output spent by this input, committed to in the BIP 143 signature.
- *
- * Per_commitment_point is the dynamic point corresponding to the channel state
- * detected onchain. It has been generated by our counterparty and is used to derive
- * channel state keys, which are then included in the witness script and committed to in the
- * BIP 143 signature.
+ * Indicates that this is the only struct which contains the same pointer.
+ * Rust functions which take ownership of an object provided via an argument require
+ * this to be true and invalidate the object pointed to by inner.
*/
- struct LDKCResult_SignatureNoneZ (*sign_counterparty_htlc_transaction)(const void *this_arg, struct LDKTransaction htlc_tx, uintptr_t input, uint64_t amount, struct LDKPublicKey per_commitment_point, const struct LDKHTLCOutputInCommitment *NONNULL_PTR htlc);
+ bool is_owned;
+} LDKInvoiceFeatures;
+
+/**
+ * The contents of CResult_InvoiceFeaturesDecodeErrorZ
+ */
+typedef union LDKCResult_InvoiceFeaturesDecodeErrorZPtr {
/**
- * Create a signature for a (proposed) closing transaction.
- *
- * Note that, due to rounding, there may be one \"missing\" satoshi, and either party may have
- * chosen to forgo their output as dust.
+ * A pointer to the contents in the success state.
+ * Reading from this pointer when `result_ok` is not set is undefined.
*/
- struct LDKCResult_SignatureNoneZ (*sign_closing_transaction)(const void *this_arg, const struct LDKClosingTransaction *NONNULL_PTR closing_tx);
+ struct LDKInvoiceFeatures *result;
/**
- * Signs a channel announcement message with our funding key, proving it comes from one
- * of the channel participants.
- *
- * Note that if this fails or is rejected, the channel will not be publicly announced and
- * our counterparty may (though likely will not) close the channel on us for violating the
- * protocol.
+ * A pointer to the contents in the error state.
+ * Reading from this pointer when `result_ok` is set is undefined.
*/
- struct LDKCResult_SignatureNoneZ (*sign_channel_announcement)(const void *this_arg, const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR msg);
+ struct LDKDecodeError *err;
+} LDKCResult_InvoiceFeaturesDecodeErrorZPtr;
+
+/**
+ * A CResult_InvoiceFeaturesDecodeErrorZ represents the result of a fallible operation,
+ * containing a crate::lightning::ln::features::InvoiceFeatures 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_InvoiceFeaturesDecodeErrorZ {
/**
- * Set the counterparty static channel data, including basepoints,
- * counterparty_selected/holder_selected_contest_delay and funding outpoint.
- * This is done as soon as the funding outpoint is known. Since these are static channel data,
- * they MUST NOT be allowed to change to different values once set.
- *
- * channel_parameters.is_populated() MUST be true.
- *
- * We bind holder_selected_contest_delay late here for API convenience.
- *
- * Will be called before any signatures are applied.
+ * The contents of this CResult_InvoiceFeaturesDecodeErrorZ, accessible via either
+ * `err` or `result` depending on the state of `result_ok`.
*/
- void (*ready_channel)(void *this_arg, const struct LDKChannelTransactionParameters *NONNULL_PTR channel_parameters);
+ union LDKCResult_InvoiceFeaturesDecodeErrorZPtr contents;
/**
- * Frees any resources associated with this object given its this_arg pointer.
- * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
+ * Whether this CResult_InvoiceFeaturesDecodeErrorZ represents a success state.
*/
- void (*free)(void *this_arg);
-} LDKBaseSign;
+ bool result_ok;
+} LDKCResult_InvoiceFeaturesDecodeErrorZ;
+
+
/**
- * A cloneable signer.
+ * Features used within the channel_type field in an OpenChannel message.
*
- * Although we require signers to be cloneable, it may be useful for developers to be able to use
- * signers in an un-sized way, for example as `dyn BaseSign`. Therefore we separate the Clone trait,
- * which implies Sized, into this derived trait.
+ * A channel is always of some known \"type\", describing the transaction formats used and the exact
+ * semantics of our interaction with our peer.
+ *
+ * Note that because a channel is a specific type which is proposed by the opener and accepted by
+ * the counterparty, only required features are allowed here.
+ *
+ * This is serialized differently from other feature types - it is not prefixed by a length, and
+ * thus must only appear inside a TLV where its length is known in advance.
*/
-typedef struct LDKSign {
+typedef struct MUST_USE_STRUCT LDKChannelTypeFeatures {
/**
- * An opaque pointer which is passed to your function implementations as an argument.
- * This has no meaning in the LDK, and can be NULL or any other value.
+ * A pointer to the opaque Rust object.
+ * Nearly everywhere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
*/
- void *this_arg;
+ LDKnativeChannelTypeFeatures *inner;
/**
- * Implementation of BaseSign for this object.
+ * Indicates that this is the only struct which contains the same pointer.
+ * Rust functions which take ownership of an object provided via an argument require
+ * this to be true and invalidate the object pointed to by inner.
*/
- struct LDKBaseSign BaseSign;
+ bool is_owned;
+} LDKChannelTypeFeatures;
+
+/**
+ * The contents of CResult_ChannelTypeFeaturesDecodeErrorZ
+ */
+typedef union LDKCResult_ChannelTypeFeaturesDecodeErrorZPtr {
/**
- * Serialize the object into a byte array
+ * A pointer to the contents in the success state.
+ * Reading from this pointer when `result_ok` is not set is undefined.
*/
- struct LDKCVec_u8Z (*write)(const void *this_arg);
+ struct LDKChannelTypeFeatures *result;
/**
- * Called, if set, after this Sign has been cloned into a duplicate object.
- * The new Sign is provided, and should be mutated as needed to perform a
- * deep copy of the object pointed to by this_arg or avoid any double-freeing.
+ * A pointer to the contents in the error state.
+ * Reading from this pointer when `result_ok` is set is undefined.
*/
- void (*cloned)(struct LDKSign *NONNULL_PTR new_Sign);
+ struct LDKDecodeError *err;
+} LDKCResult_ChannelTypeFeaturesDecodeErrorZPtr;
+
+/**
+ * A CResult_ChannelTypeFeaturesDecodeErrorZ represents the result of a fallible operation,
+ * containing a crate::lightning::ln::features::ChannelTypeFeatures 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_ChannelTypeFeaturesDecodeErrorZ {
/**
- * Frees any resources associated with this object given its this_arg pointer.
- * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
+ * The contents of this CResult_ChannelTypeFeaturesDecodeErrorZ, accessible via either
+ * `err` or `result` depending on the state of `result_ok`.
*/
- void (*free)(void *this_arg);
-} LDKSign;
+ union LDKCResult_ChannelTypeFeaturesDecodeErrorZPtr contents;
+ /**
+ * Whether this CResult_ChannelTypeFeaturesDecodeErrorZ represents a success state.
+ */
+ bool result_ok;
+} LDKCResult_ChannelTypeFeaturesDecodeErrorZ;
/**
- * The contents of CResult_SignDecodeErrorZ
+ * The contents of CResult_DelayedPaymentOutputDescriptorDecodeErrorZ
*/
-typedef union LDKCResult_SignDecodeErrorZPtr {
+typedef union LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZPtr {
/**
* A pointer to the contents in the success state.
* Reading from this pointer when `result_ok` is not set is undefined.
*/
- struct LDKSign *result;
+ struct LDKDelayedPaymentOutputDescriptor *result;
/**
* A pointer to the contents in the error state.
* Reading from this pointer when `result_ok` is set is undefined.
*/
struct LDKDecodeError *err;
-} LDKCResult_SignDecodeErrorZPtr;
+} LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZPtr;
/**
- * A CResult_SignDecodeErrorZ represents the result of a fallible operation,
- * containing a crate::lightning::chain::keysinterface::Sign on success and a crate::lightning::ln::msgs::DecodeError on failure.
+ * A CResult_DelayedPaymentOutputDescriptorDecodeErrorZ represents the result of a fallible operation,
+ * containing a crate::lightning::chain::keysinterface::DelayedPaymentOutputDescriptor on success and a crate::lightning::ln::msgs::DecodeError on failure.
* `result_ok` indicates the overall state, and the contents are provided via `contents`.
*/
-typedef struct LDKCResult_SignDecodeErrorZ {
+typedef struct LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ {
/**
- * The contents of this CResult_SignDecodeErrorZ, accessible via either
+ * The contents of this CResult_DelayedPaymentOutputDescriptorDecodeErrorZ, accessible via either
* `err` or `result` depending on the state of `result_ok`.
*/
- union LDKCResult_SignDecodeErrorZPtr contents;
+ union LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZPtr contents;
/**
- * Whether this CResult_SignDecodeErrorZ represents a success state.
+ * Whether this CResult_DelayedPaymentOutputDescriptorDecodeErrorZ represents a success state.
*/
bool result_ok;
-} LDKCResult_SignDecodeErrorZ;
+} LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ;
/**
- * Represents a secp256k1 signature serialized as two 32-byte numbers as well as a tag which
- * allows recovering the exact public key which created the signature given the message.
+ * The contents of CResult_StaticPaymentOutputDescriptorDecodeErrorZ
*/
-typedef struct LDKRecoverableSignature {
+typedef union LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZPtr {
/**
- * The bytes of the signature in "compact" form plus a "Recovery ID" which allows for
- * recovery.
+ * A pointer to the contents in the success state.
+ * Reading from this pointer when `result_ok` is not set is undefined.
*/
- uint8_t serialized_form[68];
-} LDKRecoverableSignature;
+ struct LDKStaticPaymentOutputDescriptor *result;
+ /**
+ * A pointer to the contents in the error state.
+ * Reading from this pointer when `result_ok` is set is undefined.
+ */
+ struct LDKDecodeError *err;
+} LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZPtr;
/**
- * The contents of CResult_RecoverableSignatureNoneZ
+ * A CResult_StaticPaymentOutputDescriptorDecodeErrorZ represents the result of a fallible operation,
+ * containing a crate::lightning::chain::keysinterface::StaticPaymentOutputDescriptor on success and a crate::lightning::ln::msgs::DecodeError on failure.
+ * `result_ok` indicates the overall state, and the contents are provided via `contents`.
*/
-typedef union LDKCResult_RecoverableSignatureNoneZPtr {
+typedef struct LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ {
+ /**
+ * The contents of this CResult_StaticPaymentOutputDescriptorDecodeErrorZ, accessible via either
+ * `err` or `result` depending on the state of `result_ok`.
+ */
+ union LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZPtr contents;
+ /**
+ * Whether this CResult_StaticPaymentOutputDescriptorDecodeErrorZ represents a success state.
+ */
+ bool result_ok;
+} LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ;
+
+/**
+ * The contents of CResult_SpendableOutputDescriptorDecodeErrorZ
+ */
+typedef union LDKCResult_SpendableOutputDescriptorDecodeErrorZPtr {
/**
* A pointer to the contents in the success state.
* Reading from this pointer when `result_ok` is not set is undefined.
*/
- struct LDKRecoverableSignature *result;
+ struct LDKSpendableOutputDescriptor *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_SpendableOutputDescriptorDecodeErrorZPtr;
+
+/**
+ * A CResult_SpendableOutputDescriptorDecodeErrorZ represents the result of a fallible operation,
+ * containing a crate::lightning::chain::keysinterface::SpendableOutputDescriptor on success and a crate::lightning::ln::msgs::DecodeError on failure.
+ * `result_ok` indicates the overall state, and the contents are provided via `contents`.
+ */
+typedef struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ {
+ /**
+ * The contents of this CResult_SpendableOutputDescriptorDecodeErrorZ, accessible via either
+ * `err` or `result` depending on the state of `result_ok`.
+ */
+ union LDKCResult_SpendableOutputDescriptorDecodeErrorZPtr contents;
+ /**
+ * Whether this CResult_SpendableOutputDescriptorDecodeErrorZ represents a success state.
+ */
+ bool result_ok;
+} LDKCResult_SpendableOutputDescriptorDecodeErrorZ;
+
+/**
+ * The contents of CResult_NoneNoneZ
+ */
+typedef union LDKCResult_NoneNoneZPtr {
+ /**
+ * Note that this value is always NULL, as there are no contents in the OK variant
+ */
+ void *result;
/**
* Note that this value is always NULL, as there are no contents in the Err variant
*/
void *err;
-} LDKCResult_RecoverableSignatureNoneZPtr;
+} LDKCResult_NoneNoneZPtr;
/**
- * A CResult_RecoverableSignatureNoneZ represents the result of a fallible operation,
- * containing a crate::c_types::RecoverableSignature on success and a () on failure.
+ * A CResult_NoneNoneZ represents the result of a fallible operation,
+ * containing a () on success and a () on failure.
* `result_ok` indicates the overall state, and the contents are provided via `contents`.
*/
-typedef struct LDKCResult_RecoverableSignatureNoneZ {
+typedef struct LDKCResult_NoneNoneZ {
/**
- * The contents of this CResult_RecoverableSignatureNoneZ, accessible via either
+ * The contents of this CResult_NoneNoneZ, accessible via either
* `err` or `result` depending on the state of `result_ok`.
*/
- union LDKCResult_RecoverableSignatureNoneZPtr contents;
+ union LDKCResult_NoneNoneZPtr contents;
/**
- * Whether this CResult_RecoverableSignatureNoneZ represents a success state.
+ * Whether this CResult_NoneNoneZ represents a success state.
*/
bool result_ok;
-} LDKCResult_RecoverableSignatureNoneZ;
+} LDKCResult_NoneNoneZ;
/**
- * A dynamically-allocated array of crate::c_types::derived::CVec_u8Zs of arbitrary size.
- * This corresponds to std::vector in C++
+ * A tuple of 2 elements. See the individual fields for the types contained.
*/
-typedef struct LDKCVec_CVec_u8ZZ {
+typedef struct LDKC2Tuple_SignatureCVec_SignatureZZ {
/**
- * The elements in the array.
- * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc().
+ * The element at position 0
*/
- struct LDKCVec_u8Z *data;
+ struct LDKSignature a;
/**
- * The number of elements pointed to by `data`.
+ * The element at position 1
*/
- uintptr_t datalen;
-} LDKCVec_CVec_u8ZZ;
+ struct LDKCVec_SignatureZ b;
+} LDKC2Tuple_SignatureCVec_SignatureZZ;
+
+/**
+ * The contents of CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ
+ */
+typedef union LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr {
+ /**
+ * A pointer to the contents in the success state.
+ * Reading from this pointer when `result_ok` is not set is undefined.
+ */
+ struct LDKC2Tuple_SignatureCVec_SignatureZZ *result;
+ /**
+ * Note that this value is always NULL, as there are no contents in the Err variant
+ */
+ void *err;
+} LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr;
+
+/**
+ * A CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ represents the result of a fallible operation,
+ * containing a crate::c_types::derived::C2Tuple_SignatureCVec_SignatureZZ on success and a () on failure.
+ * `result_ok` indicates the overall state, and the contents are provided via `contents`.
+ */
+typedef struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ {
+ /**
+ * The contents of this CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ, accessible via either
+ * `err` or `result` depending on the state of `result_ok`.
+ */
+ union LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr contents;
+ /**
+ * Whether this CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ represents a success state.
+ */
+ bool result_ok;
+} LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ;
/**
- * The contents of CResult_CVec_CVec_u8ZZNoneZ
+ * The contents of CResult_SignatureNoneZ
*/
-typedef union LDKCResult_CVec_CVec_u8ZZNoneZPtr {
+typedef union LDKCResult_SignatureNoneZPtr {
/**
* A pointer to the contents in the success state.
* Reading from this pointer when `result_ok` is not set is undefined.
*/
- struct LDKCVec_CVec_u8ZZ *result;
+ struct LDKSignature *result;
/**
* Note that this value is always NULL, as there are no contents in the Err variant
*/
void *err;
-} LDKCResult_CVec_CVec_u8ZZNoneZPtr;
+} LDKCResult_SignatureNoneZPtr;
/**
- * A CResult_CVec_CVec_u8ZZNoneZ represents the result of a fallible operation,
- * containing a crate::c_types::derived::CVec_CVec_u8ZZ on success and a () on failure.
+ * A CResult_SignatureNoneZ represents the result of a fallible operation,
+ * containing a crate::c_types::Signature on success and a () on failure.
* `result_ok` indicates the overall state, and the contents are provided via `contents`.
*/
-typedef struct LDKCResult_CVec_CVec_u8ZZNoneZ {
+typedef struct LDKCResult_SignatureNoneZ {
/**
- * The contents of this CResult_CVec_CVec_u8ZZNoneZ, accessible via either
+ * The contents of this CResult_SignatureNoneZ, accessible via either
* `err` or `result` depending on the state of `result_ok`.
*/
- union LDKCResult_CVec_CVec_u8ZZNoneZPtr contents;
+ union LDKCResult_SignatureNoneZPtr contents;
/**
- * Whether this CResult_CVec_CVec_u8ZZNoneZ represents a success state.
+ * Whether this CResult_SignatureNoneZ represents a success state.
*/
bool result_ok;
-} LDKCResult_CVec_CVec_u8ZZNoneZ;
+} LDKCResult_SignatureNoneZ;
/**
- * A simple implementation of Sign that just keeps the private keys in memory.
+ * This class tracks the per-transaction information needed to build a closing transaction and will
+ * actually build it and sign.
*
- * This implementation performs no policy checks and is insufficient by itself as
- * a secure external signer.
+ * This class can be used inside a signer implementation to generate a signature given the relevant
+ * secret key.
*/
-typedef struct MUST_USE_STRUCT LDKInMemorySigner {
+typedef struct MUST_USE_STRUCT LDKClosingTransaction {
/**
* A pointer to the opaque Rust object.
* Nearly everywhere, inner must be non-null, however in places where
* the Rust equivalent takes an Option, it may be set to null to indicate None.
*/
- LDKnativeInMemorySigner *inner;
+ LDKnativeClosingTransaction *inner;
/**
* Indicates that this is the only struct which contains the same pointer.
* Rust functions which take ownership of an object provided via an argument require
* this to be true and invalidate the object pointed to by inner.
*/
bool is_owned;
-} LDKInMemorySigner;
+} LDKClosingTransaction;
+
+
/**
- * The contents of CResult_InMemorySignerDecodeErrorZ
+ * The unsigned part of a channel_announcement
*/
-typedef union LDKCResult_InMemorySignerDecodeErrorZPtr {
+typedef struct MUST_USE_STRUCT LDKUnsignedChannelAnnouncement {
/**
- * A pointer to the contents in the success state.
- * Reading from this pointer when `result_ok` is not set is undefined.
+ * A pointer to the opaque Rust object.
+ * Nearly everywhere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
*/
- struct LDKInMemorySigner *result;
+ LDKnativeUnsignedChannelAnnouncement *inner;
/**
- * A pointer to the contents in the error state.
- * Reading from this pointer when `result_ok` is set is undefined.
+ * Indicates that this is the only struct which contains the same pointer.
+ * Rust functions which take ownership of an object provided via an argument require
+ * this to be true and invalidate the object pointed to by inner.
*/
- struct LDKDecodeError *err;
-} LDKCResult_InMemorySignerDecodeErrorZPtr;
+ bool is_owned;
+} LDKUnsignedChannelAnnouncement;
/**
- * A CResult_InMemorySignerDecodeErrorZ represents the result of a fallible operation,
- * containing a crate::lightning::chain::keysinterface::InMemorySigner on success and a crate::lightning::ln::msgs::DecodeError on failure.
- * `result_ok` indicates the overall state, and the contents are provided via `contents`.
+ * A trait to sign lightning channel transactions as described in BOLT 3.
+ *
+ * Signing services could be implemented on a hardware wallet. In this case,
+ * the current Sign would be a front-end on top of a communication
+ * channel connected to your secure device and lightning key material wouldn't
+ * reside on a hot server. Nevertheless, a this deployment would still need
+ * to trust the ChannelManager to avoid loss of funds as this latest component
+ * could ask to sign commitment transaction with HTLCs paying to attacker pubkeys.
+ *
+ * A more secure iteration would be to use hashlock (or payment points) to pair
+ * invoice/incoming HTLCs with outgoing HTLCs to implement a no-trust-ChannelManager
+ * at the price of more state and computation on the hardware wallet side. In the future,
+ * we are looking forward to design such interface.
+ *
+ * In any case, ChannelMonitor or fallback watchtowers are always going to be trusted
+ * to act, as liveness and breach reply correctness are always going to be hard requirements
+ * of LN security model, orthogonal of key management issues.
*/
-typedef struct LDKCResult_InMemorySignerDecodeErrorZ {
+typedef struct LDKBaseSign {
/**
- * The contents of this CResult_InMemorySignerDecodeErrorZ, accessible via either
- * `err` or `result` depending on the state of `result_ok`.
+ * An opaque pointer which is passed to your function implementations as an argument.
+ * This has no meaning in the LDK, and can be NULL or any other value.
*/
- union LDKCResult_InMemorySignerDecodeErrorZPtr contents;
+ void *this_arg;
/**
- * Whether this CResult_InMemorySignerDecodeErrorZ represents a success state.
+ * Gets the per-commitment point for a specific commitment number
+ *
+ * Note that the commitment number starts at (1 << 48) - 1 and counts backwards.
*/
- bool result_ok;
-} LDKCResult_InMemorySignerDecodeErrorZ;
-
-/**
- * A dynamically-allocated array of crate::c_types::TxOuts of arbitrary size.
- * This corresponds to std::vector in C++
- */
-typedef struct LDKCVec_TxOutZ {
+ struct LDKPublicKey (*get_per_commitment_point)(const void *this_arg, uint64_t idx);
/**
- * The elements in the array.
- * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc().
+ * Gets the commitment secret for a specific commitment number as part of the revocation process
+ *
+ * An external signer implementation should error here if the commitment was already signed
+ * and should refuse to sign it in the future.
+ *
+ * May be called more than once for the same index.
+ *
+ * Note that the commitment number starts at (1 << 48) - 1 and counts backwards.
*/
- struct LDKTxOut *data;
+ struct LDKThirtyTwoBytes (*release_commitment_secret)(const void *this_arg, uint64_t idx);
/**
- * The number of elements pointed to by `data`.
+ * Validate the counterparty's signatures on the holder commitment transaction and HTLCs.
+ *
+ * This is required in order for the signer to make sure that releasing a commitment
+ * secret won't leave us without a broadcastable holder transaction.
+ * Policy checks should be implemented in this function, including checking the amount
+ * sent to us and checking the HTLCs.
*/
- uintptr_t datalen;
-} LDKCVec_TxOutZ;
-
-/**
- * The contents of CResult_TransactionNoneZ
- */
-typedef union LDKCResult_TransactionNoneZPtr {
+ struct LDKCResult_NoneNoneZ (*validate_holder_commitment)(const void *this_arg, const struct LDKHolderCommitmentTransaction *NONNULL_PTR holder_tx);
/**
- * A pointer to the contents in the success state.
- * Reading from this pointer when `result_ok` is not set is undefined.
+ * Gets the holder's channel public keys and basepoints
*/
- struct LDKTransaction *result;
+ struct LDKChannelPublicKeys pubkeys;
/**
- * Note that this value is always NULL, as there are no contents in the Err variant
+ * Fill in the pubkeys field as a reference to it will be given to Rust after this returns
+ * Note that this takes a pointer to this object, not the this_ptr like other methods do
+ * This function pointer may be NULL if pubkeys is filled in when this object is created and never needs updating.
*/
- void *err;
-} LDKCResult_TransactionNoneZPtr;
-
-/**
- * A CResult_TransactionNoneZ represents the result of a fallible operation,
- * containing a crate::c_types::Transaction on success and a () on failure.
- * `result_ok` indicates the overall state, and the contents are provided via `contents`.
- */
-typedef struct LDKCResult_TransactionNoneZ {
+ void (*set_pubkeys)(const struct LDKBaseSign*NONNULL_PTR );
/**
- * The contents of this CResult_TransactionNoneZ, accessible via either
- * `err` or `result` depending on the state of `result_ok`.
+ * Gets an arbitrary identifier describing the set of keys which are provided back to you in
+ * some SpendableOutputDescriptor types. This should be sufficient to identify this
+ * Sign object uniquely and lookup or re-derive its keys.
+ */
+ struct LDKThirtyTwoBytes (*channel_keys_id)(const void *this_arg);
+ /**
+ * Create a signature for a counterparty's commitment transaction and associated HTLC transactions.
+ *
+ * Note that if signing fails or is rejected, the channel will be force-closed.
+ *
+ * Policy checks should be implemented in this function, including checking the amount
+ * sent to us and checking the HTLCs.
+ */
+ struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ (*sign_counterparty_commitment)(const void *this_arg, const struct LDKCommitmentTransaction *NONNULL_PTR commitment_tx);
+ /**
+ * Validate the counterparty's revocation.
+ *
+ * This is required in order for the signer to make sure that the state has moved
+ * forward and it is safe to sign the next counterparty commitment.
+ */
+ struct LDKCResult_NoneNoneZ (*validate_counterparty_revocation)(const void *this_arg, uint64_t idx, const uint8_t (*secret)[32]);
+ /**
+ * Create a signatures for a holder's commitment transaction and its claiming HTLC transactions.
+ * This will only ever be called with a non-revoked commitment_tx. This will be called with the
+ * latest commitment_tx when we initiate a force-close.
+ * This will be called with the previous latest, just to get claiming HTLC signatures, if we are
+ * reacting to a ChannelMonitor replica that decided to broadcast before it had been updated to
+ * the latest.
+ * This may be called multiple times for the same transaction.
+ *
+ * An external signer implementation should check that the commitment has not been revoked.
+ *
+ * May return Err if key derivation fails. Callers, such as ChannelMonitor, will panic in such a case.
+ */
+ struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ (*sign_holder_commitment_and_htlcs)(const void *this_arg, const struct LDKHolderCommitmentTransaction *NONNULL_PTR commitment_tx);
+ /**
+ * Create a signature for the given input in a transaction spending an HTLC transaction output
+ * or a commitment transaction `to_local` output when our counterparty broadcasts an old state.
+ *
+ * A justice transaction may claim multiple outputs at the same time if timelocks are
+ * similar, but only a signature for the input at index `input` should be signed for here.
+ * It may be called multiple times for same output(s) if a fee-bump is needed with regards
+ * to an upcoming timelock expiration.
+ *
+ * Amount is value of the output spent by this input, committed to in the BIP 143 signature.
+ *
+ * per_commitment_key is revocation secret which was provided by our counterparty when they
+ * revoked the state which they eventually broadcast. It's not a _holder_ secret key and does
+ * not allow the spending of any funds by itself (you need our holder revocation_secret to do
+ * so).
+ */
+ struct LDKCResult_SignatureNoneZ (*sign_justice_revoked_output)(const void *this_arg, struct LDKTransaction justice_tx, uintptr_t input, uint64_t amount, const uint8_t (*per_commitment_key)[32]);
+ /**
+ * Create a signature for the given input in a transaction spending a commitment transaction
+ * HTLC output when our counterparty broadcasts an old state.
+ *
+ * A justice transaction may claim multiple outputs at the same time if timelocks are
+ * similar, but only a signature for the input at index `input` should be signed for here.
+ * It may be called multiple times for same output(s) if a fee-bump is needed with regards
+ * to an upcoming timelock expiration.
+ *
+ * Amount is value of the output spent by this input, committed to in the BIP 143 signature.
+ *
+ * per_commitment_key is revocation secret which was provided by our counterparty when they
+ * revoked the state which they eventually broadcast. It's not a _holder_ secret key and does
+ * not allow the spending of any funds by itself (you need our holder revocation_secret to do
+ * so).
+ *
+ * htlc holds HTLC elements (hash, timelock), thus changing the format of the witness script
+ * (which is committed to in the BIP 143 signatures).
+ */
+ struct LDKCResult_SignatureNoneZ (*sign_justice_revoked_htlc)(const void *this_arg, struct LDKTransaction justice_tx, uintptr_t input, uint64_t amount, const uint8_t (*per_commitment_key)[32], const struct LDKHTLCOutputInCommitment *NONNULL_PTR htlc);
+ /**
+ * Create a signature for a claiming transaction for a HTLC output on a counterparty's commitment
+ * transaction, either offered or received.
+ *
+ * Such a transaction may claim multiples offered outputs at same time if we know the
+ * preimage for each when we create it, but only the input at index `input` should be
+ * signed for here. It may be called multiple times for same output(s) if a fee-bump is
+ * needed with regards to an upcoming timelock expiration.
+ *
+ * Witness_script is either a offered or received script as defined in BOLT3 for HTLC
+ * outputs.
+ *
+ * Amount is value of the output spent by this input, committed to in the BIP 143 signature.
+ *
+ * Per_commitment_point is the dynamic point corresponding to the channel state
+ * detected onchain. It has been generated by our counterparty and is used to derive
+ * channel state keys, which are then included in the witness script and committed to in the
+ * BIP 143 signature.
+ */
+ struct LDKCResult_SignatureNoneZ (*sign_counterparty_htlc_transaction)(const void *this_arg, struct LDKTransaction htlc_tx, uintptr_t input, uint64_t amount, struct LDKPublicKey per_commitment_point, const struct LDKHTLCOutputInCommitment *NONNULL_PTR htlc);
+ /**
+ * Create a signature for a (proposed) closing transaction.
+ *
+ * Note that, due to rounding, there may be one \"missing\" satoshi, and either party may have
+ * chosen to forgo their output as dust.
+ */
+ struct LDKCResult_SignatureNoneZ (*sign_closing_transaction)(const void *this_arg, const struct LDKClosingTransaction *NONNULL_PTR closing_tx);
+ /**
+ * Signs a channel announcement message with our funding key, proving it comes from one
+ * of the channel participants.
+ *
+ * Note that if this fails or is rejected, the channel will not be publicly announced and
+ * our counterparty may (though likely will not) close the channel on us for violating the
+ * protocol.
+ */
+ struct LDKCResult_SignatureNoneZ (*sign_channel_announcement)(const void *this_arg, const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR msg);
+ /**
+ * Set the counterparty static channel data, including basepoints,
+ * counterparty_selected/holder_selected_contest_delay and funding outpoint.
+ * This is done as soon as the funding outpoint is known. Since these are static channel data,
+ * they MUST NOT be allowed to change to different values once set.
+ *
+ * channel_parameters.is_populated() MUST be true.
+ *
+ * We bind holder_selected_contest_delay late here for API convenience.
+ *
+ * Will be called before any signatures are applied.
*/
- union LDKCResult_TransactionNoneZPtr contents;
+ void (*ready_channel)(void *this_arg, const struct LDKChannelTransactionParameters *NONNULL_PTR channel_parameters);
/**
- * Whether this CResult_TransactionNoneZ represents a success state.
+ * Frees any resources associated with this object given its this_arg pointer.
+ * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
*/
- bool result_ok;
-} LDKCResult_TransactionNoneZ;
-
-
+ void (*free)(void *this_arg);
+} LDKBaseSign;
/**
- * A ChannelMonitor handles chain events (blocks connected and disconnected) and generates
- * on-chain transactions to ensure no loss of funds occurs.
- *
- * You MUST ensure that no ChannelMonitors for a given channel anywhere contain out-of-date
- * information and are actively monitoring the chain.
- *
- * Pending Events or updated HTLCs which have not yet been read out by
- * get_and_clear_pending_monitor_events or get_and_clear_pending_events are serialized to disk and
- * reloaded at deserialize-time. Thus, you must ensure that, when handling events, all events
- * gotten are fully handled before re-serializing the new state.
+ * A cloneable signer.
*
- * Note that the deserializer is only implemented for (BlockHash, ChannelMonitor), which
- * tells you the last block hash which was block_connect()ed. You MUST rescan any blocks along
- * the \"reorg path\" (ie disconnecting blocks until you find a common ancestor from both the
- * returned block hash and the the current chain and then reconnecting blocks to get to the
- * best chain) upon deserializing the object!
+ * Although we require signers to be cloneable, it may be useful for developers to be able to use
+ * signers in an un-sized way, for example as `dyn BaseSign`. Therefore we separate the Clone trait,
+ * which implies Sized, into this derived trait.
*/
-typedef struct MUST_USE_STRUCT LDKChannelMonitor {
- /**
- * A pointer to the opaque Rust object.
- * Nearly everywhere, inner must be non-null, however in places where
- * the Rust equivalent takes an Option, it may be set to null to indicate None.
- */
- LDKnativeChannelMonitor *inner;
+typedef struct LDKSign {
/**
- * Indicates that this is the only struct which contains the same pointer.
- * Rust functions which take ownership of an object provided via an argument require
- * this to be true and invalidate the object pointed to by inner.
+ * An opaque pointer which is passed to your function implementations as an argument.
+ * This has no meaning in the LDK, and can be NULL or any other value.
*/
- bool is_owned;
-} LDKChannelMonitor;
-
-/**
- * A tuple of 2 elements. See the individual fields for the types contained.
- */
-typedef struct LDKC2Tuple_BlockHashChannelMonitorZ {
+ void *this_arg;
/**
- * The element at position 0
+ * Implementation of BaseSign for this object.
*/
- struct LDKThirtyTwoBytes a;
+ struct LDKBaseSign BaseSign;
/**
- * The element at position 1
+ * Serialize the object into a byte array
*/
- struct LDKChannelMonitor b;
-} LDKC2Tuple_BlockHashChannelMonitorZ;
-
-/**
- * A dynamically-allocated array of crate::c_types::derived::C2Tuple_BlockHashChannelMonitorZs of arbitrary size.
- * This corresponds to std::vector in C++
- */
-typedef struct LDKCVec_C2Tuple_BlockHashChannelMonitorZZ {
+ struct LDKCVec_u8Z (*write)(const void *this_arg);
/**
- * The elements in the array.
- * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc().
+ * Called, if set, after this Sign has been cloned into a duplicate object.
+ * The new Sign is provided, and should be mutated as needed to perform a
+ * deep copy of the object pointed to by this_arg or avoid any double-freeing.
*/
- struct LDKC2Tuple_BlockHashChannelMonitorZ *data;
+ void (*cloned)(struct LDKSign *NONNULL_PTR new_Sign);
/**
- * The number of elements pointed to by `data`.
+ * 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.
*/
- uintptr_t datalen;
-} LDKCVec_C2Tuple_BlockHashChannelMonitorZZ;
+ void (*free)(void *this_arg);
+} LDKSign;
/**
- * The contents of CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ
+ * The contents of CResult_SignDecodeErrorZ
*/
-typedef union LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZPtr {
+typedef union LDKCResult_SignDecodeErrorZPtr {
/**
* A pointer to the contents in the success state.
* Reading from this pointer when `result_ok` is not set is undefined.
*/
- struct LDKCVec_C2Tuple_BlockHashChannelMonitorZZ *result;
+ struct LDKSign *result;
/**
* A pointer to the contents in the error state.
* Reading from this pointer when `result_ok` is set is undefined.
*/
- enum LDKIOError *err;
-} LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZPtr;
+ struct LDKDecodeError *err;
+} LDKCResult_SignDecodeErrorZPtr;
/**
- * A CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ represents the result of a fallible operation,
- * containing a crate::c_types::derived::CVec_C2Tuple_BlockHashChannelMonitorZZ on success and a crate::c_types::IOError on failure.
+ * A CResult_SignDecodeErrorZ represents the result of a fallible operation,
+ * containing a crate::lightning::chain::keysinterface::Sign on success and a crate::lightning::ln::msgs::DecodeError on failure.
* `result_ok` indicates the overall state, and the contents are provided via `contents`.
*/
-typedef struct LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ {
+typedef struct LDKCResult_SignDecodeErrorZ {
/**
- * The contents of this CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ, accessible via either
+ * The contents of this CResult_SignDecodeErrorZ, accessible via either
* `err` or `result` depending on the state of `result_ok`.
*/
- union LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZPtr contents;
+ union LDKCResult_SignDecodeErrorZPtr contents;
/**
- * Whether this CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ represents a success state.
+ * Whether this CResult_SignDecodeErrorZ represents a success state.
*/
bool result_ok;
-} LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ;
+} LDKCResult_SignDecodeErrorZ;
/**
- * An enum which can either contain a u16 or not
+ * Represents a secp256k1 signature serialized as two 32-byte numbers as well as a tag which
+ * allows recovering the exact public key which created the signature given the message.
*/
-typedef 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,
+typedef struct LDKRecoverableSignature {
/**
- * Must be last for serialization purposes
+ * The bytes of the signature in "compact" form plus a "Recovery ID" which allows for
+ * recovery.
*/
- LDKCOption_u16Z_Sentinel,
-} LDKCOption_u16Z_Tag;
-
-typedef struct LDKCOption_u16Z {
- LDKCOption_u16Z_Tag tag;
- union {
- struct {
- uint16_t some;
- };
- };
-} LDKCOption_u16Z;
+ uint8_t serialized_form[68];
+} LDKRecoverableSignature;
/**
- * Indicates an error on the client's part (usually some variant of attempting to use too-low or
- * too-high values)
+ * The contents of CResult_RecoverableSignatureNoneZ
*/
-typedef enum LDKAPIError_Tag {
- /**
- * Indicates the API was wholly misused (see err for more). Cases where these can be returned
- * are documented, but generally indicates some precondition of a function was violated.
- */
- LDKAPIError_APIMisuseError,
- /**
- * Due to a high feerate, we were unable to complete the request.
- * For example, this may be returned if the feerate implies we cannot open a channel at the
- * requested value, but opening a larger channel would succeed.
- */
- LDKAPIError_FeeRateTooHigh,
- /**
- * A malformed Route was provided (eg overflowed value, node id mismatch, overly-looped route,
- * too-many-hops, etc).
- */
- LDKAPIError_RouteError,
- /**
- * We were unable to complete the request as the Channel required to do so is unable to
- * complete the request (or was not found). This can take many forms, including disconnected
- * peer, channel at capacity, channel shutting down, etc.
- */
- LDKAPIError_ChannelUnavailable,
- /**
- * An attempt to call watch/update_channel returned an Err (ie you did this!), causing the
- * 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,
+typedef union LDKCResult_RecoverableSignatureNoneZPtr {
/**
- * Must be last for serialization purposes
+ * A pointer to the contents in the success state.
+ * Reading from this pointer when `result_ok` is not set is undefined.
*/
- LDKAPIError_Sentinel,
-} LDKAPIError_Tag;
-
-typedef struct LDKAPIError_LDKAPIMisuseError_Body {
+ struct LDKRecoverableSignature *result;
/**
- * A human-readable error message
+ * Note that this value is always NULL, as there are no contents in the Err variant
*/
- struct LDKStr err;
-} LDKAPIError_LDKAPIMisuseError_Body;
+ void *err;
+} LDKCResult_RecoverableSignatureNoneZPtr;
-typedef struct LDKAPIError_LDKFeeRateTooHigh_Body {
- /**
- * A human-readable error message
- */
- struct LDKStr err;
+/**
+ * A CResult_RecoverableSignatureNoneZ represents the result of a fallible operation,
+ * containing a crate::c_types::RecoverableSignature on success and a () on failure.
+ * `result_ok` indicates the overall state, and the contents are provided via `contents`.
+ */
+typedef struct LDKCResult_RecoverableSignatureNoneZ {
/**
- * The feerate which was too high.
+ * The contents of this CResult_RecoverableSignatureNoneZ, accessible via either
+ * `err` or `result` depending on the state of `result_ok`.
*/
- uint32_t feerate;
-} LDKAPIError_LDKFeeRateTooHigh_Body;
-
-typedef struct LDKAPIError_LDKRouteError_Body {
+ union LDKCResult_RecoverableSignatureNoneZPtr contents;
/**
- * A human-readable error message
+ * Whether this CResult_RecoverableSignatureNoneZ represents a success state.
*/
- struct LDKStr err;
-} LDKAPIError_LDKRouteError_Body;
+ bool result_ok;
+} LDKCResult_RecoverableSignatureNoneZ;
-typedef struct LDKAPIError_LDKChannelUnavailable_Body {
+/**
+ * A dynamically-allocated array of crate::c_types::derived::CVec_u8Zs of arbitrary size.
+ * This corresponds to std::vector in C++
+ */
+typedef struct LDKCVec_CVec_u8ZZ {
/**
- * A human-readable error message
+ * The elements in the array.
+ * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc().
*/
- struct LDKStr err;
-} LDKAPIError_LDKChannelUnavailable_Body;
-
-typedef struct LDKAPIError_LDKIncompatibleShutdownScript_Body {
+ struct LDKCVec_u8Z *data;
/**
- * The incompatible shutdown script.
+ * The number of elements pointed to by `data`.
*/
- struct LDKShutdownScript script;
-} LDKAPIError_LDKIncompatibleShutdownScript_Body;
-
-typedef struct MUST_USE_STRUCT LDKAPIError {
- LDKAPIError_Tag tag;
- union {
- LDKAPIError_LDKAPIMisuseError_Body api_misuse_error;
- LDKAPIError_LDKFeeRateTooHigh_Body fee_rate_too_high;
- LDKAPIError_LDKRouteError_Body route_error;
- LDKAPIError_LDKChannelUnavailable_Body channel_unavailable;
- LDKAPIError_LDKIncompatibleShutdownScript_Body incompatible_shutdown_script;
- };
-} LDKAPIError;
+ uintptr_t datalen;
+} LDKCVec_CVec_u8ZZ;
/**
- * The contents of CResult_NoneAPIErrorZ
+ * The contents of CResult_CVec_CVec_u8ZZNoneZ
*/
-typedef union LDKCResult_NoneAPIErrorZPtr {
+typedef union LDKCResult_CVec_CVec_u8ZZNoneZPtr {
/**
- * Note that this value is always NULL, as there are no contents in the OK variant
+ * A pointer to the contents in the success state.
+ * Reading from this pointer when `result_ok` is not set is undefined.
*/
- void *result;
+ struct LDKCVec_CVec_u8ZZ *result;
/**
- * A pointer to the contents in the error state.
- * Reading from this pointer when `result_ok` is set is undefined.
+ * Note that this value is always NULL, as there are no contents in the Err variant
*/
- struct LDKAPIError *err;
-} LDKCResult_NoneAPIErrorZPtr;
+ void *err;
+} LDKCResult_CVec_CVec_u8ZZNoneZPtr;
/**
- * A CResult_NoneAPIErrorZ represents the result of a fallible operation,
- * containing a () on success and a crate::lightning::util::errors::APIError on failure.
+ * A CResult_CVec_CVec_u8ZZNoneZ represents the result of a fallible operation,
+ * containing a crate::c_types::derived::CVec_CVec_u8ZZ on success and a () on failure.
* `result_ok` indicates the overall state, and the contents are provided via `contents`.
*/
-typedef struct LDKCResult_NoneAPIErrorZ {
+typedef struct LDKCResult_CVec_CVec_u8ZZNoneZ {
/**
- * The contents of this CResult_NoneAPIErrorZ, accessible via either
+ * The contents of this CResult_CVec_CVec_u8ZZNoneZ, accessible via either
* `err` or `result` depending on the state of `result_ok`.
*/
- union LDKCResult_NoneAPIErrorZPtr contents;
+ union LDKCResult_CVec_CVec_u8ZZNoneZPtr contents;
/**
- * Whether this CResult_NoneAPIErrorZ represents a success state.
+ * Whether this CResult_CVec_CVec_u8ZZNoneZ represents a success state.
*/
bool result_ok;
-} LDKCResult_NoneAPIErrorZ;
+} LDKCResult_CVec_CVec_u8ZZNoneZ;
+
-/**
- * A dynamically-allocated array of crate::c_types::derived::CResult_NoneAPIErrorZs of arbitrary size.
- * This corresponds to std::vector in C++
- */
-typedef struct LDKCVec_CResult_NoneAPIErrorZZ {
- /**
- * The elements in the array.
- * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc().
- */
- struct LDKCResult_NoneAPIErrorZ *data;
- /**
- * The number of elements pointed to by `data`.
- */
- uintptr_t datalen;
-} LDKCVec_CResult_NoneAPIErrorZZ;
/**
- * A dynamically-allocated array of crate::lightning::util::errors::APIErrors of arbitrary size.
- * This corresponds to std::vector in C++
+ * A simple implementation of Sign that just keeps the private keys in memory.
+ *
+ * This implementation performs no policy checks and is insufficient by itself as
+ * a secure external signer.
*/
-typedef struct LDKCVec_APIErrorZ {
+typedef struct MUST_USE_STRUCT LDKInMemorySigner {
/**
- * The elements in the array.
- * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc().
+ * A pointer to the opaque Rust object.
+ * Nearly everywhere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
*/
- struct LDKAPIError *data;
+ LDKnativeInMemorySigner *inner;
/**
- * The number of elements pointed to by `data`.
+ * Indicates that this is the only struct which contains the same pointer.
+ * Rust functions which take ownership of an object provided via an argument require
+ * this to be true and invalidate the object pointed to by inner.
*/
- uintptr_t datalen;
-} LDKCVec_APIErrorZ;
+ bool is_owned;
+} LDKInMemorySigner;
/**
- * The contents of CResult__u832APIErrorZ
+ * The contents of CResult_InMemorySignerDecodeErrorZ
*/
-typedef union LDKCResult__u832APIErrorZPtr {
+typedef union LDKCResult_InMemorySignerDecodeErrorZPtr {
/**
* A pointer to the contents in the success state.
* Reading from this pointer when `result_ok` is not set is undefined.
*/
- struct LDKThirtyTwoBytes *result;
+ struct LDKInMemorySigner *result;
/**
* A pointer to the contents in the error state.
* Reading from this pointer when `result_ok` is set is undefined.
*/
- struct LDKAPIError *err;
-} LDKCResult__u832APIErrorZPtr;
+ struct LDKDecodeError *err;
+} LDKCResult_InMemorySignerDecodeErrorZPtr;
/**
- * A CResult__u832APIErrorZ represents the result of a fallible operation,
- * containing a crate::c_types::ThirtyTwoBytes on success and a crate::lightning::util::errors::APIError on failure.
+ * A CResult_InMemorySignerDecodeErrorZ represents the result of a fallible operation,
+ * containing a crate::lightning::chain::keysinterface::InMemorySigner on success and a crate::lightning::ln::msgs::DecodeError on failure.
* `result_ok` indicates the overall state, and the contents are provided via `contents`.
*/
-typedef struct LDKCResult__u832APIErrorZ {
+typedef struct LDKCResult_InMemorySignerDecodeErrorZ {
/**
- * The contents of this CResult__u832APIErrorZ, accessible via either
+ * The contents of this CResult_InMemorySignerDecodeErrorZ, accessible via either
* `err` or `result` depending on the state of `result_ok`.
*/
- union LDKCResult__u832APIErrorZPtr contents;
+ union LDKCResult_InMemorySignerDecodeErrorZPtr contents;
/**
- * Whether this CResult__u832APIErrorZ represents a success state.
+ * Whether this CResult_InMemorySignerDecodeErrorZ represents a success state.
*/
bool result_ok;
-} LDKCResult__u832APIErrorZ;
+} LDKCResult_InMemorySignerDecodeErrorZ;
/**
- * If a payment fails to send, it can be in one of several states. This enum is returned as the
- * Err() type describing which state the payment is in, see the description of individual enum
- * states for more.
+ * A dynamically-allocated array of crate::c_types::TxOuts of arbitrary size.
+ * This corresponds to std::vector in C++
*/
-typedef enum LDKPaymentSendFailure_Tag {
+typedef struct LDKCVec_TxOutZ {
/**
- * A parameter which was passed to send_payment was invalid, preventing us from attempting to
- * send the payment at all. No channel state has been changed or messages sent to peers, and
- * once you've changed the parameter at error, you can freely retry the payment in full.
+ * The elements in the array.
+ * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc().
*/
- LDKPaymentSendFailure_ParameterError,
+ struct LDKTxOut *data;
/**
- * A parameter in a single path which was passed to send_payment was invalid, preventing us
- * from attempting to send the payment at all. No channel state has been changed or messages
- * sent to peers, and once you've changed the parameter at error, you can freely retry the
- * payment in full.
- *
- * The results here are ordered the same as the paths in the route object which was passed to
- * send_payment.
+ * The number of elements pointed to by `data`.
*/
- LDKPaymentSendFailure_PathParameterError,
+ uintptr_t datalen;
+} LDKCVec_TxOutZ;
+
+/**
+ * The contents of CResult_TransactionNoneZ
+ */
+typedef union LDKCResult_TransactionNoneZPtr {
/**
- * All paths which were attempted failed to send, with no channel state change taking place.
- * You can freely retry the payment in full (though you probably want to do so over different
- * paths than the ones selected).
+ * A pointer to the contents in the success state.
+ * Reading from this pointer when `result_ok` is not set is undefined.
*/
- LDKPaymentSendFailure_AllFailedRetrySafe,
+ struct LDKTransaction *result;
/**
- * Some paths which were attempted failed to send, though possibly not all. At least some
- * paths have irrevocably committed to the HTLC and retrying the payment in full would result
- * in over-/re-payment.
- *
- * The results here are ordered the same as the paths in the route object which was passed to
- * send_payment, and any Errs which are not APIError::MonitorUpdateFailed can be safely
- * retried (though there is currently no API with which to do so).
- *
- * Any entries which contain Err(APIError::MonitorUpdateFailed) or Ok(()) MUST NOT be retried
- * as they will result in over-/re-payment. These HTLCs all either successfully sent (in the
- * case of Ok(())) or will send once channel_monitor_updated is called on the next-hop channel
- * with the latest update_id.
+ * Note that this value is always NULL, as there are no contents in the Err variant
*/
- LDKPaymentSendFailure_PartialFailure,
+ void *err;
+} LDKCResult_TransactionNoneZPtr;
+
+/**
+ * A CResult_TransactionNoneZ represents the result of a fallible operation,
+ * containing a crate::c_types::Transaction on success and a () on failure.
+ * `result_ok` indicates the overall state, and the contents are provided via `contents`.
+ */
+typedef struct LDKCResult_TransactionNoneZ {
/**
- * Must be last for serialization purposes
+ * The contents of this CResult_TransactionNoneZ, accessible via either
+ * `err` or `result` depending on the state of `result_ok`.
*/
- LDKPaymentSendFailure_Sentinel,
-} LDKPaymentSendFailure_Tag;
-
-typedef struct LDKPaymentSendFailure_LDKPartialFailure_Body {
+ union LDKCResult_TransactionNoneZPtr contents;
/**
- * The errors themselves, in the same order as the route hops.
+ * Whether this CResult_TransactionNoneZ represents a success state.
*/
- struct LDKCVec_CResult_NoneAPIErrorZZ results;
+ bool result_ok;
+} LDKCResult_TransactionNoneZ;
+
+
+
+/**
+ * A ChannelMonitor handles chain events (blocks connected and disconnected) and generates
+ * on-chain transactions to ensure no loss of funds occurs.
+ *
+ * You MUST ensure that no ChannelMonitors for a given channel anywhere contain out-of-date
+ * information and are actively monitoring the chain.
+ *
+ * Pending Events or updated HTLCs which have not yet been read out by
+ * get_and_clear_pending_monitor_events or get_and_clear_pending_events are serialized to disk and
+ * reloaded at deserialize-time. Thus, you must ensure that, when handling events, all events
+ * gotten are fully handled before re-serializing the new state.
+ *
+ * Note that the deserializer is only implemented for (BlockHash, ChannelMonitor), which
+ * tells you the last block hash which was block_connect()ed. You MUST rescan any blocks along
+ * the \"reorg path\" (ie disconnecting blocks until you find a common ancestor from both the
+ * returned block hash and the the current chain and then reconnecting blocks to get to the
+ * best chain) upon deserializing the object!
+ */
+typedef struct MUST_USE_STRUCT LDKChannelMonitor {
/**
- * If some paths failed without irrevocably committing to the new HTLC(s), this will
- * contain a [`RouteParameters`] object which can be used to calculate a new route that
- * will pay all remaining unpaid balance.
- *
- * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
+ * A pointer to the opaque Rust object.
+ * Nearly everywhere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
*/
- struct LDKRouteParameters failed_paths_retry;
+ LDKnativeChannelMonitor *inner;
/**
- * The payment id for the payment, which is now at least partially pending.
+ * Indicates that this is the only struct which contains the same pointer.
+ * Rust functions which take ownership of an object provided via an argument require
+ * this to be true and invalidate the object pointed to by inner.
*/
- struct LDKThirtyTwoBytes payment_id;
-} LDKPaymentSendFailure_LDKPartialFailure_Body;
-
-typedef struct MUST_USE_STRUCT LDKPaymentSendFailure {
- LDKPaymentSendFailure_Tag tag;
- union {
- struct {
- struct LDKAPIError parameter_error;
- };
- struct {
- struct LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error;
- };
- struct {
- struct LDKCVec_APIErrorZ all_failed_retry_safe;
- };
- LDKPaymentSendFailure_LDKPartialFailure_Body partial_failure;
- };
-} LDKPaymentSendFailure;
+ bool is_owned;
+} LDKChannelMonitor;
/**
- * The contents of CResult_PaymentIdPaymentSendFailureZ
+ * A tuple of 2 elements. See the individual fields for the types contained.
*/
-typedef union LDKCResult_PaymentIdPaymentSendFailureZPtr {
+typedef struct LDKC2Tuple_BlockHashChannelMonitorZ {
/**
- * A pointer to the contents in the success state.
- * Reading from this pointer when `result_ok` is not set is undefined.
+ * The element at position 0
*/
- struct LDKThirtyTwoBytes *result;
+ struct LDKThirtyTwoBytes a;
/**
- * A pointer to the contents in the error state.
- * Reading from this pointer when `result_ok` is set is undefined.
+ * The element at position 1
*/
- struct LDKPaymentSendFailure *err;
-} LDKCResult_PaymentIdPaymentSendFailureZPtr;
+ struct LDKChannelMonitor b;
+} LDKC2Tuple_BlockHashChannelMonitorZ;
/**
- * A CResult_PaymentIdPaymentSendFailureZ represents the result of a fallible operation,
- * containing a crate::c_types::ThirtyTwoBytes on success and a crate::lightning::ln::channelmanager::PaymentSendFailure on failure.
- * `result_ok` indicates the overall state, and the contents are provided via `contents`.
+ * A dynamically-allocated array of crate::c_types::derived::C2Tuple_BlockHashChannelMonitorZs of arbitrary size.
+ * This corresponds to std::vector in C++
*/
-typedef struct LDKCResult_PaymentIdPaymentSendFailureZ {
+typedef struct LDKCVec_C2Tuple_BlockHashChannelMonitorZZ {
/**
- * The contents of this CResult_PaymentIdPaymentSendFailureZ, accessible via either
- * `err` or `result` depending on the state of `result_ok`.
+ * The elements in the array.
+ * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc().
*/
- union LDKCResult_PaymentIdPaymentSendFailureZPtr contents;
+ struct LDKC2Tuple_BlockHashChannelMonitorZ *data;
/**
- * Whether this CResult_PaymentIdPaymentSendFailureZ represents a success state.
+ * The number of elements pointed to by `data`.
*/
- bool result_ok;
-} LDKCResult_PaymentIdPaymentSendFailureZ;
+ uintptr_t datalen;
+} LDKCVec_C2Tuple_BlockHashChannelMonitorZZ;
/**
- * The contents of CResult_NonePaymentSendFailureZ
+ * The contents of CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ
*/
-typedef union LDKCResult_NonePaymentSendFailureZPtr {
+typedef union LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZPtr {
/**
- * Note that this value is always NULL, as there are no contents in the OK variant
+ * A pointer to the contents in the success state.
+ * Reading from this pointer when `result_ok` is not set is undefined.
*/
- void *result;
+ struct LDKCVec_C2Tuple_BlockHashChannelMonitorZZ *result;
/**
* A pointer to the contents in the error state.
* Reading from this pointer when `result_ok` is set is undefined.
*/
- struct LDKPaymentSendFailure *err;
-} LDKCResult_NonePaymentSendFailureZPtr;
+ enum LDKIOError *err;
+} LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZPtr;
/**
- * A CResult_NonePaymentSendFailureZ represents the result of a fallible operation,
- * containing a () on success and a crate::lightning::ln::channelmanager::PaymentSendFailure on failure.
+ * A CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ represents the result of a fallible operation,
+ * containing a crate::c_types::derived::CVec_C2Tuple_BlockHashChannelMonitorZZ on success and a crate::c_types::IOError on failure.
* `result_ok` indicates the overall state, and the contents are provided via `contents`.
*/
-typedef struct LDKCResult_NonePaymentSendFailureZ {
+typedef struct LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ {
/**
- * The contents of this CResult_NonePaymentSendFailureZ, accessible via either
+ * The contents of this CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ, accessible via either
* `err` or `result` depending on the state of `result_ok`.
*/
- union LDKCResult_NonePaymentSendFailureZPtr contents;
+ union LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZPtr contents;
/**
- * Whether this CResult_NonePaymentSendFailureZ represents a success state.
+ * Whether this CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ represents a success state.
*/
bool result_ok;
-} LDKCResult_NonePaymentSendFailureZ;
+} LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ;
/**
- * A tuple of 2 elements. See the individual fields for the types contained.
+ * An enum which can either contain a u16 or not
*/
-typedef struct LDKC2Tuple_PaymentHashPaymentIdZ {
+typedef enum LDKCOption_u16Z_Tag {
/**
- * The element at position 0
+ * When we're in this state, this COption_u16Z contains a u16
*/
- struct LDKThirtyTwoBytes a;
+ LDKCOption_u16Z_Some,
/**
- * The element at position 1
+ * When we're in this state, this COption_u16Z contains nothing
*/
- struct LDKThirtyTwoBytes b;
-} LDKC2Tuple_PaymentHashPaymentIdZ;
+ 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;
/**
- * The contents of CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ
+ * Indicates an error on the client's part (usually some variant of attempting to use too-low or
+ * too-high values)
*/
-typedef union LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZPtr {
+typedef enum LDKAPIError_Tag {
/**
- * A pointer to the contents in the success state.
- * Reading from this pointer when `result_ok` is not set is undefined.
+ * Indicates the API was wholly misused (see err for more). Cases where these can be returned
+ * are documented, but generally indicates some precondition of a function was violated.
*/
- struct LDKC2Tuple_PaymentHashPaymentIdZ *result;
+ LDKAPIError_APIMisuseError,
/**
- * A pointer to the contents in the error state.
- * Reading from this pointer when `result_ok` is set is undefined.
+ * Due to a high feerate, we were unable to complete the request.
+ * For example, this may be returned if the feerate implies we cannot open a channel at the
+ * requested value, but opening a larger channel would succeed.
*/
- struct LDKPaymentSendFailure *err;
-} LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZPtr;
+ LDKAPIError_FeeRateTooHigh,
+ /**
+ * A malformed Route was provided (eg overflowed value, node id mismatch, overly-looped route,
+ * too-many-hops, etc).
+ */
+ LDKAPIError_RouteError,
+ /**
+ * We were unable to complete the request as the Channel required to do so is unable to
+ * complete the request (or was not found). This can take many forms, including disconnected
+ * peer, channel at capacity, channel shutting down, etc.
+ */
+ LDKAPIError_ChannelUnavailable,
+ /**
+ * An attempt to call watch/update_channel returned an Err (ie you did this!), causing the
+ * 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
+ */
+ LDKAPIError_Sentinel,
+} LDKAPIError_Tag;
-/**
- * A CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ represents the result of a fallible operation,
- * containing a crate::c_types::derived::C2Tuple_PaymentHashPaymentIdZ on success and a crate::lightning::ln::channelmanager::PaymentSendFailure on failure.
- * `result_ok` indicates the overall state, and the contents are provided via `contents`.
- */
-typedef struct LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ {
+typedef struct LDKAPIError_LDKAPIMisuseError_Body {
/**
- * The contents of this CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ, accessible via either
- * `err` or `result` depending on the state of `result_ok`.
+ * A human-readable error message
*/
- union LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZPtr contents;
+ struct LDKStr err;
+} LDKAPIError_LDKAPIMisuseError_Body;
+
+typedef struct LDKAPIError_LDKFeeRateTooHigh_Body {
/**
- * Whether this CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ represents a success state.
+ * A human-readable error message
*/
- bool result_ok;
-} LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ;
+ struct LDKStr err;
+ /**
+ * The feerate which was too high.
+ */
+ uint32_t feerate;
+} LDKAPIError_LDKFeeRateTooHigh_Body;
-/**
- * A 4-byte byte array.
- */
-typedef struct LDKFourBytes {
+typedef struct LDKAPIError_LDKRouteError_Body {
/**
- * The four bytes
+ * A human-readable error message
*/
- uint8_t data[4];
-} LDKFourBytes;
+ struct LDKStr err;
+} LDKAPIError_LDKRouteError_Body;
-/**
- * A 16-byte byte array.
- */
-typedef struct LDKSixteenBytes {
+typedef struct LDKAPIError_LDKChannelUnavailable_Body {
/**
- * The sixteen bytes
+ * A human-readable error message
*/
- uint8_t data[16];
-} LDKSixteenBytes;
+ struct LDKStr err;
+} LDKAPIError_LDKChannelUnavailable_Body;
-/**
- * A 10-byte byte array.
- */
-typedef struct LDKTenBytes {
+typedef struct LDKAPIError_LDKIncompatibleShutdownScript_Body {
/**
- * The ten bytes
+ * The incompatible shutdown script.
*/
- uint8_t data[10];
-} LDKTenBytes;
+ struct LDKShutdownScript script;
+} LDKAPIError_LDKIncompatibleShutdownScript_Body;
+
+typedef struct MUST_USE_STRUCT LDKAPIError {
+ LDKAPIError_Tag tag;
+ union {
+ LDKAPIError_LDKAPIMisuseError_Body api_misuse_error;
+ LDKAPIError_LDKFeeRateTooHigh_Body fee_rate_too_high;
+ LDKAPIError_LDKRouteError_Body route_error;
+ LDKAPIError_LDKChannelUnavailable_Body channel_unavailable;
+ LDKAPIError_LDKIncompatibleShutdownScript_Body incompatible_shutdown_script;
+ };
+} LDKAPIError;
/**
- * An address which can be used to connect to a remote peer
+ * The contents of CResult_NoneAPIErrorZ
*/
-typedef enum LDKNetAddress_Tag {
+typedef union LDKCResult_NoneAPIErrorZPtr {
/**
- * An IPv4 address/port on which the peer is listening.
+ * Note that this value is always NULL, as there are no contents in the OK variant
*/
- LDKNetAddress_IPv4,
+ void *result;
/**
- * An IPv6 address/port on which the peer is listening.
+ * A pointer to the contents in the error state.
+ * Reading from this pointer when `result_ok` is set is undefined.
*/
- LDKNetAddress_IPv6,
+ struct LDKAPIError *err;
+} LDKCResult_NoneAPIErrorZPtr;
+
+/**
+ * A CResult_NoneAPIErrorZ represents the result of a fallible operation,
+ * containing a () on success and a crate::lightning::util::errors::APIError on failure.
+ * `result_ok` indicates the overall state, and the contents are provided via `contents`.
+ */
+typedef struct LDKCResult_NoneAPIErrorZ {
/**
- * An old-style Tor onion address/port on which the peer is listening.
+ * The contents of this CResult_NoneAPIErrorZ, accessible via either
+ * `err` or `result` depending on the state of `result_ok`.
*/
- LDKNetAddress_OnionV2,
+ union LDKCResult_NoneAPIErrorZPtr contents;
/**
- * A new-style Tor onion address/port on which the peer is listening.
- * To create the human-readable \"hostname\", concatenate ed25519_pubkey, checksum, and version,
- * wrap as base32 and append \".onion\".
+ * Whether this CResult_NoneAPIErrorZ represents a success state.
*/
- LDKNetAddress_OnionV3,
+ bool result_ok;
+} LDKCResult_NoneAPIErrorZ;
+
+/**
+ * A dynamically-allocated array of crate::c_types::derived::CResult_NoneAPIErrorZs of arbitrary size.
+ * This corresponds to std::vector in C++
+ */
+typedef struct LDKCVec_CResult_NoneAPIErrorZZ {
/**
- * Must be last for serialization purposes
+ * The elements in the array.
+ * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc().
*/
- LDKNetAddress_Sentinel,
-} LDKNetAddress_Tag;
+ struct LDKCResult_NoneAPIErrorZ *data;
+ /**
+ * The number of elements pointed to by `data`.
+ */
+ uintptr_t datalen;
+} LDKCVec_CResult_NoneAPIErrorZZ;
-typedef struct LDKNetAddress_LDKIPv4_Body {
+/**
+ * A dynamically-allocated array of crate::lightning::util::errors::APIErrors of arbitrary size.
+ * This corresponds to std::vector in C++
+ */
+typedef struct LDKCVec_APIErrorZ {
/**
- * The 4-byte IPv4 address
+ * The elements in the array.
+ * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc().
*/
- struct LDKFourBytes addr;
+ struct LDKAPIError *data;
/**
- * The port on which the node is listening
+ * The number of elements pointed to by `data`.
*/
- uint16_t port;
-} LDKNetAddress_LDKIPv4_Body;
+ uintptr_t datalen;
+} LDKCVec_APIErrorZ;
-typedef struct LDKNetAddress_LDKIPv6_Body {
+/**
+ * The contents of CResult__u832APIErrorZ
+ */
+typedef union LDKCResult__u832APIErrorZPtr {
/**
- * The 16-byte IPv6 address
+ * A pointer to the contents in the success state.
+ * Reading from this pointer when `result_ok` is not set is undefined.
*/
- struct LDKSixteenBytes addr;
+ struct LDKThirtyTwoBytes *result;
/**
- * The port on which the node is listening
+ * A pointer to the contents in the error state.
+ * Reading from this pointer when `result_ok` is set is undefined.
*/
- uint16_t port;
-} LDKNetAddress_LDKIPv6_Body;
+ struct LDKAPIError *err;
+} LDKCResult__u832APIErrorZPtr;
-typedef struct LDKNetAddress_LDKOnionV2_Body {
+/**
+ * A CResult__u832APIErrorZ represents the result of a fallible operation,
+ * containing a crate::c_types::ThirtyTwoBytes on success and a crate::lightning::util::errors::APIError on failure.
+ * `result_ok` indicates the overall state, and the contents are provided via `contents`.
+ */
+typedef struct LDKCResult__u832APIErrorZ {
/**
- * The bytes (usually encoded in base32 with \".onion\" appended)
+ * The contents of this CResult__u832APIErrorZ, accessible via either
+ * `err` or `result` depending on the state of `result_ok`.
*/
- struct LDKTenBytes addr;
+ union LDKCResult__u832APIErrorZPtr contents;
/**
- * The port on which the node is listening
+ * Whether this CResult__u832APIErrorZ represents a success state.
*/
- uint16_t port;
-} LDKNetAddress_LDKOnionV2_Body;
+ bool result_ok;
+} LDKCResult__u832APIErrorZ;
-typedef struct LDKNetAddress_LDKOnionV3_Body {
+/**
+ * If a payment fails to send, it can be in one of several states. This enum is returned as the
+ * Err() type describing which state the payment is in, see the description of individual enum
+ * states for more.
+ */
+typedef enum LDKPaymentSendFailure_Tag {
/**
- * The ed25519 long-term public key of the peer
+ * A parameter which was passed to send_payment was invalid, preventing us from attempting to
+ * send the payment at all. No channel state has been changed or messages sent to peers, and
+ * once you've changed the parameter at error, you can freely retry the payment in full.
*/
- struct LDKThirtyTwoBytes ed25519_pubkey;
+ LDKPaymentSendFailure_ParameterError,
/**
- * The checksum of the pubkey and version, as included in the onion address
+ * A parameter in a single path which was passed to send_payment was invalid, preventing us
+ * from attempting to send the payment at all. No channel state has been changed or messages
+ * sent to peers, and once you've changed the parameter at error, you can freely retry the
+ * payment in full.
+ *
+ * The results here are ordered the same as the paths in the route object which was passed to
+ * send_payment.
*/
- uint16_t checksum;
+ LDKPaymentSendFailure_PathParameterError,
/**
- * The version byte, as defined by the Tor Onion v3 spec.
+ * All paths which were attempted failed to send, with no channel state change taking place.
+ * You can freely retry the payment in full (though you probably want to do so over different
+ * paths than the ones selected).
*/
- uint8_t version;
+ LDKPaymentSendFailure_AllFailedRetrySafe,
/**
- * The port on which the node is listening
+ * Some paths which were attempted failed to send, though possibly not all. At least some
+ * paths have irrevocably committed to the HTLC and retrying the payment in full would result
+ * in over-/re-payment.
+ *
+ * The results here are ordered the same as the paths in the route object which was passed to
+ * send_payment, and any Errs which are not APIError::MonitorUpdateFailed can be safely
+ * retried (though there is currently no API with which to do so).
+ *
+ * Any entries which contain Err(APIError::MonitorUpdateFailed) or Ok(()) MUST NOT be retried
+ * as they will result in over-/re-payment. These HTLCs all either successfully sent (in the
+ * case of Ok(())) or will send once channel_monitor_updated is called on the next-hop channel
+ * with the latest update_id.
*/
- uint16_t port;
-} LDKNetAddress_LDKOnionV3_Body;
-
-typedef struct MUST_USE_STRUCT LDKNetAddress {
- LDKNetAddress_Tag tag;
- union {
- LDKNetAddress_LDKIPv4_Body i_pv4;
- LDKNetAddress_LDKIPv6_Body i_pv6;
- LDKNetAddress_LDKOnionV2_Body onion_v2;
- LDKNetAddress_LDKOnionV3_Body onion_v3;
- };
-} LDKNetAddress;
-
-/**
- * A dynamically-allocated array of crate::lightning::ln::msgs::NetAddresss of arbitrary size.
- * This corresponds to std::vector in C++
- */
-typedef struct LDKCVec_NetAddressZ {
+ LDKPaymentSendFailure_PartialFailure,
/**
- * The elements in the array.
- * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc().
+ * Must be last for serialization purposes
*/
- struct LDKNetAddress *data;
+ LDKPaymentSendFailure_Sentinel,
+} LDKPaymentSendFailure_Tag;
+
+typedef struct LDKPaymentSendFailure_LDKPartialFailure_Body {
/**
- * The number of elements pointed to by `data`.
+ * The errors themselves, in the same order as the route hops.
*/
- uintptr_t datalen;
-} LDKCVec_NetAddressZ;
-
-/**
- * A tuple of 2 elements. See the individual fields for the types contained.
- */
-typedef struct LDKC2Tuple_PaymentHashPaymentSecretZ {
+ struct LDKCVec_CResult_NoneAPIErrorZZ results;
/**
- * The element at position 0
+ * If some paths failed without irrevocably committing to the new HTLC(s), this will
+ * contain a [`RouteParameters`] object which can be used to calculate a new route that
+ * will pay all remaining unpaid balance.
+ *
+ * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
*/
- struct LDKThirtyTwoBytes a;
+ struct LDKRouteParameters failed_paths_retry;
/**
- * The element at position 1
+ * The payment id for the payment, which is now at least partially pending.
*/
- struct LDKThirtyTwoBytes b;
-} LDKC2Tuple_PaymentHashPaymentSecretZ;
+ struct LDKThirtyTwoBytes payment_id;
+} LDKPaymentSendFailure_LDKPartialFailure_Body;
+
+typedef struct MUST_USE_STRUCT LDKPaymentSendFailure {
+ LDKPaymentSendFailure_Tag tag;
+ union {
+ struct {
+ struct LDKAPIError parameter_error;
+ };
+ struct {
+ struct LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error;
+ };
+ struct {
+ struct LDKCVec_APIErrorZ all_failed_retry_safe;
+ };
+ LDKPaymentSendFailure_LDKPartialFailure_Body partial_failure;
+ };
+} LDKPaymentSendFailure;
/**
- * The contents of CResult_PaymentSecretAPIErrorZ
+ * The contents of CResult_PaymentIdPaymentSendFailureZ
*/
-typedef union LDKCResult_PaymentSecretAPIErrorZPtr {
+typedef union LDKCResult_PaymentIdPaymentSendFailureZPtr {
/**
* A pointer to the contents in the success state.
* Reading from this pointer when `result_ok` is not set is undefined.
* A pointer to the contents in the error state.
* Reading from this pointer when `result_ok` is set is undefined.
*/
- struct LDKAPIError *err;
-} LDKCResult_PaymentSecretAPIErrorZPtr;
+ struct LDKPaymentSendFailure *err;
+} LDKCResult_PaymentIdPaymentSendFailureZPtr;
/**
- * A CResult_PaymentSecretAPIErrorZ represents the result of a fallible operation,
- * containing a crate::c_types::ThirtyTwoBytes on success and a crate::lightning::util::errors::APIError on failure.
+ * A CResult_PaymentIdPaymentSendFailureZ represents the result of a fallible operation,
+ * containing a crate::c_types::ThirtyTwoBytes on success and a crate::lightning::ln::channelmanager::PaymentSendFailure on failure.
* `result_ok` indicates the overall state, and the contents are provided via `contents`.
*/
-typedef struct LDKCResult_PaymentSecretAPIErrorZ {
+typedef struct LDKCResult_PaymentIdPaymentSendFailureZ {
/**
- * The contents of this CResult_PaymentSecretAPIErrorZ, accessible via either
+ * The contents of this CResult_PaymentIdPaymentSendFailureZ, accessible via either
* `err` or `result` depending on the state of `result_ok`.
*/
- union LDKCResult_PaymentSecretAPIErrorZPtr contents;
+ union LDKCResult_PaymentIdPaymentSendFailureZPtr contents;
/**
- * Whether this CResult_PaymentSecretAPIErrorZ represents a success state.
+ * Whether this CResult_PaymentIdPaymentSendFailureZ represents a success state.
*/
bool result_ok;
-} LDKCResult_PaymentSecretAPIErrorZ;
+} LDKCResult_PaymentIdPaymentSendFailureZ;
/**
- * A dynamically-allocated array of crate::lightning::chain::channelmonitor::ChannelMonitors of arbitrary size.
- * This corresponds to std::vector in C++
+ * The contents of CResult_NonePaymentSendFailureZ
*/
-typedef struct LDKCVec_ChannelMonitorZ {
+typedef union LDKCResult_NonePaymentSendFailureZPtr {
/**
- * The elements in the array.
- * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc().
+ * Note that this value is always NULL, as there are no contents in the OK variant
*/
- struct LDKChannelMonitor *data;
+ void *result;
/**
- * The number of elements pointed to by `data`.
+ * A pointer to the contents in the error state.
+ * Reading from this pointer when `result_ok` is set is undefined.
*/
- uintptr_t datalen;
-} LDKCVec_ChannelMonitorZ;
-
-
+ struct LDKPaymentSendFailure *err;
+} LDKCResult_NonePaymentSendFailureZPtr;
/**
- * An update generated by the underlying Channel itself which contains some new information the
- * ChannelMonitor should be made aware of.
+ * A CResult_NonePaymentSendFailureZ represents the result of a fallible operation,
+ * containing a () on success and a crate::lightning::ln::channelmanager::PaymentSendFailure on failure.
+ * `result_ok` indicates the overall state, and the contents are provided via `contents`.
*/
-typedef struct MUST_USE_STRUCT LDKChannelMonitorUpdate {
+typedef struct LDKCResult_NonePaymentSendFailureZ {
/**
- * A pointer to the opaque Rust object.
- * Nearly everywhere, inner must be non-null, however in places where
- * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ * The contents of this CResult_NonePaymentSendFailureZ, accessible via either
+ * `err` or `result` depending on the state of `result_ok`.
*/
- LDKnativeChannelMonitorUpdate *inner;
+ union LDKCResult_NonePaymentSendFailureZPtr contents;
/**
- * Indicates that this is the only struct which contains the same pointer.
- * Rust functions which take ownership of an object provided via an argument require
- * this to be true and invalidate the object pointed to by inner.
+ * Whether this CResult_NonePaymentSendFailureZ represents a success state.
*/
- bool is_owned;
-} LDKChannelMonitorUpdate;
+ bool result_ok;
+} LDKCResult_NonePaymentSendFailureZ;
/**
- * The `Watch` trait defines behavior for watching on-chain activity pertaining to channels as
- * blocks are connected and disconnected.
- *
- * Each channel is associated with a [`ChannelMonitor`]. Implementations of this trait are
- * responsible for maintaining a set of monitors such that they can be updated accordingly as
- * channel state changes and HTLCs are resolved. See method documentation for specific
- * requirements.
- *
- * Implementations **must** ensure that updates are successfully applied and persisted upon method
- * completion. If an update fails with a [`PermanentFailure`], then it must immediately shut down
- * without taking any further action such as persisting the current state.
- *
- * If an implementation maintains multiple instances of a channel's monitor (e.g., by storing
- * backup copies), then it must ensure that updates are applied across all instances. Otherwise, it
- * could result in a revoked transaction being broadcast, allowing the counterparty to claim all
- * funds in the channel. See [`ChannelMonitorUpdateErr`] for more details about how to handle
- * multiple instances.
- *
- * [`PermanentFailure`]: ChannelMonitorUpdateErr::PermanentFailure
+ * A tuple of 2 elements. See the individual fields for the types contained.
*/
-typedef struct LDKWatch {
- /**
- * An opaque pointer which is passed to your function implementations as an argument.
- * This has no meaning in the LDK, and can be NULL or any other value.
- */
- void *this_arg;
+typedef struct LDKC2Tuple_PaymentHashPaymentIdZ {
/**
- * Watches a channel identified by `funding_txo` using `monitor`.
- *
- * Implementations are responsible for watching the chain for the funding transaction along
- * with any spends of outputs returned by [`get_outputs_to_watch`]. In practice, this means
- * calling [`block_connected`] and [`block_disconnected`] on the monitor.
- *
- * Note: this interface MUST error with `ChannelMonitorUpdateErr::PermanentFailure` if
- * the given `funding_txo` has previously been registered via `watch_channel`.
- *
- * [`get_outputs_to_watch`]: channelmonitor::ChannelMonitor::get_outputs_to_watch
- * [`block_connected`]: channelmonitor::ChannelMonitor::block_connected
- * [`block_disconnected`]: channelmonitor::ChannelMonitor::block_disconnected
+ * The element at position 0
*/
- struct LDKCResult_NoneChannelMonitorUpdateErrZ (*watch_channel)(const void *this_arg, struct LDKOutPoint funding_txo, struct LDKChannelMonitor monitor);
+ struct LDKThirtyTwoBytes a;
/**
- * Updates a channel identified by `funding_txo` by applying `update` to its monitor.
- *
- * Implementations must call [`update_monitor`] with the given update. See
- * [`ChannelMonitorUpdateErr`] for invariants around returning an error.
- *
- * [`update_monitor`]: channelmonitor::ChannelMonitor::update_monitor
+ * The element at position 1
*/
- struct LDKCResult_NoneChannelMonitorUpdateErrZ (*update_channel)(const void *this_arg, struct LDKOutPoint funding_txo, struct LDKChannelMonitorUpdate update);
+ struct LDKThirtyTwoBytes b;
+} LDKC2Tuple_PaymentHashPaymentIdZ;
+
+/**
+ * The contents of CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ
+ */
+typedef union LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZPtr {
/**
- * Returns any monitor events since the last call. Subsequent calls must only return new
- * events.
- *
- * Note that after any block- or transaction-connection calls to a [`ChannelMonitor`], no
- * further events may be returned here until the [`ChannelMonitor`] has been fully persisted
- * to disk.
- *
- * For details on asynchronous [`ChannelMonitor`] updating and returning
- * [`MonitorEvent::UpdateCompleted`] here, see [`ChannelMonitorUpdateErr::TemporaryFailure`].
+ * A pointer to the contents in the success state.
+ * Reading from this pointer when `result_ok` is not set is undefined.
*/
- struct LDKCVec_MonitorEventZ (*release_pending_monitor_events)(const void *this_arg);
- /**
- * Frees any resources associated with this object given its this_arg pointer.
- * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
+ struct LDKC2Tuple_PaymentHashPaymentIdZ *result;
+ /**
+ * A pointer to the contents in the error state.
+ * Reading from this pointer when `result_ok` is set is undefined.
*/
- void (*free)(void *this_arg);
-} LDKWatch;
+ struct LDKPaymentSendFailure *err;
+} LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZPtr;
/**
- * An interface to send a transaction to the Bitcoin network.
+ * A CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ represents the result of a fallible operation,
+ * containing a crate::c_types::derived::C2Tuple_PaymentHashPaymentIdZ on success and a crate::lightning::ln::channelmanager::PaymentSendFailure on failure.
+ * `result_ok` indicates the overall state, and the contents are provided via `contents`.
*/
-typedef struct LDKBroadcasterInterface {
+typedef struct LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ {
/**
- * An opaque pointer which is passed to your function implementations as an argument.
- * This has no meaning in the LDK, and can be NULL or any other value.
+ * The contents of this CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ, accessible via either
+ * `err` or `result` depending on the state of `result_ok`.
*/
- void *this_arg;
+ union LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZPtr contents;
/**
- * Sends a transaction out to (hopefully) be mined.
+ * Whether this CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ represents a success state.
*/
- void (*broadcast_transaction)(const void *this_arg, struct LDKTransaction tx);
+ bool result_ok;
+} LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ;
+
+/**
+ * A 4-byte byte array.
+ */
+typedef struct LDKFourBytes {
/**
- * Frees any resources associated with this object given its this_arg pointer.
- * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
+ * The four bytes
*/
- void (*free)(void *this_arg);
-} LDKBroadcasterInterface;
+ uint8_t data[4];
+} LDKFourBytes;
/**
- * A "slice" referencing some byte array. This is simply a length-tagged pointer which does not
- * own the memory pointed to by data.
+ * A 16-byte byte array.
*/
-typedef struct LDKu8slice {
+typedef struct LDKSixteenBytes {
/**
- * A pointer to the byte buffer
+ * The sixteen bytes
*/
- const uint8_t *data;
+ uint8_t data[16];
+} LDKSixteenBytes;
+
+/**
+ * A 12-byte byte array.
+ */
+typedef struct LDKTwelveBytes {
/**
- * The number of bytes pointed to by `data`.
+ * The twelve bytes
*/
- uintptr_t datalen;
-} LDKu8slice;
+ uint8_t data[12];
+} LDKTwelveBytes;
/**
- * A trait to describe an object which can get user secrets and key material.
+ * An address which can be used to connect to a remote peer
*/
-typedef struct LDKKeysInterface {
+typedef enum LDKNetAddress_Tag {
/**
- * An opaque pointer which is passed to your function implementations as an argument.
- * This has no meaning in the LDK, and can be NULL or any other value.
+ * An IPv4 address/port on which the peer is listening.
*/
- void *this_arg;
+ LDKNetAddress_IPv4,
/**
- * Get node secret key (aka node_id or network_key).
- *
- * This method must return the same value each time it is called.
+ * An IPv6 address/port on which the peer is listening.
*/
- struct LDKSecretKey (*get_node_secret)(const void *this_arg);
+ LDKNetAddress_IPv6,
/**
- * Get a script pubkey which we send funds to when claiming on-chain contestable outputs.
+ * An old-style Tor onion address/port on which the peer is listening.
*
- * 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.
+ * This field is deprecated and the Tor network generally no longer supports V2 Onion
+ * addresses. Thus, the details are not parsed here.
*/
- struct LDKCVec_u8Z (*get_destination_script)(const void *this_arg);
+ LDKNetAddress_OnionV2,
/**
- * 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.
+ * A new-style Tor onion address/port on which the peer is listening.
+ * To create the human-readable \"hostname\", concatenate ed25519_pubkey, checksum, and version,
+ * wrap as base32 and append \".onion\".
*/
- struct LDKShutdownScript (*get_shutdown_scriptpubkey)(const void *this_arg);
+ LDKNetAddress_OnionV3,
/**
- * Get a new set of Sign for per-channel secrets. These MUST be unique even if you
- * restarted with some stale data!
- *
- * This method must return a different value each time it is called.
+ * Must be last for serialization purposes
*/
- struct LDKSign (*get_channel_signer)(const void *this_arg, bool inbound, uint64_t channel_value_satoshis);
+ LDKNetAddress_Sentinel,
+} LDKNetAddress_Tag;
+
+typedef struct LDKNetAddress_LDKIPv4_Body {
/**
- * Gets a unique, cryptographically-secure, random 32 byte value. This is used for encrypting
- * onion packets and for temporary channel IDs. There is no requirement that these be
- * persisted anywhere, though they must be unique across restarts.
- *
- * This method must return a different value each time it is called.
+ * The 4-byte IPv4 address
*/
- struct LDKThirtyTwoBytes (*get_secure_random_bytes)(const void *this_arg);
+ struct LDKFourBytes addr;
/**
- * Reads a `Signer` for this `KeysInterface` from the given input stream.
- * This is only called during deserialization of other objects which contain
- * `Sign`-implementing objects (ie `ChannelMonitor`s and `ChannelManager`s).
- * The bytes are exactly those which `<Self::Signer as Writeable>::write()` writes, and
- * contain no versioning scheme. You may wish to include your own version prefix and ensure
- * you've read all of the provided bytes to ensure no corruption occurred.
+ * The port on which the node is listening
*/
- struct LDKCResult_SignDecodeErrorZ (*read_chan_signer)(const void *this_arg, struct LDKu8slice reader);
+ uint16_t port;
+} LDKNetAddress_LDKIPv4_Body;
+
+typedef struct LDKNetAddress_LDKIPv6_Body {
/**
- * Sign an invoice's preimage (note that this is the preimage of the invoice, not the HTLC's
- * preimage). By parameterizing by the preimage instead of the hash, we allow implementors of
- * this trait to parse the invoice and make sure they're signing what they expect, rather than
- * blindly signing the hash.
+ * The 16-byte IPv6 address
*/
- struct LDKCResult_RecoverableSignatureNoneZ (*sign_invoice)(const void *this_arg, struct LDKCVec_u8Z invoice_preimage);
+ struct LDKSixteenBytes addr;
/**
- * Frees any resources associated with this object given its this_arg pointer.
- * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
+ * The port on which the node is listening
*/
- void (*free)(void *this_arg);
-} LDKKeysInterface;
+ uint16_t port;
+} LDKNetAddress_LDKIPv6_Body;
-/**
- * A trait which should be implemented to provide feerate information on a number of time
- * horizons.
- *
- * Note that all of the functions implemented here *must* be reentrant-safe (obviously - they're
- * called from inside the library in response to chain events, P2P events, or timer events).
- */
-typedef struct LDKFeeEstimator {
+typedef struct LDKNetAddress_LDKOnionV3_Body {
/**
- * An opaque pointer which is passed to your function implementations as an argument.
- * This has no meaning in the LDK, and can be NULL or any other value.
+ * The ed25519 long-term public key of the peer
*/
- void *this_arg;
+ struct LDKThirtyTwoBytes ed25519_pubkey;
/**
- * Gets estimated satoshis of fee required per 1000 Weight-Units.
- *
- * Must be no smaller than 253 (ie 1 satoshi-per-byte rounded up to ensure later round-downs
- * don't put us below 1 satoshi-per-byte).
- *
- * This translates to:
- * * satoshis-per-byte * 250
- * * ceil(satoshis-per-kbyte / 4)
+ * The checksum of the pubkey and version, as included in the onion address
*/
- uint32_t (*get_est_sat_per_1000_weight)(const void *this_arg, enum LDKConfirmationTarget confirmation_target);
+ uint16_t checksum;
/**
- * Frees any resources associated with this object given its this_arg pointer.
- * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
+ * The version byte, as defined by the Tor Onion v3 spec.
*/
- void (*free)(void *this_arg);
-} LDKFeeEstimator;
+ uint8_t version;
+ /**
+ * The port on which the node is listening
+ */
+ uint16_t port;
+} LDKNetAddress_LDKOnionV3_Body;
+
+typedef struct MUST_USE_STRUCT LDKNetAddress {
+ LDKNetAddress_Tag tag;
+ union {
+ LDKNetAddress_LDKIPv4_Body i_pv4;
+ LDKNetAddress_LDKIPv6_Body i_pv6;
+ struct {
+ struct LDKTwelveBytes onion_v2;
+ };
+ LDKNetAddress_LDKOnionV3_Body onion_v3;
+ };
+} LDKNetAddress;
/**
- * A trait encapsulating the operations required of a logger
+ * A dynamically-allocated array of crate::lightning::ln::msgs::NetAddresss of arbitrary size.
+ * This corresponds to std::vector in C++
*/
-typedef struct LDKLogger {
+typedef struct LDKCVec_NetAddressZ {
/**
- * An opaque pointer which is passed to your function implementations as an argument.
- * This has no meaning in the LDK, and can be NULL or any other value.
+ * The elements in the array.
+ * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc().
*/
- void *this_arg;
+ struct LDKNetAddress *data;
/**
- * Logs the `Record`
+ * The number of elements pointed to by `data`.
*/
- void (*log)(const void *this_arg, const char *record);
+ uintptr_t datalen;
+} LDKCVec_NetAddressZ;
+
+/**
+ * A tuple of 2 elements. See the individual fields for the types contained.
+ */
+typedef struct LDKC2Tuple_PaymentHashPaymentSecretZ {
/**
- * Frees any resources associated with this object given its this_arg pointer.
- * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
+ * The element at position 0
*/
- void (*free)(void *this_arg);
-} LDKLogger;
-
-
+ struct LDKThirtyTwoBytes a;
+ /**
+ * The element at position 1
+ */
+ struct LDKThirtyTwoBytes b;
+} LDKC2Tuple_PaymentHashPaymentSecretZ;
/**
- * Manager which keeps track of a number of channels and sends messages to the appropriate
- * channel, also tracking HTLC preimages and forwarding onion packets appropriately.
- *
- * Implements ChannelMessageHandler, handling the multi-channel parts and passing things through
- * to individual Channels.
- *
- * Implements Writeable to write out all channel state to disk. Implies peer_disconnected() for
- * all peers during write/read (though does not modify this instance, only the instance being
- * serialized). This will result in any channels which have not yet exchanged funding_created (ie
- * called funding_transaction_generated for outbound channels).
- *
- * Note that you can be a bit lazier about writing out ChannelManager than you can be with
- * ChannelMonitors. With ChannelMonitors you MUST write each monitor update out to disk before
- * returning from chain::Watch::watch_/update_channel, with ChannelManagers, writing updates
- * happens out-of-band (and will prevent any other ChannelManager operations from occurring during
- * the serialization process). If the deserialized version is out-of-date compared to the
- * ChannelMonitors passed by reference to read(), those channels will be force-closed based on the
- * ChannelMonitor state and no funds will be lost (mod on-chain transaction fees).
- *
- * Note that the deserializer is only implemented for (BlockHash, ChannelManager), which
- * tells you the last block hash which was block_connect()ed. You MUST rescan any blocks along
- * the \"reorg path\" (ie call block_disconnected() until you get to a common block and then call
- * block_connected() to step towards your best block) upon deserialization before using the
- * object!
- *
- * Note that ChannelManager is responsible for tracking liveness of its channels and generating
- * ChannelUpdate messages informing peers that the channel is temporarily disabled. To avoid
- * spam due to quick disconnection/reconnection, updates are not sent until the channel has been
- * offline for a full minute. In order to track this, you must call
- * timer_tick_occurred roughly once per minute, though it doesn't have to be perfect.
- *
- * Rather than using a plain ChannelManager, it is preferable to use either a SimpleArcChannelManager
- * a SimpleRefChannelManager, for conciseness. See their documentation for more details, but
- * essentially you should default to using a SimpleRefChannelManager, and use a
- * SimpleArcChannelManager when you require a ChannelManager with a static lifetime, such as when
- * you're using lightning-net-tokio.
+ * The contents of CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ
*/
-typedef struct MUST_USE_STRUCT LDKChannelManager {
+typedef union LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZPtr {
/**
- * A pointer to the opaque Rust object.
- * Nearly everywhere, inner must be non-null, however in places where
- * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ * A pointer to the contents in the success state.
+ * Reading from this pointer when `result_ok` is not set is undefined.
*/
- LDKnativeChannelManager *inner;
+ struct LDKC2Tuple_PaymentHashPaymentSecretZ *result;
/**
- * Indicates that this is the only struct which contains the same pointer.
- * Rust functions which take ownership of an object provided via an argument require
- * this to be true and invalidate the object pointed to by inner.
+ * Note that this value is always NULL, as there are no contents in the Err variant
*/
- bool is_owned;
-} LDKChannelManager;
+ void *err;
+} LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZPtr;
/**
- * A tuple of 2 elements. See the individual fields for the types contained.
+ * A CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ represents the result of a fallible operation,
+ * containing a crate::c_types::derived::C2Tuple_PaymentHashPaymentSecretZ on success and a () on failure.
+ * `result_ok` indicates the overall state, and the contents are provided via `contents`.
*/
-typedef struct LDKC2Tuple_BlockHashChannelManagerZ {
+typedef struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ {
/**
- * The element at position 0
+ * The contents of this CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ, accessible via either
+ * `err` or `result` depending on the state of `result_ok`.
*/
- struct LDKThirtyTwoBytes a;
+ union LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZPtr contents;
/**
- * The element at position 1
+ * Whether this CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ represents a success state.
*/
- struct LDKChannelManager b;
-} LDKC2Tuple_BlockHashChannelManagerZ;
+ bool result_ok;
+} LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ;
/**
- * The contents of CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ
+ * The contents of CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ
*/
-typedef union LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr {
+typedef union LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZPtr {
/**
* A pointer to the contents in the success state.
* Reading from this pointer when `result_ok` is not set is undefined.
*/
- struct LDKC2Tuple_BlockHashChannelManagerZ *result;
+ struct LDKC2Tuple_PaymentHashPaymentSecretZ *result;
/**
* A pointer to the contents in the error state.
* Reading from this pointer when `result_ok` is set is undefined.
*/
- struct LDKDecodeError *err;
-} LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr;
+ struct LDKAPIError *err;
+} LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZPtr;
/**
- * A CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ represents the result of a fallible operation,
- * containing a crate::c_types::derived::C2Tuple_BlockHashChannelManagerZ on success and a crate::lightning::ln::msgs::DecodeError on failure.
+ * A CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ represents the result of a fallible operation,
+ * containing a crate::c_types::derived::C2Tuple_PaymentHashPaymentSecretZ on success and a crate::lightning::util::errors::APIError on failure.
* `result_ok` indicates the overall state, and the contents are provided via `contents`.
*/
-typedef struct LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ {
+typedef struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ {
/**
- * The contents of this CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ, accessible via either
+ * The contents of this CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ, accessible via either
* `err` or `result` depending on the state of `result_ok`.
*/
- union LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr contents;
+ union LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZPtr contents;
/**
- * Whether this CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ represents a success state.
+ * Whether this CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ represents a success state.
*/
bool result_ok;
-} LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ;
-
+} LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ;
+/**
+ * The contents of CResult_PaymentSecretNoneZ
+ */
+typedef union LDKCResult_PaymentSecretNoneZPtr {
+ /**
+ * A pointer to the contents in the success state.
+ * Reading from this pointer when `result_ok` is not set is undefined.
+ */
+ struct LDKThirtyTwoBytes *result;
+ /**
+ * Note that this value is always NULL, as there are no contents in the Err variant
+ */
+ void *err;
+} LDKCResult_PaymentSecretNoneZPtr;
/**
- * Options which apply on a per-channel basis and may change at runtime or based on negotiation
- * with our counterparty.
+ * A CResult_PaymentSecretNoneZ represents the result of a fallible operation,
+ * containing a crate::c_types::ThirtyTwoBytes on success and a () on failure.
+ * `result_ok` indicates the overall state, and the contents are provided via `contents`.
*/
-typedef struct MUST_USE_STRUCT LDKChannelConfig {
+typedef struct LDKCResult_PaymentSecretNoneZ {
/**
- * A pointer to the opaque Rust object.
- * Nearly everywhere, inner must be non-null, however in places where
- * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ * The contents of this CResult_PaymentSecretNoneZ, accessible via either
+ * `err` or `result` depending on the state of `result_ok`.
*/
- LDKnativeChannelConfig *inner;
+ union LDKCResult_PaymentSecretNoneZPtr contents;
/**
- * Indicates that this is the only struct which contains the same pointer.
- * Rust functions which take ownership of an object provided via an argument require
- * this to be true and invalidate the object pointed to by inner.
+ * Whether this CResult_PaymentSecretNoneZ represents a success state.
*/
- bool is_owned;
-} LDKChannelConfig;
+ bool result_ok;
+} LDKCResult_PaymentSecretNoneZ;
/**
- * The contents of CResult_ChannelConfigDecodeErrorZ
+ * The contents of CResult_PaymentSecretAPIErrorZ
*/
-typedef union LDKCResult_ChannelConfigDecodeErrorZPtr {
+typedef union LDKCResult_PaymentSecretAPIErrorZPtr {
/**
* A pointer to the contents in the success state.
* Reading from this pointer when `result_ok` is not set is undefined.
*/
- struct LDKChannelConfig *result;
+ struct LDKThirtyTwoBytes *result;
/**
* A pointer to the contents in the error state.
* Reading from this pointer when `result_ok` is set is undefined.
*/
- struct LDKDecodeError *err;
-} LDKCResult_ChannelConfigDecodeErrorZPtr;
+ struct LDKAPIError *err;
+} LDKCResult_PaymentSecretAPIErrorZPtr;
/**
- * A CResult_ChannelConfigDecodeErrorZ represents the result of a fallible operation,
- * containing a crate::lightning::util::config::ChannelConfig on success and a crate::lightning::ln::msgs::DecodeError on failure.
+ * A CResult_PaymentSecretAPIErrorZ represents the result of a fallible operation,
+ * containing a crate::c_types::ThirtyTwoBytes on success and a crate::lightning::util::errors::APIError on failure.
* `result_ok` indicates the overall state, and the contents are provided via `contents`.
*/
-typedef struct LDKCResult_ChannelConfigDecodeErrorZ {
+typedef struct LDKCResult_PaymentSecretAPIErrorZ {
/**
- * The contents of this CResult_ChannelConfigDecodeErrorZ, accessible via either
+ * The contents of this CResult_PaymentSecretAPIErrorZ, accessible via either
* `err` or `result` depending on the state of `result_ok`.
*/
- union LDKCResult_ChannelConfigDecodeErrorZPtr contents;
+ union LDKCResult_PaymentSecretAPIErrorZPtr contents;
/**
- * Whether this CResult_ChannelConfigDecodeErrorZ represents a success state.
+ * Whether this CResult_PaymentSecretAPIErrorZ represents a success state.
*/
bool result_ok;
-} LDKCResult_ChannelConfigDecodeErrorZ;
+} LDKCResult_PaymentSecretAPIErrorZ;
/**
- * The contents of CResult_OutPointDecodeErrorZ
+ * The contents of CResult_PaymentPreimageAPIErrorZ
*/
-typedef union LDKCResult_OutPointDecodeErrorZPtr {
+typedef union LDKCResult_PaymentPreimageAPIErrorZPtr {
/**
* A pointer to the contents in the success state.
* Reading from this pointer when `result_ok` is not set is undefined.
*/
- struct LDKOutPoint *result;
+ struct LDKThirtyTwoBytes *result;
/**
* A pointer to the contents in the error state.
* Reading from this pointer when `result_ok` is set is undefined.
*/
- struct LDKDecodeError *err;
-} LDKCResult_OutPointDecodeErrorZPtr;
+ struct LDKAPIError *err;
+} LDKCResult_PaymentPreimageAPIErrorZPtr;
/**
- * A CResult_OutPointDecodeErrorZ represents the result of a fallible operation,
- * containing a crate::lightning::chain::transaction::OutPoint on success and a crate::lightning::ln::msgs::DecodeError on failure.
+ * A CResult_PaymentPreimageAPIErrorZ represents the result of a fallible operation,
+ * containing a crate::c_types::ThirtyTwoBytes on success and a crate::lightning::util::errors::APIError on failure.
* `result_ok` indicates the overall state, and the contents are provided via `contents`.
*/
-typedef struct LDKCResult_OutPointDecodeErrorZ {
+typedef struct LDKCResult_PaymentPreimageAPIErrorZ {
/**
- * The contents of this CResult_OutPointDecodeErrorZ, accessible via either
+ * The contents of this CResult_PaymentPreimageAPIErrorZ, accessible via either
* `err` or `result` depending on the state of `result_ok`.
*/
- union LDKCResult_OutPointDecodeErrorZPtr contents;
+ union LDKCResult_PaymentPreimageAPIErrorZPtr contents;
/**
- * Whether this CResult_OutPointDecodeErrorZ represents a success state.
+ * Whether this CResult_PaymentPreimageAPIErrorZ represents a success state.
*/
bool result_ok;
-} LDKCResult_OutPointDecodeErrorZ;
+} LDKCResult_PaymentPreimageAPIErrorZ;
/**
- * Defines a type identifier for sending messages over the wire.
+ * A dynamically-allocated array of crate::lightning::chain::channelmonitor::ChannelMonitors of arbitrary size.
+ * This corresponds to std::vector in C++
+ */
+typedef struct LDKCVec_ChannelMonitorZ {
+ /**
+ * The elements in the array.
+ * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc().
+ */
+ struct LDKChannelMonitor *data;
+ /**
+ * The number of elements pointed to by `data`.
+ */
+ uintptr_t datalen;
+} LDKCVec_ChannelMonitorZ;
+
+
+
+/**
+ * An update generated by the underlying Channel itself which contains some new information the
+ * ChannelMonitor should be made aware of.
+ */
+typedef struct MUST_USE_STRUCT LDKChannelMonitorUpdate {
+ /**
+ * A pointer to the opaque Rust object.
+ * Nearly everywhere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeChannelMonitorUpdate *inner;
+ /**
+ * Indicates that this is the only struct which contains the same pointer.
+ * Rust functions which take ownership of an object provided via an argument require
+ * this to be true and invalidate the object pointed to by inner.
+ */
+ bool is_owned;
+} LDKChannelMonitorUpdate;
+
+/**
+ * The `Watch` trait defines behavior for watching on-chain activity pertaining to channels as
+ * blocks are connected and disconnected.
*
- * Messages implementing this trait specify a type and must be [`Writeable`].
+ * Each channel is associated with a [`ChannelMonitor`]. Implementations of this trait are
+ * responsible for maintaining a set of monitors such that they can be updated accordingly as
+ * channel state changes and HTLCs are resolved. See method documentation for specific
+ * requirements.
+ *
+ * Implementations **must** ensure that updates are successfully applied and persisted upon method
+ * completion. If an update fails with a [`PermanentFailure`], then it must immediately shut down
+ * without taking any further action such as persisting the current state.
+ *
+ * If an implementation maintains multiple instances of a channel's monitor (e.g., by storing
+ * backup copies), then it must ensure that updates are applied across all instances. Otherwise, it
+ * could result in a revoked transaction being broadcast, allowing the counterparty to claim all
+ * funds in the channel. See [`ChannelMonitorUpdateErr`] for more details about how to handle
+ * multiple instances.
+ *
+ * [`PermanentFailure`]: ChannelMonitorUpdateErr::PermanentFailure
*/
-typedef struct LDKType {
+typedef struct LDKWatch {
/**
* An opaque pointer which is passed to your function implementations as an argument.
* This has no meaning in the LDK, and can be NULL or any other value.
*/
void *this_arg;
/**
- * Returns the type identifying the message payload.
+ * Watches a channel identified by `funding_txo` using `monitor`.
+ *
+ * Implementations are responsible for watching the chain for the funding transaction along
+ * with any spends of outputs returned by [`get_outputs_to_watch`]. In practice, this means
+ * calling [`block_connected`] and [`block_disconnected`] on the monitor.
+ *
+ * Note: this interface MUST error with `ChannelMonitorUpdateErr::PermanentFailure` if
+ * the given `funding_txo` has previously been registered via `watch_channel`.
+ *
+ * [`get_outputs_to_watch`]: channelmonitor::ChannelMonitor::get_outputs_to_watch
+ * [`block_connected`]: channelmonitor::ChannelMonitor::block_connected
+ * [`block_disconnected`]: channelmonitor::ChannelMonitor::block_disconnected
*/
- uint16_t (*type_id)(const void *this_arg);
+ struct LDKCResult_NoneChannelMonitorUpdateErrZ (*watch_channel)(const void *this_arg, struct LDKOutPoint funding_txo, struct LDKChannelMonitor monitor);
/**
- * Return a human-readable "debug" string describing this object
+ * Updates a channel identified by `funding_txo` by applying `update` to its monitor.
+ *
+ * Implementations must call [`update_monitor`] with the given update. See
+ * [`ChannelMonitorUpdateErr`] for invariants around returning an error.
+ *
+ * [`update_monitor`]: channelmonitor::ChannelMonitor::update_monitor
*/
- struct LDKStr (*debug_str)(const void *this_arg);
+ struct LDKCResult_NoneChannelMonitorUpdateErrZ (*update_channel)(const void *this_arg, struct LDKOutPoint funding_txo, struct LDKChannelMonitorUpdate update);
/**
- * Serialize the object into a byte array
+ * Returns any monitor events since the last call. Subsequent calls must only return new
+ * events.
+ *
+ * Note that after any block- or transaction-connection calls to a [`ChannelMonitor`], no
+ * further events may be returned here until the [`ChannelMonitor`] has been fully persisted
+ * to disk.
+ *
+ * For details on asynchronous [`ChannelMonitor`] updating and returning
+ * [`MonitorEvent::UpdateCompleted`] here, see [`ChannelMonitorUpdateErr::TemporaryFailure`].
*/
- struct LDKCVec_u8Z (*write)(const void *this_arg);
+ struct LDKCVec_MonitorEventZ (*release_pending_monitor_events)(const void *this_arg);
/**
* Frees any resources associated with this object given its this_arg pointer.
* Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
*/
void (*free)(void *this_arg);
-} LDKType;
+} LDKWatch;
/**
- * An enum which can either contain a crate::lightning::ln::wire::Type or not
+ * An interface to send a transaction to the Bitcoin network.
*/
-typedef enum LDKCOption_TypeZ_Tag {
+typedef struct LDKBroadcasterInterface {
/**
- * When we're in this state, this COption_TypeZ contains a crate::lightning::ln::wire::Type
+ * An opaque pointer which is passed to your function implementations as an argument.
+ * This has no meaning in the LDK, and can be NULL or any other value.
*/
- LDKCOption_TypeZ_Some,
+ void *this_arg;
/**
- * When we're in this state, this COption_TypeZ contains nothing
+ * Sends a transaction out to (hopefully) be mined.
*/
- LDKCOption_TypeZ_None,
+ void (*broadcast_transaction)(const void *this_arg, struct LDKTransaction tx);
/**
- * Must be last for serialization purposes
+ * 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.
*/
- LDKCOption_TypeZ_Sentinel,
-} LDKCOption_TypeZ_Tag;
-
-typedef struct LDKCOption_TypeZ {
- LDKCOption_TypeZ_Tag tag;
- union {
- struct {
- struct LDKType some;
- };
- };
-} LDKCOption_TypeZ;
+ void (*free)(void *this_arg);
+} LDKBroadcasterInterface;
/**
- * The contents of CResult_COption_TypeZDecodeErrorZ
+ * A "slice" referencing some byte array. This is simply a length-tagged pointer which does not
+ * own the memory pointed to by data.
*/
-typedef union LDKCResult_COption_TypeZDecodeErrorZPtr {
+typedef struct LDKu8slice {
/**
- * A pointer to the contents in the success state.
- * Reading from this pointer when `result_ok` is not set is undefined.
+ * A pointer to the byte buffer
*/
- struct LDKCOption_TypeZ *result;
+ const uint8_t *data;
/**
- * A pointer to the contents in the error state.
- * Reading from this pointer when `result_ok` is set is undefined.
+ * The number of bytes pointed to by `data`.
*/
- struct LDKDecodeError *err;
-} LDKCResult_COption_TypeZDecodeErrorZPtr;
+ uintptr_t datalen;
+} LDKu8slice;
/**
- * A CResult_COption_TypeZDecodeErrorZ represents the result of a fallible operation,
- * containing a crate::c_types::derived::COption_TypeZ on success and a crate::lightning::ln::msgs::DecodeError on failure.
- * `result_ok` indicates the overall state, and the contents are provided via `contents`.
+ * A trait to describe an object which can get user secrets and key material.
*/
-typedef struct LDKCResult_COption_TypeZDecodeErrorZ {
+typedef struct LDKKeysInterface {
/**
- * The contents of this CResult_COption_TypeZDecodeErrorZ, accessible via either
- * `err` or `result` depending on the state of `result_ok`.
+ * An opaque pointer which is passed to your function implementations as an argument.
+ * This has no meaning in the LDK, and can be NULL or any other value.
*/
- union LDKCResult_COption_TypeZDecodeErrorZPtr contents;
+ void *this_arg;
/**
- * Whether this CResult_COption_TypeZDecodeErrorZ represents a success state.
+ * Get node secret key (aka node_id or network_key).
+ *
+ * This method must return the same value each time it is called.
*/
- bool result_ok;
-} LDKCResult_COption_TypeZDecodeErrorZ;
-
-/**
- * An error that may occur when making a payment.
- */
-typedef enum LDKPaymentError_Tag {
+ struct LDKSecretKey (*get_node_secret)(const void *this_arg);
/**
- * An error resulting from the provided [`Invoice`] or payment hash.
+ * Get a script pubkey which we send funds to when claiming on-chain contestable outputs.
+ *
+ * This method should return a different value each time it is called, to avoid linking
+ * on-chain funds across channels as controlled to the same user.
*/
- LDKPaymentError_Invoice,
+ struct LDKCVec_u8Z (*get_destination_script)(const void *this_arg);
/**
- * An error occurring when finding a route.
+ * 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.
*/
- LDKPaymentError_Routing,
+ struct LDKShutdownScript (*get_shutdown_scriptpubkey)(const void *this_arg);
/**
- * An error occurring when sending a payment.
+ * Get a new set of Sign for per-channel secrets. These MUST be unique even if you
+ * restarted with some stale data!
+ *
+ * This method must return a different value each time it is called.
*/
- LDKPaymentError_Sending,
+ struct LDKSign (*get_channel_signer)(const void *this_arg, bool inbound, uint64_t channel_value_satoshis);
/**
- * Must be last for serialization purposes
+ * Gets a unique, cryptographically-secure, random 32 byte value. This is used for encrypting
+ * onion packets and for temporary channel IDs. There is no requirement that these be
+ * persisted anywhere, though they must be unique across restarts.
+ *
+ * This method must return a different value each time it is called.
*/
- LDKPaymentError_Sentinel,
-} LDKPaymentError_Tag;
-
-typedef struct MUST_USE_STRUCT LDKPaymentError {
- LDKPaymentError_Tag tag;
- union {
- struct {
- struct LDKStr invoice;
- };
- struct {
- struct LDKLightningError routing;
- };
- struct {
- struct LDKPaymentSendFailure sending;
- };
- };
-} LDKPaymentError;
-
-/**
- * The contents of CResult_PaymentIdPaymentErrorZ
- */
-typedef union LDKCResult_PaymentIdPaymentErrorZPtr {
+ struct LDKThirtyTwoBytes (*get_secure_random_bytes)(const void *this_arg);
/**
- * A pointer to the contents in the success state.
- * Reading from this pointer when `result_ok` is not set is undefined.
+ * Reads a `Signer` for this `KeysInterface` from the given input stream.
+ * This is only called during deserialization of other objects which contain
+ * `Sign`-implementing objects (ie `ChannelMonitor`s and `ChannelManager`s).
+ * The bytes are exactly those which `<Self::Signer as Writeable>::write()` writes, and
+ * contain no versioning scheme. You may wish to include your own version prefix and ensure
+ * you've read all of the provided bytes to ensure no corruption occurred.
*/
- struct LDKThirtyTwoBytes *result;
+ struct LDKCResult_SignDecodeErrorZ (*read_chan_signer)(const void *this_arg, struct LDKu8slice reader);
/**
- * A pointer to the contents in the error state.
- * Reading from this pointer when `result_ok` is set is undefined.
+ * Sign an invoice's preimage (note that this is the preimage of the invoice, not the HTLC's
+ * preimage). By parameterizing by the preimage instead of the hash, we allow implementors of
+ * this trait to parse the invoice and make sure they're signing what they expect, rather than
+ * blindly signing the hash.
*/
- struct LDKPaymentError *err;
-} LDKCResult_PaymentIdPaymentErrorZPtr;
-
-/**
- * A CResult_PaymentIdPaymentErrorZ represents the result of a fallible operation,
- * containing a crate::c_types::ThirtyTwoBytes on success and a crate::lightning_invoice::payment::PaymentError on failure.
- * `result_ok` indicates the overall state, and the contents are provided via `contents`.
- */
-typedef struct LDKCResult_PaymentIdPaymentErrorZ {
+ struct LDKCResult_RecoverableSignatureNoneZ (*sign_invoice)(const void *this_arg, struct LDKCVec_u8Z invoice_preimage);
/**
- * The contents of this CResult_PaymentIdPaymentErrorZ, accessible via either
- * `err` or `result` depending on the state of `result_ok`.
+ * Get secret key material as bytes for use in encrypting and decrypting inbound payment data.
+ *
+ * This method must return the same value each time it is called.
*/
- union LDKCResult_PaymentIdPaymentErrorZPtr contents;
+ struct LDKThirtyTwoBytes (*get_inbound_payment_key_material)(const void *this_arg);
/**
- * Whether this CResult_PaymentIdPaymentErrorZ represents a success state.
+ * Frees any resources associated with this object given its this_arg pointer.
+ * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
*/
- bool result_ok;
-} LDKCResult_PaymentIdPaymentErrorZ;
+ void (*free)(void *this_arg);
+} LDKKeysInterface;
/**
- * The contents of CResult_SiPrefixNoneZ
+ * A trait which should be implemented to provide feerate information on a number of time
+ * horizons.
+ *
+ * Note that all of the functions implemented here *must* be reentrant-safe (obviously - they're
+ * called from inside the library in response to chain events, P2P events, or timer events).
*/
-typedef union LDKCResult_SiPrefixNoneZPtr {
- /**
- * A pointer to the contents in the success state.
- * Reading from this pointer when `result_ok` is not set is undefined.
- */
- enum LDKSiPrefix *result;
+typedef struct LDKFeeEstimator {
/**
- * Note that this value is always NULL, as there are no contents in the Err variant
+ * An opaque pointer which is passed to your function implementations as an argument.
+ * This has no meaning in the LDK, and can be NULL or any other value.
*/
- void *err;
-} LDKCResult_SiPrefixNoneZPtr;
-
-/**
- * A CResult_SiPrefixNoneZ represents the result of a fallible operation,
- * containing a crate::lightning_invoice::SiPrefix on success and a () on failure.
- * `result_ok` indicates the overall state, and the contents are provided via `contents`.
- */
-typedef struct LDKCResult_SiPrefixNoneZ {
+ void *this_arg;
/**
- * The contents of this CResult_SiPrefixNoneZ, accessible via either
- * `err` or `result` depending on the state of `result_ok`.
+ * Gets estimated satoshis of fee required per 1000 Weight-Units.
+ *
+ * Must return a value no smaller than 253 (ie 1 satoshi-per-byte rounded up to ensure later
+ * round-downs don't put us below 1 satoshi-per-byte).
+ *
+ * This method can be implemented with the following unit conversions:
+ * * max(satoshis-per-byte * 250, 253)
+ * * max(satoshis-per-kbyte / 4, 253)
*/
- union LDKCResult_SiPrefixNoneZPtr contents;
+ uint32_t (*get_est_sat_per_1000_weight)(const void *this_arg, enum LDKConfirmationTarget confirmation_target);
/**
- * Whether this CResult_SiPrefixNoneZ represents a success state.
+ * Frees any resources associated with this object given its this_arg pointer.
+ * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
*/
- bool result_ok;
-} LDKCResult_SiPrefixNoneZ;
+ void (*free)(void *this_arg);
+} LDKFeeEstimator;
/**
- * Represents a syntactically and semantically correct lightning BOLT11 invoice.
- *
- * There are three ways to construct an `Invoice`:
- * 1. using `InvoiceBuilder`
- * 2. using `Invoice::from_signed(SignedRawInvoice)`
- * 3. using `str::parse::<Invoice>(&str)`
+ * A Record, unit of logging output with Metadata to enable filtering
+ * Module_path, file, line to inform on log's source
*/
-typedef struct MUST_USE_STRUCT LDKInvoice {
+typedef struct MUST_USE_STRUCT LDKRecord {
/**
* A pointer to the opaque Rust object.
* Nearly everywhere, inner must be non-null, however in places where
* the Rust equivalent takes an Option, it may be set to null to indicate None.
*/
- LDKnativeInvoice *inner;
+ LDKnativeRecord *inner;
/**
* Indicates that this is the only struct which contains the same pointer.
* Rust functions which take ownership of an object provided via an argument require
* this to be true and invalidate the object pointed to by inner.
*/
bool is_owned;
-} LDKInvoice;
+} LDKRecord;
/**
- * The contents of CResult_InvoiceNoneZ
+ * A trait encapsulating the operations required of a logger
*/
-typedef union LDKCResult_InvoiceNoneZPtr {
- /**
- * A pointer to the contents in the success state.
- * Reading from this pointer when `result_ok` is not set is undefined.
- */
- struct LDKInvoice *result;
+typedef struct LDKLogger {
/**
- * Note that this value is always NULL, as there are no contents in the Err variant
+ * An opaque pointer which is passed to your function implementations as an argument.
+ * This has no meaning in the LDK, and can be NULL or any other value.
*/
- void *err;
-} LDKCResult_InvoiceNoneZPtr;
-
-/**
- * A CResult_InvoiceNoneZ represents the result of a fallible operation,
- * containing a crate::lightning_invoice::Invoice on success and a () on failure.
- * `result_ok` indicates the overall state, and the contents are provided via `contents`.
- */
-typedef struct LDKCResult_InvoiceNoneZ {
+ void *this_arg;
/**
- * The contents of this CResult_InvoiceNoneZ, accessible via either
- * `err` or `result` depending on the state of `result_ok`.
+ * Logs the `Record`
*/
- union LDKCResult_InvoiceNoneZPtr contents;
+ void (*log)(const void *this_arg, const struct LDKRecord *NONNULL_PTR record);
/**
- * Whether this CResult_InvoiceNoneZ represents a success state.
+ * Frees any resources associated with this object given its this_arg pointer.
+ * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
*/
- bool result_ok;
-} LDKCResult_InvoiceNoneZ;
+ void (*free)(void *this_arg);
+} LDKLogger;
/**
- * Represents a signed `RawInvoice` with cached hash. The signature is not checked and may be
- * invalid.
+ * Manager which keeps track of a number of channels and sends messages to the appropriate
+ * channel, also tracking HTLC preimages and forwarding onion packets appropriately.
*
- * # Invariants
- * The hash has to be either from the deserialized invoice or from the serialized `raw_invoice`.
+ * Implements ChannelMessageHandler, handling the multi-channel parts and passing things through
+ * to individual Channels.
+ *
+ * Implements Writeable to write out all channel state to disk. Implies peer_disconnected() for
+ * all peers during write/read (though does not modify this instance, only the instance being
+ * serialized). This will result in any channels which have not yet exchanged funding_created (ie
+ * called funding_transaction_generated for outbound channels).
+ *
+ * Note that you can be a bit lazier about writing out ChannelManager than you can be with
+ * ChannelMonitors. With ChannelMonitors you MUST write each monitor update out to disk before
+ * returning from chain::Watch::watch_/update_channel, with ChannelManagers, writing updates
+ * happens out-of-band (and will prevent any other ChannelManager operations from occurring during
+ * the serialization process). If the deserialized version is out-of-date compared to the
+ * ChannelMonitors passed by reference to read(), those channels will be force-closed based on the
+ * ChannelMonitor state and no funds will be lost (mod on-chain transaction fees).
+ *
+ * Note that the deserializer is only implemented for (BlockHash, ChannelManager), which
+ * tells you the last block hash which was block_connect()ed. You MUST rescan any blocks along
+ * the \"reorg path\" (ie call block_disconnected() until you get to a common block and then call
+ * block_connected() to step towards your best block) upon deserialization before using the
+ * object!
+ *
+ * Note that ChannelManager is responsible for tracking liveness of its channels and generating
+ * ChannelUpdate messages informing peers that the channel is temporarily disabled. To avoid
+ * spam due to quick disconnection/reconnection, updates are not sent until the channel has been
+ * offline for a full minute. In order to track this, you must call
+ * timer_tick_occurred roughly once per minute, though it doesn't have to be perfect.
+ *
+ * Rather than using a plain ChannelManager, it is preferable to use either a SimpleArcChannelManager
+ * a SimpleRefChannelManager, for conciseness. See their documentation for more details, but
+ * essentially you should default to using a SimpleRefChannelManager, and use a
+ * SimpleArcChannelManager when you require a ChannelManager with a static lifetime, such as when
+ * you're using lightning-net-tokio.
*/
-typedef struct MUST_USE_STRUCT LDKSignedRawInvoice {
+typedef struct MUST_USE_STRUCT LDKChannelManager {
/**
* A pointer to the opaque Rust object.
* Nearly everywhere, inner must be non-null, however in places where
* the Rust equivalent takes an Option, it may be set to null to indicate None.
*/
- LDKnativeSignedRawInvoice *inner;
+ LDKnativeChannelManager *inner;
/**
* Indicates that this is the only struct which contains the same pointer.
* Rust functions which take ownership of an object provided via an argument require
* this to be true and invalidate the object pointed to by inner.
*/
bool is_owned;
-} LDKSignedRawInvoice;
+} LDKChannelManager;
/**
- * The contents of CResult_SignedRawInvoiceNoneZ
+ * A tuple of 2 elements. See the individual fields for the types contained.
*/
-typedef union LDKCResult_SignedRawInvoiceNoneZPtr {
+typedef struct LDKC2Tuple_BlockHashChannelManagerZ {
/**
- * A pointer to the contents in the success state.
- * Reading from this pointer when `result_ok` is not set is undefined.
+ * The element at position 0
*/
- struct LDKSignedRawInvoice *result;
+ struct LDKThirtyTwoBytes a;
/**
- * Note that this value is always NULL, as there are no contents in the Err variant
+ * The element at position 1
*/
- void *err;
-} LDKCResult_SignedRawInvoiceNoneZPtr;
+ struct LDKChannelManager b;
+} LDKC2Tuple_BlockHashChannelManagerZ;
/**
- * A CResult_SignedRawInvoiceNoneZ represents the result of a fallible operation,
- * containing a crate::lightning_invoice::SignedRawInvoice on success and a () on failure.
- * `result_ok` indicates the overall state, and the contents are provided via `contents`.
+ * The contents of CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ
*/
-typedef struct LDKCResult_SignedRawInvoiceNoneZ {
+typedef union LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr {
/**
- * The contents of this CResult_SignedRawInvoiceNoneZ, accessible via either
- * `err` or `result` depending on the state of `result_ok`.
+ * A pointer to the contents in the success state.
+ * Reading from this pointer when `result_ok` is not set is undefined.
*/
- union LDKCResult_SignedRawInvoiceNoneZPtr contents;
+ struct LDKC2Tuple_BlockHashChannelManagerZ *result;
/**
- * Whether this CResult_SignedRawInvoiceNoneZ represents a success state.
+ * A pointer to the contents in the error state.
+ * Reading from this pointer when `result_ok` is set is undefined.
*/
- bool result_ok;
-} LDKCResult_SignedRawInvoiceNoneZ;
-
-
+ struct LDKDecodeError *err;
+} LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr;
/**
- * Represents an syntactically correct Invoice for a payment on the lightning network,
- * but without the signature information.
- * De- and encoding should not lead to information loss but may lead to different hashes.
- *
- * For methods without docs see the corresponding methods in `Invoice`.
+ * A CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ represents the result of a fallible operation,
+ * containing a crate::c_types::derived::C2Tuple_BlockHashChannelManagerZ on success and a crate::lightning::ln::msgs::DecodeError on failure.
+ * `result_ok` indicates the overall state, and the contents are provided via `contents`.
*/
-typedef struct MUST_USE_STRUCT LDKRawInvoice {
+typedef struct LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ {
/**
- * A pointer to the opaque Rust object.
- * Nearly everywhere, inner must be non-null, however in places where
- * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ * The contents of this CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ, accessible via either
+ * `err` or `result` depending on the state of `result_ok`.
*/
- LDKnativeRawInvoice *inner;
+ union LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr contents;
/**
- * Indicates that this is the only struct which contains the same pointer.
- * Rust functions which take ownership of an object provided via an argument require
- * this to be true and invalidate the object pointed to by inner.
+ * Whether this CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ represents a success state.
*/
- bool is_owned;
-} LDKRawInvoice;
+ bool result_ok;
+} LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ;
/**
- * Recoverable signature
+ * Options which apply on a per-channel basis and may change at runtime or based on negotiation
+ * with our counterparty.
*/
-typedef struct MUST_USE_STRUCT LDKInvoiceSignature {
+typedef struct MUST_USE_STRUCT LDKChannelConfig {
/**
* A pointer to the opaque Rust object.
* Nearly everywhere, inner must be non-null, however in places where
* the Rust equivalent takes an Option, it may be set to null to indicate None.
*/
- LDKnativeInvoiceSignature *inner;
+ LDKnativeChannelConfig *inner;
/**
* Indicates that this is the only struct which contains the same pointer.
* Rust functions which take ownership of an object provided via an argument require
* this to be true and invalidate the object pointed to by inner.
*/
bool is_owned;
-} LDKInvoiceSignature;
+} LDKChannelConfig;
/**
- * A tuple of 3 elements. See the individual fields for the types contained.
+ * The contents of CResult_ChannelConfigDecodeErrorZ
*/
-typedef struct LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ {
- /**
- * The element at position 0
- */
- struct LDKRawInvoice a;
+typedef union LDKCResult_ChannelConfigDecodeErrorZPtr {
/**
- * The element at position 1
+ * A pointer to the contents in the success state.
+ * Reading from this pointer when `result_ok` is not set is undefined.
*/
- struct LDKThirtyTwoBytes b;
+ struct LDKChannelConfig *result;
/**
- * The element at position 2
+ * A pointer to the contents in the error state.
+ * Reading from this pointer when `result_ok` is set is undefined.
*/
- struct LDKInvoiceSignature c;
-} LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ;
-
-
+ struct LDKDecodeError *err;
+} LDKCResult_ChannelConfigDecodeErrorZPtr;
/**
- * Payee public key
+ * A CResult_ChannelConfigDecodeErrorZ represents the result of a fallible operation,
+ * containing a crate::lightning::util::config::ChannelConfig on success and a crate::lightning::ln::msgs::DecodeError on failure.
+ * `result_ok` indicates the overall state, and the contents are provided via `contents`.
*/
-typedef struct MUST_USE_STRUCT LDKPayeePubKey {
+typedef struct LDKCResult_ChannelConfigDecodeErrorZ {
/**
- * A pointer to the opaque Rust object.
- * Nearly everywhere, inner must be non-null, however in places where
- * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ * The contents of this CResult_ChannelConfigDecodeErrorZ, accessible via either
+ * `err` or `result` depending on the state of `result_ok`.
*/
- LDKnativePayeePubKey *inner;
+ union LDKCResult_ChannelConfigDecodeErrorZPtr contents;
/**
- * Indicates that this is the only struct which contains the same pointer.
- * Rust functions which take ownership of an object provided via an argument require
- * this to be true and invalidate the object pointed to by inner.
+ * Whether this CResult_ChannelConfigDecodeErrorZ represents a success state.
*/
- bool is_owned;
-} LDKPayeePubKey;
+ bool result_ok;
+} LDKCResult_ChannelConfigDecodeErrorZ;
/**
- * The contents of CResult_PayeePubKeyErrorZ
+ * The contents of CResult_OutPointDecodeErrorZ
*/
-typedef union LDKCResult_PayeePubKeyErrorZPtr {
+typedef union LDKCResult_OutPointDecodeErrorZPtr {
/**
* A pointer to the contents in the success state.
* Reading from this pointer when `result_ok` is not set is undefined.
*/
- struct LDKPayeePubKey *result;
+ struct LDKOutPoint *result;
/**
* A pointer to the contents in the error state.
* Reading from this pointer when `result_ok` is set is undefined.
*/
- enum LDKSecp256k1Error *err;
-} LDKCResult_PayeePubKeyErrorZPtr;
+ struct LDKDecodeError *err;
+} LDKCResult_OutPointDecodeErrorZPtr;
/**
- * A CResult_PayeePubKeyErrorZ represents the result of a fallible operation,
- * containing a crate::lightning_invoice::PayeePubKey on success and a crate::c_types::Secp256k1Error on failure.
+ * A CResult_OutPointDecodeErrorZ represents the result of a fallible operation,
+ * containing a crate::lightning::chain::transaction::OutPoint on success and a crate::lightning::ln::msgs::DecodeError on failure.
* `result_ok` indicates the overall state, and the contents are provided via `contents`.
*/
-typedef struct LDKCResult_PayeePubKeyErrorZ {
+typedef struct LDKCResult_OutPointDecodeErrorZ {
/**
- * The contents of this CResult_PayeePubKeyErrorZ, accessible via either
+ * The contents of this CResult_OutPointDecodeErrorZ, accessible via either
* `err` or `result` depending on the state of `result_ok`.
*/
- union LDKCResult_PayeePubKeyErrorZPtr contents;
+ union LDKCResult_OutPointDecodeErrorZPtr contents;
/**
- * Whether this CResult_PayeePubKeyErrorZ represents a success state.
+ * Whether this CResult_OutPointDecodeErrorZ represents a success state.
*/
bool result_ok;
-} LDKCResult_PayeePubKeyErrorZ;
-
-
+} LDKCResult_OutPointDecodeErrorZ;
/**
- * Private routing information
- *
- * # Invariants
- * The encoded route has to be <1024 5bit characters long (<=639 bytes or <=12 hops)
+ * Defines a type identifier for sending messages over the wire.
*
+ * Messages implementing this trait specify a type and must be [`Writeable`].
*/
-typedef struct MUST_USE_STRUCT LDKPrivateRoute {
+typedef struct LDKType {
/**
- * A pointer to the opaque Rust object.
- * Nearly everywhere, inner must be non-null, however in places where
- * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ * An opaque pointer which is passed to your function implementations as an argument.
+ * This has no meaning in the LDK, and can be NULL or any other value.
*/
- LDKnativePrivateRoute *inner;
+ void *this_arg;
/**
- * Indicates that this is the only struct which contains the same pointer.
- * Rust functions which take ownership of an object provided via an argument require
- * this to be true and invalidate the object pointed to by inner.
+ * Returns the type identifying the message payload.
*/
- bool is_owned;
-} LDKPrivateRoute;
-
-/**
- * A dynamically-allocated array of crate::lightning_invoice::PrivateRoutes of arbitrary size.
- * This corresponds to std::vector in C++
- */
-typedef struct LDKCVec_PrivateRouteZ {
+ uint16_t (*type_id)(const void *this_arg);
/**
- * The elements in the array.
- * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc().
+ * Return a human-readable "debug" string describing this object
*/
- struct LDKPrivateRoute *data;
+ struct LDKStr (*debug_str)(const void *this_arg);
/**
- * The number of elements pointed to by `data`.
+ * Serialize the object into a byte array
*/
- uintptr_t datalen;
-} LDKCVec_PrivateRouteZ;
-
-
+ struct LDKCVec_u8Z (*write)(const void *this_arg);
+ /**
+ * Frees any resources associated with this object given its this_arg pointer.
+ * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
+ */
+ void (*free)(void *this_arg);
+} LDKType;
/**
- * A timestamp that refers to a date after 1 January 1970 which means its representation as UNIX
- * timestamp is positive.
- *
- * # Invariants
- * The UNIX timestamp representing the stored time has to be positive and small enough so that
- * a `EpiryTime` can be added to it without an overflow.
+ * An enum which can either contain a crate::lightning::ln::wire::Type or not
*/
-typedef struct MUST_USE_STRUCT LDKPositiveTimestamp {
+typedef enum LDKCOption_TypeZ_Tag {
/**
- * A pointer to the opaque Rust object.
- * Nearly everywhere, inner must be non-null, however in places where
- * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ * When we're in this state, this COption_TypeZ contains a crate::lightning::ln::wire::Type
*/
- LDKnativePositiveTimestamp *inner;
+ LDKCOption_TypeZ_Some,
/**
- * Indicates that this is the only struct which contains the same pointer.
- * Rust functions which take ownership of an object provided via an argument require
- * this to be true and invalidate the object pointed to by inner.
+ * When we're in this state, this COption_TypeZ contains nothing
*/
- bool is_owned;
-} LDKPositiveTimestamp;
+ LDKCOption_TypeZ_None,
+ /**
+ * Must be last for serialization purposes
+ */
+ LDKCOption_TypeZ_Sentinel,
+} LDKCOption_TypeZ_Tag;
+
+typedef struct LDKCOption_TypeZ {
+ LDKCOption_TypeZ_Tag tag;
+ union {
+ struct {
+ struct LDKType some;
+ };
+ };
+} LDKCOption_TypeZ;
/**
- * The contents of CResult_PositiveTimestampCreationErrorZ
+ * The contents of CResult_COption_TypeZDecodeErrorZ
*/
-typedef union LDKCResult_PositiveTimestampCreationErrorZPtr {
+typedef union LDKCResult_COption_TypeZDecodeErrorZPtr {
/**
* A pointer to the contents in the success state.
* Reading from this pointer when `result_ok` is not set is undefined.
*/
- struct LDKPositiveTimestamp *result;
+ struct LDKCOption_TypeZ *result;
/**
* A pointer to the contents in the error state.
* Reading from this pointer when `result_ok` is set is undefined.
*/
- enum LDKCreationError *err;
-} LDKCResult_PositiveTimestampCreationErrorZPtr;
+ struct LDKDecodeError *err;
+} LDKCResult_COption_TypeZDecodeErrorZPtr;
/**
- * A CResult_PositiveTimestampCreationErrorZ represents the result of a fallible operation,
- * containing a crate::lightning_invoice::PositiveTimestamp on success and a crate::lightning_invoice::CreationError on failure.
+ * A CResult_COption_TypeZDecodeErrorZ represents the result of a fallible operation,
+ * containing a crate::c_types::derived::COption_TypeZ on success and a crate::lightning::ln::msgs::DecodeError on failure.
* `result_ok` indicates the overall state, and the contents are provided via `contents`.
*/
-typedef struct LDKCResult_PositiveTimestampCreationErrorZ {
+typedef struct LDKCResult_COption_TypeZDecodeErrorZ {
/**
- * The contents of this CResult_PositiveTimestampCreationErrorZ, accessible via either
+ * The contents of this CResult_COption_TypeZDecodeErrorZ, accessible via either
* `err` or `result` depending on the state of `result_ok`.
*/
- union LDKCResult_PositiveTimestampCreationErrorZPtr contents;
+ union LDKCResult_COption_TypeZDecodeErrorZPtr contents;
/**
- * Whether this CResult_PositiveTimestampCreationErrorZ represents a success state.
+ * Whether this CResult_COption_TypeZDecodeErrorZ represents a success state.
*/
bool result_ok;
-} LDKCResult_PositiveTimestampCreationErrorZ;
+} LDKCResult_COption_TypeZDecodeErrorZ;
/**
- * The contents of CResult_NoneSemanticErrorZ
+ * An error that may occur when making a payment.
*/
-typedef union LDKCResult_NoneSemanticErrorZPtr {
+typedef enum LDKPaymentError_Tag {
/**
- * Note that this value is always NULL, as there are no contents in the OK variant
+ * An error resulting from the provided [`Invoice`] or payment hash.
*/
- void *result;
+ LDKPaymentError_Invoice,
+ /**
+ * An error occurring when finding a route.
+ */
+ LDKPaymentError_Routing,
+ /**
+ * An error occurring when sending a payment.
+ */
+ LDKPaymentError_Sending,
+ /**
+ * Must be last for serialization purposes
+ */
+ LDKPaymentError_Sentinel,
+} LDKPaymentError_Tag;
+
+typedef struct MUST_USE_STRUCT LDKPaymentError {
+ LDKPaymentError_Tag tag;
+ union {
+ struct {
+ struct LDKStr invoice;
+ };
+ struct {
+ struct LDKLightningError routing;
+ };
+ struct {
+ struct LDKPaymentSendFailure sending;
+ };
+ };
+} LDKPaymentError;
+
+/**
+ * The contents of CResult_PaymentIdPaymentErrorZ
+ */
+typedef union LDKCResult_PaymentIdPaymentErrorZPtr {
+ /**
+ * A pointer to the contents in the success state.
+ * Reading from this pointer when `result_ok` is not set is undefined.
+ */
+ struct LDKThirtyTwoBytes *result;
/**
* A pointer to the contents in the error state.
* Reading from this pointer when `result_ok` is set is undefined.
*/
- enum LDKSemanticError *err;
-} LDKCResult_NoneSemanticErrorZPtr;
+ struct LDKPaymentError *err;
+} LDKCResult_PaymentIdPaymentErrorZPtr;
/**
- * A CResult_NoneSemanticErrorZ represents the result of a fallible operation,
- * containing a () on success and a crate::lightning_invoice::SemanticError on failure.
+ * A CResult_PaymentIdPaymentErrorZ represents the result of a fallible operation,
+ * containing a crate::c_types::ThirtyTwoBytes on success and a crate::lightning_invoice::payment::PaymentError on failure.
* `result_ok` indicates the overall state, and the contents are provided via `contents`.
*/
-typedef struct LDKCResult_NoneSemanticErrorZ {
+typedef struct LDKCResult_PaymentIdPaymentErrorZ {
/**
- * The contents of this CResult_NoneSemanticErrorZ, accessible via either
+ * The contents of this CResult_PaymentIdPaymentErrorZ, accessible via either
* `err` or `result` depending on the state of `result_ok`.
*/
- union LDKCResult_NoneSemanticErrorZPtr contents;
+ union LDKCResult_PaymentIdPaymentErrorZPtr contents;
/**
- * Whether this CResult_NoneSemanticErrorZ represents a success state.
+ * Whether this CResult_PaymentIdPaymentErrorZ represents a success state.
*/
bool result_ok;
-} LDKCResult_NoneSemanticErrorZ;
+} LDKCResult_PaymentIdPaymentErrorZ;
/**
- * The contents of CResult_InvoiceSemanticErrorZ
+ * The contents of CResult_SiPrefixNoneZ
*/
-typedef union LDKCResult_InvoiceSemanticErrorZPtr {
+typedef union LDKCResult_SiPrefixNoneZPtr {
/**
* A pointer to the contents in the success state.
* Reading from this pointer when `result_ok` is not set is undefined.
*/
- struct LDKInvoice *result;
+ enum LDKSiPrefix *result;
/**
- * A pointer to the contents in the error state.
- * Reading from this pointer when `result_ok` is set is undefined.
+ * Note that this value is always NULL, as there are no contents in the Err variant
*/
- enum LDKSemanticError *err;
-} LDKCResult_InvoiceSemanticErrorZPtr;
+ void *err;
+} LDKCResult_SiPrefixNoneZPtr;
/**
- * A CResult_InvoiceSemanticErrorZ represents the result of a fallible operation,
- * containing a crate::lightning_invoice::Invoice on success and a crate::lightning_invoice::SemanticError on failure.
+ * A CResult_SiPrefixNoneZ represents the result of a fallible operation,
+ * containing a crate::lightning_invoice::SiPrefix on success and a () on failure.
* `result_ok` indicates the overall state, and the contents are provided via `contents`.
*/
-typedef struct LDKCResult_InvoiceSemanticErrorZ {
+typedef struct LDKCResult_SiPrefixNoneZ {
/**
- * The contents of this CResult_InvoiceSemanticErrorZ, accessible via either
+ * The contents of this CResult_SiPrefixNoneZ, accessible via either
* `err` or `result` depending on the state of `result_ok`.
*/
- union LDKCResult_InvoiceSemanticErrorZPtr contents;
+ union LDKCResult_SiPrefixNoneZPtr contents;
/**
- * Whether this CResult_InvoiceSemanticErrorZ represents a success state.
+ * Whether this CResult_SiPrefixNoneZ represents a success state.
*/
bool result_ok;
-} LDKCResult_InvoiceSemanticErrorZ;
+} LDKCResult_SiPrefixNoneZ;
/**
- * Description string
+ * Represents a syntactically and semantically correct lightning BOLT11 invoice.
*
- * # Invariants
- * The description can be at most 639 __bytes__ long
+ * There are three ways to construct an `Invoice`:
+ * 1. using `InvoiceBuilder`
+ * 2. using `Invoice::from_signed(SignedRawInvoice)`
+ * 3. using `str::parse::<Invoice>(&str)`
*/
-typedef struct MUST_USE_STRUCT LDKDescription {
+typedef struct MUST_USE_STRUCT LDKInvoice {
/**
* A pointer to the opaque Rust object.
* Nearly everywhere, inner must be non-null, however in places where
* the Rust equivalent takes an Option, it may be set to null to indicate None.
*/
- LDKnativeDescription *inner;
+ LDKnativeInvoice *inner;
/**
* Indicates that this is the only struct which contains the same pointer.
* Rust functions which take ownership of an object provided via an argument require
* this to be true and invalidate the object pointed to by inner.
*/
bool is_owned;
-} LDKDescription;
+} LDKInvoice;
/**
- * The contents of CResult_DescriptionCreationErrorZ
+ * The contents of CResult_InvoiceNoneZ
*/
-typedef union LDKCResult_DescriptionCreationErrorZPtr {
+typedef union LDKCResult_InvoiceNoneZPtr {
/**
* A pointer to the contents in the success state.
* Reading from this pointer when `result_ok` is not set is undefined.
*/
- struct LDKDescription *result;
+ struct LDKInvoice *result;
/**
- * A pointer to the contents in the error state.
- * Reading from this pointer when `result_ok` is set is undefined.
+ * Note that this value is always NULL, as there are no contents in the Err variant
*/
- enum LDKCreationError *err;
-} LDKCResult_DescriptionCreationErrorZPtr;
+ void *err;
+} LDKCResult_InvoiceNoneZPtr;
/**
- * A CResult_DescriptionCreationErrorZ represents the result of a fallible operation,
- * containing a crate::lightning_invoice::Description on success and a crate::lightning_invoice::CreationError on failure.
+ * A CResult_InvoiceNoneZ represents the result of a fallible operation,
+ * containing a crate::lightning_invoice::Invoice on success and a () on failure.
* `result_ok` indicates the overall state, and the contents are provided via `contents`.
*/
-typedef struct LDKCResult_DescriptionCreationErrorZ {
+typedef struct LDKCResult_InvoiceNoneZ {
/**
- * The contents of this CResult_DescriptionCreationErrorZ, accessible via either
+ * The contents of this CResult_InvoiceNoneZ, accessible via either
* `err` or `result` depending on the state of `result_ok`.
*/
- union LDKCResult_DescriptionCreationErrorZPtr contents;
+ union LDKCResult_InvoiceNoneZPtr contents;
/**
- * Whether this CResult_DescriptionCreationErrorZ represents a success state.
+ * Whether this CResult_InvoiceNoneZ represents a success state.
*/
bool result_ok;
-} LDKCResult_DescriptionCreationErrorZ;
+} LDKCResult_InvoiceNoneZ;
/**
- * Positive duration that defines when (relatively to the timestamp) in the future the invoice
- * expires
+ * Represents a signed `RawInvoice` with cached hash. The signature is not checked and may be
+ * invalid.
*
* # Invariants
- * The number of seconds this expiry time represents has to be in the range
- * `0...(SYSTEM_TIME_MAX_UNIX_TIMESTAMP - MAX_EXPIRY_TIME)` to avoid overflows when adding it to a
- * timestamp
+ * The hash has to be either from the deserialized invoice or from the serialized `raw_invoice`.
*/
-typedef struct MUST_USE_STRUCT LDKExpiryTime {
+typedef struct MUST_USE_STRUCT LDKSignedRawInvoice {
/**
* A pointer to the opaque Rust object.
* Nearly everywhere, inner must be non-null, however in places where
* the Rust equivalent takes an Option, it may be set to null to indicate None.
*/
- LDKnativeExpiryTime *inner;
+ LDKnativeSignedRawInvoice *inner;
/**
* Indicates that this is the only struct which contains the same pointer.
* Rust functions which take ownership of an object provided via an argument require
* this to be true and invalidate the object pointed to by inner.
*/
bool is_owned;
-} LDKExpiryTime;
+} LDKSignedRawInvoice;
/**
- * The contents of CResult_ExpiryTimeCreationErrorZ
+ * The contents of CResult_SignedRawInvoiceNoneZ
*/
-typedef union LDKCResult_ExpiryTimeCreationErrorZPtr {
+typedef union LDKCResult_SignedRawInvoiceNoneZPtr {
/**
* A pointer to the contents in the success state.
* Reading from this pointer when `result_ok` is not set is undefined.
*/
- struct LDKExpiryTime *result;
+ struct LDKSignedRawInvoice *result;
/**
- * A pointer to the contents in the error state.
- * Reading from this pointer when `result_ok` is set is undefined.
+ * Note that this value is always NULL, as there are no contents in the Err variant
*/
- enum LDKCreationError *err;
-} LDKCResult_ExpiryTimeCreationErrorZPtr;
+ void *err;
+} LDKCResult_SignedRawInvoiceNoneZPtr;
/**
- * A CResult_ExpiryTimeCreationErrorZ represents the result of a fallible operation,
- * containing a crate::lightning_invoice::ExpiryTime on success and a crate::lightning_invoice::CreationError on failure.
+ * A CResult_SignedRawInvoiceNoneZ represents the result of a fallible operation,
+ * containing a crate::lightning_invoice::SignedRawInvoice on success and a () on failure.
* `result_ok` indicates the overall state, and the contents are provided via `contents`.
*/
-typedef struct LDKCResult_ExpiryTimeCreationErrorZ {
+typedef struct LDKCResult_SignedRawInvoiceNoneZ {
/**
- * The contents of this CResult_ExpiryTimeCreationErrorZ, accessible via either
+ * The contents of this CResult_SignedRawInvoiceNoneZ, accessible via either
* `err` or `result` depending on the state of `result_ok`.
*/
- union LDKCResult_ExpiryTimeCreationErrorZPtr contents;
+ union LDKCResult_SignedRawInvoiceNoneZPtr contents;
/**
- * Whether this CResult_ExpiryTimeCreationErrorZ represents a success state.
+ * Whether this CResult_SignedRawInvoiceNoneZ represents a success state.
*/
bool result_ok;
-} LDKCResult_ExpiryTimeCreationErrorZ;
+} LDKCResult_SignedRawInvoiceNoneZ;
+
+
/**
- * The contents of CResult_PrivateRouteCreationErrorZ
+ * Represents an syntactically correct Invoice for a payment on the lightning network,
+ * but without the signature information.
+ * De- and encoding should not lead to information loss but may lead to different hashes.
+ *
+ * For methods without docs see the corresponding methods in `Invoice`.
*/
-typedef union LDKCResult_PrivateRouteCreationErrorZPtr {
+typedef struct MUST_USE_STRUCT LDKRawInvoice {
/**
- * A pointer to the contents in the success state.
- * Reading from this pointer when `result_ok` is not set is undefined.
+ * A pointer to the opaque Rust object.
+ * Nearly everywhere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
*/
- struct LDKPrivateRoute *result;
+ LDKnativeRawInvoice *inner;
/**
- * A pointer to the contents in the error state.
- * Reading from this pointer when `result_ok` is set is undefined.
+ * Indicates that this is the only struct which contains the same pointer.
+ * Rust functions which take ownership of an object provided via an argument require
+ * this to be true and invalidate the object pointed to by inner.
*/
- enum LDKCreationError *err;
-} LDKCResult_PrivateRouteCreationErrorZPtr;
+ bool is_owned;
+} LDKRawInvoice;
+
+
/**
- * A CResult_PrivateRouteCreationErrorZ represents the result of a fallible operation,
- * containing a crate::lightning_invoice::PrivateRoute on success and a crate::lightning_invoice::CreationError on failure.
- * `result_ok` indicates the overall state, and the contents are provided via `contents`.
+ * Recoverable signature
*/
-typedef struct LDKCResult_PrivateRouteCreationErrorZ {
+typedef struct MUST_USE_STRUCT LDKInvoiceSignature {
/**
- * The contents of this CResult_PrivateRouteCreationErrorZ, accessible via either
- * `err` or `result` depending on the state of `result_ok`.
+ * A pointer to the opaque Rust object.
+ * Nearly everywhere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
*/
- union LDKCResult_PrivateRouteCreationErrorZPtr contents;
+ LDKnativeInvoiceSignature *inner;
/**
- * Whether this CResult_PrivateRouteCreationErrorZ represents a success state.
+ * Indicates that this is the only struct which contains the same pointer.
+ * Rust functions which take ownership of an object provided via an argument require
+ * this to be true and invalidate the object pointed to by inner.
*/
- bool result_ok;
-} LDKCResult_PrivateRouteCreationErrorZ;
+ bool is_owned;
+} LDKInvoiceSignature;
/**
- * The contents of CResult_StringErrorZ
+ * A tuple of 3 elements. See the individual fields for the types contained.
*/
-typedef union LDKCResult_StringErrorZPtr {
+typedef struct LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ {
/**
- * A pointer to the contents in the success state.
- * Reading from this pointer when `result_ok` is not set is undefined.
+ * The element at position 0
*/
- struct LDKStr *result;
+ struct LDKRawInvoice a;
/**
- * A pointer to the contents in the error state.
- * Reading from this pointer when `result_ok` is set is undefined.
+ * The element at position 1
*/
- enum LDKSecp256k1Error *err;
-} LDKCResult_StringErrorZPtr;
+ struct LDKThirtyTwoBytes b;
+ /**
+ * The element at position 2
+ */
+ struct LDKInvoiceSignature c;
+} LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ;
+
+
/**
- * A CResult_StringErrorZ represents the result of a fallible operation,
- * containing a crate::c_types::Str on success and a crate::c_types::Secp256k1Error on failure.
- * `result_ok` indicates the overall state, and the contents are provided via `contents`.
+ * Payee public key
*/
-typedef struct LDKCResult_StringErrorZ {
+typedef struct MUST_USE_STRUCT LDKPayeePubKey {
/**
- * The contents of this CResult_StringErrorZ, accessible via either
- * `err` or `result` depending on the state of `result_ok`.
+ * A pointer to the opaque Rust object.
+ * Nearly everywhere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
*/
- union LDKCResult_StringErrorZPtr contents;
+ LDKnativePayeePubKey *inner;
/**
- * Whether this CResult_StringErrorZ represents a success state.
+ * Indicates that this is the only struct which contains the same pointer.
+ * Rust functions which take ownership of an object provided via an argument require
+ * this to be true and invalidate the object pointed to by inner.
*/
- bool result_ok;
-} LDKCResult_StringErrorZ;
+ bool is_owned;
+} LDKPayeePubKey;
/**
- * The contents of CResult_ChannelMonitorUpdateDecodeErrorZ
+ * The contents of CResult_PayeePubKeyErrorZ
*/
-typedef union LDKCResult_ChannelMonitorUpdateDecodeErrorZPtr {
+typedef union LDKCResult_PayeePubKeyErrorZPtr {
/**
* A pointer to the contents in the success state.
* Reading from this pointer when `result_ok` is not set is undefined.
*/
- struct LDKChannelMonitorUpdate *result;
+ struct LDKPayeePubKey *result;
/**
* A pointer to the contents in the error state.
* Reading from this pointer when `result_ok` is set is undefined.
*/
- struct LDKDecodeError *err;
-} LDKCResult_ChannelMonitorUpdateDecodeErrorZPtr;
+ enum LDKSecp256k1Error *err;
+} LDKCResult_PayeePubKeyErrorZPtr;
/**
- * A CResult_ChannelMonitorUpdateDecodeErrorZ represents the result of a fallible operation,
- * containing a crate::lightning::chain::channelmonitor::ChannelMonitorUpdate on success and a crate::lightning::ln::msgs::DecodeError on failure.
+ * A CResult_PayeePubKeyErrorZ represents the result of a fallible operation,
+ * containing a crate::lightning_invoice::PayeePubKey on success and a crate::c_types::Secp256k1Error on failure.
* `result_ok` indicates the overall state, and the contents are provided via `contents`.
*/
-typedef struct LDKCResult_ChannelMonitorUpdateDecodeErrorZ {
+typedef struct LDKCResult_PayeePubKeyErrorZ {
/**
- * The contents of this CResult_ChannelMonitorUpdateDecodeErrorZ, accessible via either
+ * The contents of this CResult_PayeePubKeyErrorZ, accessible via either
* `err` or `result` depending on the state of `result_ok`.
*/
- union LDKCResult_ChannelMonitorUpdateDecodeErrorZPtr contents;
+ union LDKCResult_PayeePubKeyErrorZPtr contents;
/**
- * Whether this CResult_ChannelMonitorUpdateDecodeErrorZ represents a success state.
+ * Whether this CResult_PayeePubKeyErrorZ represents a success state.
*/
bool result_ok;
-} LDKCResult_ChannelMonitorUpdateDecodeErrorZ;
+} LDKCResult_PayeePubKeyErrorZ;
+
+
/**
- * The contents of CResult_HTLCUpdateDecodeErrorZ
+ * Private routing information
+ *
+ * # Invariants
+ * The encoded route has to be <1024 5bit characters long (<=639 bytes or <=12 hops)
+ *
*/
-typedef union LDKCResult_HTLCUpdateDecodeErrorZPtr {
+typedef struct MUST_USE_STRUCT LDKPrivateRoute {
/**
- * A pointer to the contents in the success state.
- * Reading from this pointer when `result_ok` is not set is undefined.
+ * A pointer to the opaque Rust object.
+ * Nearly everywhere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
*/
- struct LDKHTLCUpdate *result;
+ LDKnativePrivateRoute *inner;
/**
- * A pointer to the contents in the error state.
- * Reading from this pointer when `result_ok` is set is undefined.
+ * Indicates that this is the only struct which contains the same pointer.
+ * Rust functions which take ownership of an object provided via an argument require
+ * this to be true and invalidate the object pointed to by inner.
*/
- struct LDKDecodeError *err;
-} LDKCResult_HTLCUpdateDecodeErrorZPtr;
+ bool is_owned;
+} LDKPrivateRoute;
/**
- * A CResult_HTLCUpdateDecodeErrorZ represents the result of a fallible operation,
- * containing a crate::lightning::chain::channelmonitor::HTLCUpdate on success and a crate::lightning::ln::msgs::DecodeError on failure.
- * `result_ok` indicates the overall state, and the contents are provided via `contents`.
+ * A dynamically-allocated array of crate::lightning_invoice::PrivateRoutes of arbitrary size.
+ * This corresponds to std::vector in C++
*/
-typedef struct LDKCResult_HTLCUpdateDecodeErrorZ {
+typedef struct LDKCVec_PrivateRouteZ {
/**
- * The contents of this CResult_HTLCUpdateDecodeErrorZ, accessible via either
- * `err` or `result` depending on the state of `result_ok`.
+ * The elements in the array.
+ * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc().
*/
- union LDKCResult_HTLCUpdateDecodeErrorZPtr contents;
+ struct LDKPrivateRoute *data;
/**
- * Whether this CResult_HTLCUpdateDecodeErrorZ represents a success state.
+ * The number of elements pointed to by `data`.
*/
- bool result_ok;
-} LDKCResult_HTLCUpdateDecodeErrorZ;
+ uintptr_t datalen;
+} LDKCVec_PrivateRouteZ;
/**
- * General Err type for ChannelMonitor actions. Generally, this implies that the data provided is
- * inconsistent with the ChannelMonitor being called. eg for ChannelMonitor::update_monitor this
- * means you tried to update a monitor for a different channel or the ChannelMonitorUpdate was
- * corrupted.
- * Contains a developer-readable error message.
+ * A timestamp that refers to a date after 1 January 1970 which means its representation as UNIX
+ * timestamp is positive.
+ *
+ * # Invariants
+ * The UNIX timestamp representing the stored time has to be positive and small enough so that
+ * a `EpiryTime` can be added to it without an overflow.
*/
-typedef struct MUST_USE_STRUCT LDKMonitorUpdateError {
+typedef struct MUST_USE_STRUCT LDKPositiveTimestamp {
/**
* 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.
*/
- LDKnativeMonitorUpdateError *inner;
+ LDKnativePositiveTimestamp *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;
-} LDKMonitorUpdateError;
+} LDKPositiveTimestamp;
/**
- * The contents of CResult_NoneMonitorUpdateErrorZ
+ * The contents of CResult_PositiveTimestampCreationErrorZ
*/
-typedef union LDKCResult_NoneMonitorUpdateErrorZPtr {
+typedef union LDKCResult_PositiveTimestampCreationErrorZPtr {
/**
- * Note that this value is always NULL, as there are no contents in the OK variant
+ * A pointer to the contents in the success state.
+ * Reading from this pointer when `result_ok` is not set is undefined.
*/
- void *result;
+ struct LDKPositiveTimestamp *result;
/**
* A pointer to the contents in the error state.
* Reading from this pointer when `result_ok` is set is undefined.
*/
- struct LDKMonitorUpdateError *err;
-} LDKCResult_NoneMonitorUpdateErrorZPtr;
+ enum LDKCreationError *err;
+} LDKCResult_PositiveTimestampCreationErrorZPtr;
/**
- * A CResult_NoneMonitorUpdateErrorZ represents the result of a fallible operation,
- * containing a () on success and a crate::lightning::chain::channelmonitor::MonitorUpdateError on failure.
+ * A CResult_PositiveTimestampCreationErrorZ represents the result of a fallible operation,
+ * containing a crate::lightning_invoice::PositiveTimestamp on success and a crate::lightning_invoice::CreationError on failure.
* `result_ok` indicates the overall state, and the contents are provided via `contents`.
*/
-typedef struct LDKCResult_NoneMonitorUpdateErrorZ {
+typedef struct LDKCResult_PositiveTimestampCreationErrorZ {
/**
- * The contents of this CResult_NoneMonitorUpdateErrorZ, accessible via either
+ * The contents of this CResult_PositiveTimestampCreationErrorZ, accessible via either
* `err` or `result` depending on the state of `result_ok`.
*/
- union LDKCResult_NoneMonitorUpdateErrorZPtr contents;
+ union LDKCResult_PositiveTimestampCreationErrorZPtr contents;
/**
- * Whether this CResult_NoneMonitorUpdateErrorZ represents a success state.
+ * Whether this CResult_PositiveTimestampCreationErrorZ represents a success state.
*/
bool result_ok;
-} LDKCResult_NoneMonitorUpdateErrorZ;
+} LDKCResult_PositiveTimestampCreationErrorZ;
/**
- * A tuple of 2 elements. See the individual fields for the types contained.
+ * The contents of CResult_NoneSemanticErrorZ
*/
-typedef struct LDKC2Tuple_OutPointScriptZ {
+typedef union LDKCResult_NoneSemanticErrorZPtr {
/**
- * The element at position 0
+ * Note that this value is always NULL, as there are no contents in the OK variant
*/
- struct LDKOutPoint a;
+ void *result;
/**
- * The element at position 1
+ * A pointer to the contents in the error state.
+ * Reading from this pointer when `result_ok` is set is undefined.
*/
- struct LDKCVec_u8Z b;
-} LDKC2Tuple_OutPointScriptZ;
+ enum LDKSemanticError *err;
+} LDKCResult_NoneSemanticErrorZPtr;
/**
- * A tuple of 2 elements. See the individual fields for the types contained.
+ * A CResult_NoneSemanticErrorZ represents the result of a fallible operation,
+ * containing a () on success and a crate::lightning_invoice::SemanticError on failure.
+ * `result_ok` indicates the overall state, and the contents are provided via `contents`.
*/
-typedef struct LDKC2Tuple_u32ScriptZ {
+typedef struct LDKCResult_NoneSemanticErrorZ {
/**
- * The element at position 0
+ * The contents of this CResult_NoneSemanticErrorZ, accessible via either
+ * `err` or `result` depending on the state of `result_ok`.
*/
- uint32_t a;
+ union LDKCResult_NoneSemanticErrorZPtr contents;
/**
- * The element at position 1
+ * Whether this CResult_NoneSemanticErrorZ represents a success state.
*/
- struct LDKCVec_u8Z b;
-} LDKC2Tuple_u32ScriptZ;
+ bool result_ok;
+} LDKCResult_NoneSemanticErrorZ;
/**
- * A dynamically-allocated array of crate::c_types::derived::C2Tuple_u32ScriptZs of arbitrary size.
- * This corresponds to std::vector in C++
+ * The contents of CResult_InvoiceSemanticErrorZ
*/
-typedef struct LDKCVec_C2Tuple_u32ScriptZZ {
+typedef union LDKCResult_InvoiceSemanticErrorZPtr {
/**
- * The elements in the array.
- * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc().
+ * A pointer to the contents in the success state.
+ * Reading from this pointer when `result_ok` is not set is undefined.
*/
- struct LDKC2Tuple_u32ScriptZ *data;
+ struct LDKInvoice *result;
/**
- * The number of elements pointed to by `data`.
+ * A pointer to the contents in the error state.
+ * Reading from this pointer when `result_ok` is set is undefined.
*/
- uintptr_t datalen;
-} LDKCVec_C2Tuple_u32ScriptZZ;
+ enum LDKSemanticError *err;
+} LDKCResult_InvoiceSemanticErrorZPtr;
/**
- * A tuple of 2 elements. See the individual fields for the types contained.
+ * A CResult_InvoiceSemanticErrorZ represents the result of a fallible operation,
+ * containing a crate::lightning_invoice::Invoice on success and a crate::lightning_invoice::SemanticError on failure.
+ * `result_ok` indicates the overall state, and the contents are provided via `contents`.
*/
-typedef struct LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ {
+typedef struct LDKCResult_InvoiceSemanticErrorZ {
/**
- * The element at position 0
+ * The contents of this CResult_InvoiceSemanticErrorZ, accessible via either
+ * `err` or `result` depending on the state of `result_ok`.
*/
- struct LDKThirtyTwoBytes a;
+ union LDKCResult_InvoiceSemanticErrorZPtr contents;
/**
- * The element at position 1
+ * Whether this CResult_InvoiceSemanticErrorZ represents a success state.
*/
- struct LDKCVec_C2Tuple_u32ScriptZZ b;
-} LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ;
+ bool result_ok;
+} LDKCResult_InvoiceSemanticErrorZ;
+
+
/**
- * A dynamically-allocated array of crate::c_types::derived::C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZs of arbitrary size.
- * This corresponds to std::vector in C++
+ * Description string
+ *
+ * # Invariants
+ * The description can be at most 639 __bytes__ long
*/
-typedef struct LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ {
+typedef struct MUST_USE_STRUCT LDKDescription {
/**
- * The elements in the array.
- * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc().
+ * A pointer to the opaque Rust object.
+ * Nearly everywhere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
*/
- struct LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *data;
+ LDKnativeDescription *inner;
/**
- * The number of elements pointed to by `data`.
+ * Indicates that this is the only struct which contains the same pointer.
+ * Rust functions which take ownership of an object provided via an argument require
+ * this to be true and invalidate the object pointed to by inner.
*/
- uintptr_t datalen;
-} LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ;
+ bool is_owned;
+} LDKDescription;
/**
- * Some information provided on receipt of payment depends on whether the payment received is a
- * spontaneous payment or a \"conventional\" lightning payment that's paying an invoice.
+ * The contents of CResult_DescriptionCreationErrorZ
*/
-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;
+typedef union LDKCResult_DescriptionCreationErrorZPtr {
/**
- * 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
+ * A pointer to the contents in the success state.
+ * Reading from this pointer when `result_ok` is not set is undefined.
*/
- struct LDKThirtyTwoBytes payment_secret;
+ struct LDKDescription *result;
/**
- * 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
+ * A pointer to the contents in the error state.
+ * Reading from this pointer when `result_ok` is set is undefined.
*/
- 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;
+ enum LDKCreationError *err;
+} LDKCResult_DescriptionCreationErrorZPtr;
/**
- * The reason the channel was closed. See individual variants more details.
+ * A CResult_DescriptionCreationErrorZ represents the result of a fallible operation,
+ * containing a crate::lightning_invoice::Description on success and a crate::lightning_invoice::CreationError on failure.
+ * `result_ok` indicates the overall state, and the contents are provided via `contents`.
*/
-typedef enum LDKClosureReason_Tag {
- /**
- * Closure generated from receiving a peer error message.
- *
- * Our counterparty may have broadcasted their latest commitment state, and we have
- * as well.
- */
- LDKClosureReason_CounterpartyForceClosed,
- /**
- * Closure generated from [`ChannelManager::force_close_channel`], called by the user.
- *
- * [`ChannelManager::force_close_channel`]: crate::ln::channelmanager::ChannelManager::force_close_channel.
- */
- LDKClosureReason_HolderForceClosed,
- /**
- * The channel was closed after negotiating a cooperative close and we've now broadcasted
- * the cooperative close transaction. Note the shutdown may have been initiated by us.
- */
- LDKClosureReason_CooperativeClosure,
- /**
- * A commitment transaction was confirmed on chain, closing the channel. Most likely this
- * commitment transaction came from our counterparty, but it may also have come from
- * a copy of our own `ChannelMonitor`.
- */
- LDKClosureReason_CommitmentTxConfirmed,
- /**
- * Closure generated from processing an event, likely a HTLC forward/relay/reception.
- */
- LDKClosureReason_ProcessingError,
- /**
- * The `PeerManager` informed us that we've disconnected from the peer. We close channels
- * if the `PeerManager` informed us that it is unlikely we'll be able to connect to the
- * peer again in the future or if the peer disconnected before we finished negotiating
- * the channel open. The first case may be caused by incompatible features which our
- * counterparty, or we, require.
- */
- LDKClosureReason_DisconnectedPeer,
- /**
- * Closure generated from `ChannelManager::read` if the ChannelMonitor is newer than
- * the ChannelManager deserialized.
- */
- LDKClosureReason_OutdatedChannelManager,
- /**
- * Must be last for serialization purposes
- */
- LDKClosureReason_Sentinel,
-} LDKClosureReason_Tag;
-
-typedef struct LDKClosureReason_LDKCounterpartyForceClosed_Body {
+typedef struct LDKCResult_DescriptionCreationErrorZ {
/**
- * The error which the peer sent us.
- *
- * The string should be sanitized before it is used (e.g emitted to logs
- * or printed to stdout). Otherwise, a well crafted error message may exploit
- * a security vulnerability in the terminal emulator or the logging subsystem.
+ * The contents of this CResult_DescriptionCreationErrorZ, accessible via either
+ * `err` or `result` depending on the state of `result_ok`.
*/
- struct LDKStr peer_msg;
-} LDKClosureReason_LDKCounterpartyForceClosed_Body;
-
-typedef struct LDKClosureReason_LDKProcessingError_Body {
+ union LDKCResult_DescriptionCreationErrorZPtr contents;
/**
- * A developer-readable error message which we generated.
+ * Whether this CResult_DescriptionCreationErrorZ represents a success state.
*/
- struct LDKStr err;
-} LDKClosureReason_LDKProcessingError_Body;
+ bool result_ok;
+} LDKCResult_DescriptionCreationErrorZ;
+
-typedef struct MUST_USE_STRUCT LDKClosureReason {
- LDKClosureReason_Tag tag;
- union {
- LDKClosureReason_LDKCounterpartyForceClosed_Body counterparty_force_closed;
- LDKClosureReason_LDKProcessingError_Body processing_error;
- };
-} LDKClosureReason;
/**
- * An Event which you should probably take some action in response to.
+ * Positive duration that defines when (relatively to the timestamp) in the future the invoice
+ * expires
*
- * Note that while Writeable and Readable are implemented for Event, you probably shouldn't use
- * them directly as they don't round-trip exactly (for example FundingGenerationReady is never
- * written as it makes no sense to respond to it after reconnecting to peers).
+ * # Invariants
+ * The number of seconds this expiry time represents has to be in the range
+ * `0...(SYSTEM_TIME_MAX_UNIX_TIMESTAMP - MAX_EXPIRY_TIME)` to avoid overflows when adding it to a
+ * timestamp
*/
-typedef enum LDKEvent_Tag {
+typedef struct MUST_USE_STRUCT LDKExpiryTime {
/**
- * Used to indicate that the client should generate a funding transaction with the given
- * parameters and then call ChannelManager::funding_transaction_generated.
- * Generated in ChannelManager message handling.
- * Note that *all inputs* in the funding transaction must spend SegWit outputs or your
- * counterparty can steal your funds!
+ * 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.
*/
- LDKEvent_FundingGenerationReady,
+ LDKnativeExpiryTime *inner;
/**
- * Indicates we've received money! Just gotta dig out that payment preimage and feed it to
- * [`ChannelManager::claim_funds`] to get it....
- * Note that if the preimage is not known, you should call
- * [`ChannelManager::fail_htlc_backwards`] to free up resources for this HTLC and avoid
- * network congestion.
- * If you fail to call either [`ChannelManager::claim_funds`] or
- * [`ChannelManager::fail_htlc_backwards`] within the HTLC's timeout, the HTLC will be
- * automatically failed.
- *
- * [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds
- * [`ChannelManager::fail_htlc_backwards`]: crate::ln::channelmanager::ChannelManager::fail_htlc_backwards
+ * 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.
*/
- LDKEvent_PaymentReceived,
+ bool is_owned;
+} LDKExpiryTime;
+
+/**
+ * The contents of CResult_ExpiryTimeCreationErrorZ
+ */
+typedef union LDKCResult_ExpiryTimeCreationErrorZPtr {
/**
- * Indicates an outbound payment we made succeeded (i.e. it made it all the way to its target
- * and we got back the payment preimage for it).
- *
- * Note for MPP payments: in rare cases, this event may be preceded by a `PaymentPathFailed`
- * event. In this situation, you SHOULD treat this payment as having succeeded.
+ * A pointer to the contents in the success state.
+ * Reading from this pointer when `result_ok` is not set is undefined.
*/
- LDKEvent_PaymentSent,
+ struct LDKExpiryTime *result;
/**
- * Indicates an outbound payment we made failed. Probably some intermediary node dropped
- * something. You may wish to retry with a different route.
+ * A pointer to the contents in the error state.
+ * Reading from this pointer when `result_ok` is set is undefined.
*/
- LDKEvent_PaymentPathFailed,
+ enum LDKCreationError *err;
+} LDKCResult_ExpiryTimeCreationErrorZPtr;
+
+/**
+ * A CResult_ExpiryTimeCreationErrorZ represents the result of a fallible operation,
+ * containing a crate::lightning_invoice::ExpiryTime on success and a crate::lightning_invoice::CreationError on failure.
+ * `result_ok` indicates the overall state, and the contents are provided via `contents`.
+ */
+typedef struct LDKCResult_ExpiryTimeCreationErrorZ {
/**
- * Used to indicate that ChannelManager::process_pending_htlc_forwards should be called at a
- * time in the future.
+ * The contents of this CResult_ExpiryTimeCreationErrorZ, accessible via either
+ * `err` or `result` depending on the state of `result_ok`.
*/
- LDKEvent_PendingHTLCsForwardable,
+ union LDKCResult_ExpiryTimeCreationErrorZPtr contents;
/**
- * Used to indicate that an output which you should know how to spend was confirmed on chain
- * and is now spendable.
- * Such an output will *not* ever be spent by rust-lightning, and are not at risk of your
- * counterparty spending them due to some kind of timeout. Thus, you need to store them
- * somewhere and spend them when you create on-chain transactions.
+ * Whether this CResult_ExpiryTimeCreationErrorZ represents a success state.
*/
- LDKEvent_SpendableOutputs,
+ bool result_ok;
+} LDKCResult_ExpiryTimeCreationErrorZ;
+
+/**
+ * The contents of CResult_PrivateRouteCreationErrorZ
+ */
+typedef union LDKCResult_PrivateRouteCreationErrorZPtr {
/**
- * This event is generated when a payment has been successfully forwarded through us and a
- * forwarding fee earned.
+ * A pointer to the contents in the success state.
+ * Reading from this pointer when `result_ok` is not set is undefined.
*/
- LDKEvent_PaymentForwarded,
+ struct LDKPrivateRoute *result;
/**
- * Used to indicate that a channel with the given `channel_id` is in the process of closure.
+ * A pointer to the contents in the error state.
+ * Reading from this pointer when `result_ok` is set is undefined.
*/
- LDKEvent_ChannelClosed,
+ enum LDKCreationError *err;
+} LDKCResult_PrivateRouteCreationErrorZPtr;
+
+/**
+ * A CResult_PrivateRouteCreationErrorZ represents the result of a fallible operation,
+ * containing a crate::lightning_invoice::PrivateRoute on success and a crate::lightning_invoice::CreationError on failure.
+ * `result_ok` indicates the overall state, and the contents are provided via `contents`.
+ */
+typedef struct LDKCResult_PrivateRouteCreationErrorZ {
/**
- * Used to indicate to the user that they can abandon the funding transaction and recycle the
- * inputs for another purpose.
+ * The contents of this CResult_PrivateRouteCreationErrorZ, accessible via either
+ * `err` or `result` depending on the state of `result_ok`.
*/
- LDKEvent_DiscardFunding,
+ union LDKCResult_PrivateRouteCreationErrorZPtr contents;
/**
- * Must be last for serialization purposes
+ * Whether this CResult_PrivateRouteCreationErrorZ represents a success state.
*/
- LDKEvent_Sentinel,
-} LDKEvent_Tag;
+ bool result_ok;
+} LDKCResult_PrivateRouteCreationErrorZ;
-typedef struct LDKEvent_LDKFundingGenerationReady_Body {
+/**
+ * The contents of CResult_StringErrorZ
+ */
+typedef union LDKCResult_StringErrorZPtr {
/**
- * The random channel_id we picked which you'll need to pass into
- * ChannelManager::funding_transaction_generated.
+ * A pointer to the contents in the success state.
+ * Reading from this pointer when `result_ok` is not set is undefined.
*/
- struct LDKThirtyTwoBytes temporary_channel_id;
+ struct LDKStr *result;
/**
- * The value, in satoshis, that the output should have.
+ * A pointer to the contents in the error state.
+ * Reading from this pointer when `result_ok` is set is undefined.
*/
- uint64_t channel_value_satoshis;
+ enum LDKSecp256k1Error *err;
+} LDKCResult_StringErrorZPtr;
+
+/**
+ * A CResult_StringErrorZ represents the result of a fallible operation,
+ * containing a crate::c_types::Str on success and a crate::c_types::Secp256k1Error on failure.
+ * `result_ok` indicates the overall state, and the contents are provided via `contents`.
+ */
+typedef struct LDKCResult_StringErrorZ {
/**
- * The script which should be used in the transaction output.
+ * The contents of this CResult_StringErrorZ, accessible via either
+ * `err` or `result` depending on the state of `result_ok`.
*/
- struct LDKCVec_u8Z output_script;
+ union LDKCResult_StringErrorZPtr contents;
/**
- * The `user_channel_id` value passed in to [`ChannelManager::create_channel`], or 0 for
- * an inbound channel.
- *
- * [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
+ * Whether this CResult_StringErrorZ represents a success state.
*/
- uint64_t user_channel_id;
-} LDKEvent_LDKFundingGenerationReady_Body;
+ bool result_ok;
+} LDKCResult_StringErrorZ;
-typedef struct LDKEvent_LDKPaymentReceived_Body {
+/**
+ * The contents of CResult_ChannelMonitorUpdateDecodeErrorZ
+ */
+typedef union LDKCResult_ChannelMonitorUpdateDecodeErrorZPtr {
/**
- * The hash for which the preimage should be handed to the ChannelManager.
+ * A pointer to the contents in the success state.
+ * Reading from this pointer when `result_ok` is not set is undefined.
*/
- struct LDKThirtyTwoBytes payment_hash;
+ struct LDKChannelMonitorUpdate *result;
/**
- * The value, in thousandths of a satoshi, that this payment is for.
+ * A pointer to the contents in the error state.
+ * Reading from this pointer when `result_ok` is set is undefined.
*/
- uint64_t amt;
+ struct LDKDecodeError *err;
+} LDKCResult_ChannelMonitorUpdateDecodeErrorZPtr;
+
+/**
+ * A CResult_ChannelMonitorUpdateDecodeErrorZ represents the result of a fallible operation,
+ * containing a crate::lightning::chain::channelmonitor::ChannelMonitorUpdate on success and a crate::lightning::ln::msgs::DecodeError on failure.
+ * `result_ok` indicates the overall state, and the contents are provided via `contents`.
+ */
+typedef struct LDKCResult_ChannelMonitorUpdateDecodeErrorZ {
/**
- * 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.
+ * The contents of this CResult_ChannelMonitorUpdateDecodeErrorZ, accessible via either
+ * `err` or `result` depending on the state of `result_ok`.
*/
- struct LDKPaymentPurpose purpose;
-} LDKEvent_LDKPaymentReceived_Body;
-
-typedef struct LDKEvent_LDKPaymentSent_Body {
+ union LDKCResult_ChannelMonitorUpdateDecodeErrorZPtr contents;
/**
- * The id returned by [`ChannelManager::send_payment`] and used with
- * [`ChannelManager::retry_payment`].
- *
- * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
- * [`ChannelManager::retry_payment`]: crate::ln::channelmanager::ChannelManager::retry_payment
- *
- * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
+ * Whether this CResult_ChannelMonitorUpdateDecodeErrorZ represents a success state.
*/
- struct LDKThirtyTwoBytes payment_id;
+ bool result_ok;
+} LDKCResult_ChannelMonitorUpdateDecodeErrorZ;
+
+/**
+ * An enum which can either contain a crate::lightning::chain::channelmonitor::MonitorEvent or not
+ */
+typedef enum LDKCOption_MonitorEventZ_Tag {
/**
- * The preimage to the hash given to ChannelManager::send_payment.
- * Note that this serves as a payment receipt, if you wish to have such a thing, you must
- * store it somehow!
+ * When we're in this state, this COption_MonitorEventZ contains a crate::lightning::chain::channelmonitor::MonitorEvent
*/
- struct LDKThirtyTwoBytes payment_preimage;
+ LDKCOption_MonitorEventZ_Some,
/**
- * The hash which was given to [`ChannelManager::send_payment`].
- *
- * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
+ * When we're in this state, this COption_MonitorEventZ contains nothing
*/
- struct LDKThirtyTwoBytes payment_hash;
+ LDKCOption_MonitorEventZ_None,
/**
- * The total fee which was spent at intermediate hops in this payment, across all paths.
- *
- * Note that, like [`Route::get_total_fees`] this does *not* include any potential
- * overpayment to the recipient node.
- *
- * If the recipient or an intermediate node misbehaves and gives us free money, this may
- * overstate the amount paid, though this is unlikely.
- *
- * [`Route::get_total_fees`]: crate::routing::router::Route::get_total_fees
+ * Must be last for serialization purposes
*/
- struct LDKCOption_u64Z fee_paid_msat;
-} LDKEvent_LDKPaymentSent_Body;
+ LDKCOption_MonitorEventZ_Sentinel,
+} LDKCOption_MonitorEventZ_Tag;
-typedef struct LDKEvent_LDKPaymentPathFailed_Body {
+typedef struct LDKCOption_MonitorEventZ {
+ LDKCOption_MonitorEventZ_Tag tag;
+ union {
+ struct {
+ struct LDKMonitorEvent some;
+ };
+ };
+} LDKCOption_MonitorEventZ;
+
+/**
+ * The contents of CResult_COption_MonitorEventZDecodeErrorZ
+ */
+typedef union LDKCResult_COption_MonitorEventZDecodeErrorZPtr {
/**
- * The id returned by [`ChannelManager::send_payment`] and used with
- * [`ChannelManager::retry_payment`].
- *
- * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
- * [`ChannelManager::retry_payment`]: crate::ln::channelmanager::ChannelManager::retry_payment
- *
- * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
+ * A pointer to the contents in the success state.
+ * Reading from this pointer when `result_ok` is not set is undefined.
*/
- struct LDKThirtyTwoBytes payment_id;
+ struct LDKCOption_MonitorEventZ *result;
/**
- * The hash which was given to ChannelManager::send_payment.
+ * A pointer to the contents in the error state.
+ * Reading from this pointer when `result_ok` is set is undefined.
*/
- struct LDKThirtyTwoBytes payment_hash;
+ struct LDKDecodeError *err;
+} LDKCResult_COption_MonitorEventZDecodeErrorZPtr;
+
+/**
+ * A CResult_COption_MonitorEventZDecodeErrorZ represents the result of a fallible operation,
+ * containing a crate::c_types::derived::COption_MonitorEventZ on success and a crate::lightning::ln::msgs::DecodeError on failure.
+ * `result_ok` indicates the overall state, and the contents are provided via `contents`.
+ */
+typedef struct LDKCResult_COption_MonitorEventZDecodeErrorZ {
/**
- * Indicates the payment was rejected for some reason by the recipient. This implies that
- * the payment has failed, not just the route in question. If this is not set, you may
- * retry the payment via a different route.
+ * The contents of this CResult_COption_MonitorEventZDecodeErrorZ, accessible via either
+ * `err` or `result` depending on the state of `result_ok`.
*/
- bool rejected_by_dest;
+ union LDKCResult_COption_MonitorEventZDecodeErrorZPtr contents;
/**
- * Any failure information conveyed via the Onion return packet by a node along the failed
- * payment route.
- *
- * Should be applied to the [`NetworkGraph`] so that routing decisions can take into
- * account the update. [`NetGraphMsgHandler`] is capable of doing this.
- *
- * [`NetworkGraph`]: crate::routing::network_graph::NetworkGraph
- * [`NetGraphMsgHandler`]: crate::routing::network_graph::NetGraphMsgHandler
+ * Whether this CResult_COption_MonitorEventZDecodeErrorZ represents a success state.
*/
- struct LDKCOption_NetworkUpdateZ network_update;
+ bool result_ok;
+} LDKCResult_COption_MonitorEventZDecodeErrorZ;
+
+/**
+ * The contents of CResult_HTLCUpdateDecodeErrorZ
+ */
+typedef union LDKCResult_HTLCUpdateDecodeErrorZPtr {
/**
- * For both single-path and multi-path payments, this is set if all paths of the payment have
- * failed. This will be set to false if (1) this is an MPP payment and (2) other parts of the
- * larger MPP payment were still in flight when this event was generated.
+ * A pointer to the contents in the success state.
+ * Reading from this pointer when `result_ok` is not set is undefined.
*/
- bool all_paths_failed;
+ struct LDKHTLCUpdate *result;
/**
- * The payment path that failed.
+ * A pointer to the contents in the error state.
+ * Reading from this pointer when `result_ok` is set is undefined.
*/
- struct LDKCVec_RouteHopZ path;
+ struct LDKDecodeError *err;
+} LDKCResult_HTLCUpdateDecodeErrorZPtr;
+
+/**
+ * A CResult_HTLCUpdateDecodeErrorZ represents the result of a fallible operation,
+ * containing a crate::lightning::chain::channelmonitor::HTLCUpdate on success and a crate::lightning::ln::msgs::DecodeError on failure.
+ * `result_ok` indicates the overall state, and the contents are provided via `contents`.
+ */
+typedef struct LDKCResult_HTLCUpdateDecodeErrorZ {
/**
- * The channel responsible for the failed payment path.
- *
- * If this is `Some`, then the corresponding channel should be avoided when the payment is
- * retried. May be `None` for older [`Event`] serializations.
+ * The contents of this CResult_HTLCUpdateDecodeErrorZ, accessible via either
+ * `err` or `result` depending on the state of `result_ok`.
*/
- struct LDKCOption_u64Z short_channel_id;
+ union LDKCResult_HTLCUpdateDecodeErrorZPtr contents;
/**
- * Parameters needed to compute a new [`Route`] when retrying the failed payment path.
- *
- * See [`find_route`] for details.
- *
- * [`Route`]: crate::routing::router::Route
- * [`find_route`]: crate::routing::router::find_route
- *
- * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
+ * Whether this CResult_HTLCUpdateDecodeErrorZ represents a success state.
*/
- struct LDKRouteParameters retry;
-} LDKEvent_LDKPaymentPathFailed_Body;
+ bool result_ok;
+} LDKCResult_HTLCUpdateDecodeErrorZ;
-typedef struct LDKEvent_LDKPendingHTLCsForwardable_Body {
+/**
+ * A tuple of 2 elements. See the individual fields for the types contained.
+ */
+typedef struct LDKC2Tuple_OutPointScriptZ {
/**
- * The minimum amount of time that should be waited prior to calling
- * process_pending_htlc_forwards. To increase the effort required to correlate payments,
- * you should wait a random amount of time in roughly the range (now + time_forwardable,
- * now + 5*time_forwardable).
+ * The element at position 0
*/
- uint64_t time_forwardable;
-} LDKEvent_LDKPendingHTLCsForwardable_Body;
-
-typedef struct LDKEvent_LDKSpendableOutputs_Body {
+ struct LDKOutPoint a;
/**
- * The outputs which you should store as spendable by you.
+ * The element at position 1
*/
- struct LDKCVec_SpendableOutputDescriptorZ outputs;
-} LDKEvent_LDKSpendableOutputs_Body;
+ struct LDKCVec_u8Z b;
+} LDKC2Tuple_OutPointScriptZ;
-typedef struct LDKEvent_LDKPaymentForwarded_Body {
+/**
+ * A tuple of 2 elements. See the individual fields for the types contained.
+ */
+typedef struct LDKC2Tuple_u32ScriptZ {
/**
- * 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`.
+ * The element at position 0
*/
- struct LDKCOption_u64Z fee_earned_msat;
+ uint32_t a;
/**
- * If this is `true`, the forwarded HTLC was claimed by our counterparty via an on-chain
- * transaction.
+ * The element at position 1
*/
- bool claim_from_onchain_tx;
-} LDKEvent_LDKPaymentForwarded_Body;
+ struct LDKCVec_u8Z b;
+} LDKC2Tuple_u32ScriptZ;
-typedef struct LDKEvent_LDKChannelClosed_Body {
+/**
+ * A dynamically-allocated array of crate::c_types::derived::C2Tuple_u32ScriptZs of arbitrary size.
+ * This corresponds to std::vector in C++
+ */
+typedef struct LDKCVec_C2Tuple_u32ScriptZZ {
/**
- * The channel_id of the channel which has been closed. Note that on-chain transactions
- * resolving the channel are likely still awaiting confirmation.
+ * The elements in the array.
+ * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc().
*/
- struct LDKThirtyTwoBytes channel_id;
+ struct LDKC2Tuple_u32ScriptZ *data;
/**
- * The `user_channel_id` value passed in to [`ChannelManager::create_channel`], or 0 for
- * an inbound channel. This will always be zero for objects serialized with LDK versions
- * prior to 0.0.102.
- *
- * [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
+ * The number of elements pointed to by `data`.
*/
- uint64_t user_channel_id;
+ uintptr_t datalen;
+} LDKCVec_C2Tuple_u32ScriptZZ;
+
+/**
+ * A tuple of 2 elements. See the individual fields for the types contained.
+ */
+typedef struct LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ {
/**
- * The reason the channel was closed.
+ * The element at position 0
*/
- struct LDKClosureReason reason;
-} LDKEvent_LDKChannelClosed_Body;
+ struct LDKThirtyTwoBytes a;
+ /**
+ * The element at position 1
+ */
+ struct LDKCVec_C2Tuple_u32ScriptZZ b;
+} LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ;
-typedef struct LDKEvent_LDKDiscardFunding_Body {
+/**
+ * A dynamically-allocated array of crate::c_types::derived::C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZs of arbitrary size.
+ * This corresponds to std::vector in C++
+ */
+typedef struct LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ {
/**
- * The channel_id of the channel which has been closed.
+ * The elements in the array.
+ * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc().
*/
- struct LDKThirtyTwoBytes channel_id;
+ struct LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *data;
/**
- * The full transaction received from the user
+ * The number of elements pointed to by `data`.
*/
- struct LDKTransaction transaction;
-} LDKEvent_LDKDiscardFunding_Body;
-
-typedef struct MUST_USE_STRUCT LDKEvent {
- LDKEvent_Tag tag;
- union {
- LDKEvent_LDKFundingGenerationReady_Body funding_generation_ready;
- LDKEvent_LDKPaymentReceived_Body payment_received;
- LDKEvent_LDKPaymentSent_Body payment_sent;
- LDKEvent_LDKPaymentPathFailed_Body payment_path_failed;
- LDKEvent_LDKPendingHTLCsForwardable_Body pending_htl_cs_forwardable;
- LDKEvent_LDKSpendableOutputs_Body spendable_outputs;
- LDKEvent_LDKPaymentForwarded_Body payment_forwarded;
- LDKEvent_LDKChannelClosed_Body channel_closed;
- LDKEvent_LDKDiscardFunding_Body discard_funding;
- };
-} LDKEvent;
+ uintptr_t datalen;
+} LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ;
/**
* A dynamically-allocated array of crate::lightning::util::events::Events of arbitrary size.
bool result_ok;
} LDKCResult_NodeIdDecodeErrorZ;
+/**
+ * The contents of CResult_COption_NetworkUpdateZDecodeErrorZ
+ */
+typedef union LDKCResult_COption_NetworkUpdateZDecodeErrorZPtr {
+ /**
+ * A pointer to the contents in the success state.
+ * Reading from this pointer when `result_ok` is not set is undefined.
+ */
+ struct LDKCOption_NetworkUpdateZ *result;
+ /**
+ * A pointer to the contents in the error state.
+ * Reading from this pointer when `result_ok` is set is undefined.
+ */
+ struct LDKDecodeError *err;
+} LDKCResult_COption_NetworkUpdateZDecodeErrorZPtr;
+
+/**
+ * A CResult_COption_NetworkUpdateZDecodeErrorZ represents the result of a fallible operation,
+ * containing a crate::c_types::derived::COption_NetworkUpdateZ on success and a crate::lightning::ln::msgs::DecodeError on failure.
+ * `result_ok` indicates the overall state, and the contents are provided via `contents`.
+ */
+typedef struct LDKCResult_COption_NetworkUpdateZDecodeErrorZ {
+ /**
+ * The contents of this CResult_COption_NetworkUpdateZDecodeErrorZ, accessible via either
+ * `err` or `result` depending on the state of `result_ok`.
+ */
+ union LDKCResult_COption_NetworkUpdateZDecodeErrorZPtr contents;
+ /**
+ * Whether this CResult_COption_NetworkUpdateZDecodeErrorZ represents a success state.
+ */
+ bool result_ok;
+} LDKCResult_COption_NetworkUpdateZDecodeErrorZ;
+
/**
* The `Access` trait defines behavior for accessing chain data and state, such as blocks and
* UTXOs.
* This is derived from the holder/counterparty-organized ChannelTransactionParameters via the
* as_holder_broadcastable and as_counterparty_broadcastable functions.
*/
-typedef struct MUST_USE_STRUCT LDKDirectedChannelTransactionParameters {
+typedef struct MUST_USE_STRUCT LDKDirectedChannelTransactionParameters {
+ /**
+ * A pointer to the opaque Rust object.
+ * Nearly everywhere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeDirectedChannelTransactionParameters *inner;
+ /**
+ * Indicates that this is the only struct which contains the same pointer.
+ * Rust functions which take ownership of an object provided via an argument require
+ * this to be true and invalidate the object pointed to by inner.
+ */
+ bool is_owned;
+} LDKDirectedChannelTransactionParameters;
+
+
+
+/**
+ * A read-only view of [`NetworkGraph`].
+ */
+typedef struct MUST_USE_STRUCT LDKReadOnlyNetworkGraph {
+ /**
+ * A pointer to the opaque Rust object.
+ * Nearly everywhere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeReadOnlyNetworkGraph *inner;
+ /**
+ * Indicates that this is the only struct which contains the same pointer.
+ * Rust functions which take ownership of an object provided via an argument require
+ * this to be true and invalidate the object pointed to by inner.
+ */
+ bool is_owned;
+} LDKReadOnlyNetworkGraph;
+
+
+
+/**
+ * Receives and validates network updates from peers,
+ * stores authentic and relevant data as a network graph.
+ * This network graph is then used for routing payments.
+ * Provides interface to help with initial routing sync by
+ * serving historical announcements.
+ *
+ * Serves as an [`EventHandler`] for applying updates from [`Event::PaymentPathFailed`] to the
+ * [`NetworkGraph`].
+ */
+typedef struct MUST_USE_STRUCT LDKNetGraphMsgHandler {
/**
* A pointer to the opaque Rust object.
* Nearly everywhere, inner must be non-null, however in places where
* the Rust equivalent takes an Option, it may be set to null to indicate None.
*/
- LDKnativeDirectedChannelTransactionParameters *inner;
+ LDKnativeNetGraphMsgHandler *inner;
/**
* Indicates that this is the only struct which contains the same pointer.
* Rust functions which take ownership of an object provided via an argument require
* this to be true and invalidate the object pointed to by inner.
*/
bool is_owned;
-} LDKDirectedChannelTransactionParameters;
+} LDKNetGraphMsgHandler;
/**
* An interface used to score payment channels for path finding.
*/
void *this_arg;
/**
- * Returns the fee in msats willing to be paid to avoid routing through the given channel
- * in the direction from `source` to `target`.
+ * Returns the fee in msats willing to be paid to avoid routing `send_amt_msat` through the
+ * given channel in the direction from `source` to `target`.
+ *
+ * The channel's capacity (less any other MPP parts which are also being considered for use in
+ * the same payment) is given by `channel_capacity_msat`. It may be guessed from various
+ * sources or assumed from no data at all.
+ *
+ * For hints provided in the invoice, we assume the channel has sufficient capacity to accept
+ * the invoice's full amount, and provide a `channel_capacity_msat` of `None`. In all other
+ * cases it is set to `Some`, even if we're guessing at the channel value.
+ *
+ * Your code should be overflow-safe through a `channel_capacity_msat` of 21 million BTC.
*/
- uint64_t (*channel_penalty_msat)(const void *this_arg, uint64_t short_channel_id, const struct LDKNodeId *NONNULL_PTR source, const struct LDKNodeId *NONNULL_PTR target);
+ uint64_t (*channel_penalty_msat)(const void *this_arg, uint64_t short_channel_id, uint64_t send_amt_msat, struct LDKCOption_u64Z channel_capacity_msat, const struct LDKNodeId *NONNULL_PTR source, const struct LDKNodeId *NONNULL_PTR target);
/**
* Handles updating channel penalties after failing to route through a channel.
*/
void (*payment_path_failed)(void *this_arg, struct LDKCVec_RouteHopZ path, uint64_t short_channel_id);
+ /**
+ * Handles updating channel penalties after successfully routing along a path.
+ */
+ void (*payment_path_successful)(void *this_arg, struct LDKCVec_RouteHopZ path);
/**
* Serialize the object into a byte array
*/
void (*free)(void *this_arg);
} LDKScore;
-
-
/**
* A scorer that is accessed under a lock.
*
*
* [`find_route`]: crate::routing::router::find_route
*/
-typedef struct MUST_USE_STRUCT LDKLockableScore {
- /**
- * 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.
- */
- LDKnativeLockableScore *inner;
+typedef struct LDKLockableScore {
/**
- * Indicates that this is the only struct which contains the same pointer.
- * Rust functions which take ownership of an object provided via an argument require
- * this to be true and invalidate the object pointed to by inner.
+ * An opaque pointer which is passed to your function implementations as an argument.
+ * This has no meaning in the LDK, and can be NULL or any other value.
*/
- bool is_owned;
-} LDKLockableScore;
-
-
-
-/**
- * A read-only view of [`NetworkGraph`].
- */
-typedef struct MUST_USE_STRUCT LDKReadOnlyNetworkGraph {
+ void *this_arg;
/**
- * A pointer to the opaque Rust object.
- * Nearly everywhere, inner must be non-null, however in places where
- * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ * Returns the locked scorer.
*/
- LDKnativeReadOnlyNetworkGraph *inner;
+ struct LDKScore (*lock)(const void *this_arg);
/**
- * Indicates that this is the only struct which contains the same pointer.
- * Rust functions which take ownership of an object provided via an argument require
- * this to be true and invalidate the object pointed to by inner.
+ * Frees any resources associated with this object given its this_arg pointer.
+ * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
*/
- bool is_owned;
-} LDKReadOnlyNetworkGraph;
+ void (*free)(void *this_arg);
+} LDKLockableScore;
/**
- * Receives and validates network updates from peers,
- * stores authentic and relevant data as a network graph.
- * This network graph is then used for routing payments.
- * Provides interface to help with initial routing sync by
- * serving historical announcements.
- *
- * Serves as an [`EventHandler`] for applying updates from [`Event::PaymentPathFailed`] to the
- * [`NetworkGraph`].
+ * A concrete implementation of [`LockableScore`] which supports multi-threading.
*/
-typedef struct MUST_USE_STRUCT LDKNetGraphMsgHandler {
+typedef struct MUST_USE_STRUCT LDKMultiThreadedLockableScore {
/**
* A pointer to the opaque Rust object.
* Nearly everywhere, inner must be non-null, however in places where
* the Rust equivalent takes an Option, it may be set to null to indicate None.
*/
- LDKnativeNetGraphMsgHandler *inner;
+ LDKnativeMultiThreadedLockableScore *inner;
/**
* Indicates that this is the only struct which contains the same pointer.
* Rust functions which take ownership of an object provided via an argument require
* this to be true and invalidate the object pointed to by inner.
*/
bool is_owned;
-} LDKNetGraphMsgHandler;
+} LDKMultiThreadedLockableScore;
* [`ChannelManager`] persistence should be done in the background.
* * Calling [`ChannelManager::timer_tick_occurred`] and [`PeerManager::timer_tick_occurred`]
* at the appropriate intervals.
+ * * Calling [`NetworkGraph::remove_stale_channels`] (if a [`NetGraphMsgHandler`] is provided to
+ * [`BackgroundProcessor::start`]).
*
* It will also call [`PeerManager::process_events`] periodically though this shouldn't be relied
* upon as doing so may result in high latency.
* Note that payment_secret (or a relevant inner pointer) may be NULL or all-0s to represent None
*/
struct LDKCResult_PaymentIdPaymentSendFailureZ (*send_payment)(const void *this_arg, const struct LDKRoute *NONNULL_PTR route, struct LDKThirtyTwoBytes payment_hash, struct LDKThirtyTwoBytes payment_secret);
+ /**
+ * Sends a spontaneous payment over the Lightning Network using the given [`Route`].
+ */
+ struct LDKCResult_PaymentIdPaymentSendFailureZ (*send_spontaneous_payment)(const void *this_arg, const struct LDKRoute *NONNULL_PTR route, struct LDKThirtyTwoBytes payment_preimage);
/**
* Retries a failed payment path for the [`PaymentId`] using the given [`Route`].
*/
struct LDKCResult_NonePaymentSendFailureZ (*retry_payment)(const void *this_arg, const struct LDKRoute *NONNULL_PTR route, struct LDKThirtyTwoBytes payment_id);
+ /**
+ * Signals that no further retries for the given payment will occur.
+ */
+ void (*abandon_payment)(const void *this_arg, struct LDKThirtyTwoBytes payment_id);
/**
* Frees any resources associated with this object given its this_arg pointer.
* Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
*
* Note that first_hops (or a relevant inner pointer) may be NULL or all-0s to represent None
*/
- struct LDKCResult_RouteLightningErrorZ (*find_route)(const void *this_arg, struct LDKPublicKey payer, const struct LDKRouteParameters *NONNULL_PTR params, struct LDKCVec_ChannelDetailsZ *first_hops, const struct LDKScore *NONNULL_PTR scorer);
+ struct LDKCResult_RouteLightningErrorZ (*find_route)(const void *this_arg, struct LDKPublicKey payer, const struct LDKRouteParameters *NONNULL_PTR params, const uint8_t (*payment_hash)[32], struct LDKCVec_ChannelDetailsZ *first_hops, const struct LDKScore *NONNULL_PTR scorer);
/**
* Frees any resources associated with this object given its this_arg pointer.
* Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
/**
- * A utility for paying [`Invoice]`s.
+ * A utility for paying [`Invoice`]s and sending spontaneous payments.
+ *
+ * See [module-level documentation] for details.
+ *
+ * [module-level documentation]: crate::payment
*/
typedef struct MUST_USE_STRUCT LDKInvoicePayer {
/**
*/
void Str_free(struct LDKStr _res);
+#if defined(LDK_DEBUG_BUILD)
+/**
+ * This function exists for memory safety testing purposes. It should never be used in production
+ * code
+ */
+const void *__unmangle_inner_ptr(const void *ptr);
+#endif
+
/**
* Creates a new CResult_SecretKeyErrorZ in the success state.
*/
*/
struct LDKCResult_SecretKeyErrorZ CResult_SecretKeyErrorZ_err(enum LDKSecp256k1Error e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_SecretKeyErrorZ_is_ok(const struct LDKCResult_SecretKeyErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_SecretKeyErrorZ.
*/
*/
struct LDKCResult_PublicKeyErrorZ CResult_PublicKeyErrorZ_err(enum LDKSecp256k1Error e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_PublicKeyErrorZ_is_ok(const struct LDKCResult_PublicKeyErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_PublicKeyErrorZ.
*/
*/
struct LDKCResult_TxCreationKeysDecodeErrorZ CResult_TxCreationKeysDecodeErrorZ_err(struct LDKDecodeError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_TxCreationKeysDecodeErrorZ_is_ok(const struct LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_TxCreationKeysDecodeErrorZ.
*/
*/
struct LDKCResult_ChannelPublicKeysDecodeErrorZ CResult_ChannelPublicKeysDecodeErrorZ_err(struct LDKDecodeError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_ChannelPublicKeysDecodeErrorZ_is_ok(const struct LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_ChannelPublicKeysDecodeErrorZ.
*/
*/
struct LDKCResult_TxCreationKeysErrorZ CResult_TxCreationKeysErrorZ_err(enum LDKSecp256k1Error e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_TxCreationKeysErrorZ_is_ok(const struct LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_TxCreationKeysErrorZ.
*/
*/
struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ CResult_HTLCOutputInCommitmentDecodeErrorZ_err(struct LDKDecodeError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(const struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_HTLCOutputInCommitmentDecodeErrorZ.
*/
*/
struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(const struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR orig);
+/**
+ * Constructs a new COption_NoneZ containing a
+ */
+enum LDKCOption_NoneZ COption_NoneZ_some(void);
+
+/**
+ * Constructs a new COption_NoneZ containing nothing
+ */
+enum LDKCOption_NoneZ COption_NoneZ_none(void);
+
+/**
+ * Frees any resources associated with the , if we are in the Some state
+ */
+void COption_NoneZ_free(enum LDKCOption_NoneZ _res);
+
/**
* Creates a new CResult_CounterpartyChannelTransactionParametersDecodeErrorZ in the success state.
*/
*/
struct LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(struct LDKDecodeError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(const struct LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_CounterpartyChannelTransactionParametersDecodeErrorZ.
*/
*/
struct LDKCResult_ChannelTransactionParametersDecodeErrorZ CResult_ChannelTransactionParametersDecodeErrorZ_err(struct LDKDecodeError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(const struct LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_ChannelTransactionParametersDecodeErrorZ.
*/
*/
struct LDKCResult_HolderCommitmentTransactionDecodeErrorZ CResult_HolderCommitmentTransactionDecodeErrorZ_err(struct LDKDecodeError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(const struct LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_HolderCommitmentTransactionDecodeErrorZ.
*/
*/
struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ CResult_BuiltCommitmentTransactionDecodeErrorZ_err(struct LDKDecodeError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(const struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_BuiltCommitmentTransactionDecodeErrorZ.
*/
*/
struct LDKCResult_TrustedClosingTransactionNoneZ CResult_TrustedClosingTransactionNoneZ_err(void);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_TrustedClosingTransactionNoneZ_is_ok(const struct LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_TrustedClosingTransactionNoneZ.
*/
*/
struct LDKCResult_CommitmentTransactionDecodeErrorZ CResult_CommitmentTransactionDecodeErrorZ_err(struct LDKDecodeError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_CommitmentTransactionDecodeErrorZ_is_ok(const struct LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_CommitmentTransactionDecodeErrorZ.
*/
*/
struct LDKCResult_TrustedCommitmentTransactionNoneZ CResult_TrustedCommitmentTransactionNoneZ_err(void);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_TrustedCommitmentTransactionNoneZ_is_ok(const struct LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_TrustedCommitmentTransactionNoneZ.
*/
*/
struct LDKCResult_CVec_SignatureZNoneZ CResult_CVec_SignatureZNoneZ_err(void);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_CVec_SignatureZNoneZ_is_ok(const struct LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_CVec_SignatureZNoneZ.
*/
*/
struct LDKCResult_ShutdownScriptDecodeErrorZ CResult_ShutdownScriptDecodeErrorZ_err(struct LDKDecodeError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_ShutdownScriptDecodeErrorZ_is_ok(const struct LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_ShutdownScriptDecodeErrorZ.
*/
*/
struct LDKCResult_ShutdownScriptInvalidShutdownScriptZ CResult_ShutdownScriptInvalidShutdownScriptZ_err(struct LDKInvalidShutdownScript e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(const struct LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_ShutdownScriptInvalidShutdownScriptZ.
*/
void CResult_ShutdownScriptInvalidShutdownScriptZ_free(struct LDKCResult_ShutdownScriptInvalidShutdownScriptZ _res);
+/**
+ * Creates a new CResult_ShutdownScriptInvalidShutdownScriptZ which has the same data as `orig`
+ * but with all dynamically-allocated buffers duplicated in new buffers.
+ */
+struct LDKCResult_ShutdownScriptInvalidShutdownScriptZ CResult_ShutdownScriptInvalidShutdownScriptZ_clone(const struct LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR orig);
+
/**
* Creates a new CResult_NoneErrorZ in the success state.
*/
*/
struct LDKCResult_NoneErrorZ CResult_NoneErrorZ_err(enum LDKIOError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_NoneErrorZ_is_ok(const struct LDKCResult_NoneErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_NoneErrorZ.
*/
*/
struct LDKCResult_RouteHopDecodeErrorZ CResult_RouteHopDecodeErrorZ_err(struct LDKDecodeError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_RouteHopDecodeErrorZ_is_ok(const struct LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_RouteHopDecodeErrorZ.
*/
*/
struct LDKCResult_RouteDecodeErrorZ CResult_RouteDecodeErrorZ_err(struct LDKDecodeError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_RouteDecodeErrorZ_is_ok(const struct LDKCResult_RouteDecodeErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_RouteDecodeErrorZ.
*/
*/
struct LDKCResult_RouteParametersDecodeErrorZ CResult_RouteParametersDecodeErrorZ_err(struct LDKDecodeError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_RouteParametersDecodeErrorZ_is_ok(const struct LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_RouteParametersDecodeErrorZ.
*/
*/
struct LDKCResult_PayeeDecodeErrorZ CResult_PayeeDecodeErrorZ_err(struct LDKDecodeError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_PayeeDecodeErrorZ_is_ok(const struct LDKCResult_PayeeDecodeErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_PayeeDecodeErrorZ.
*/
*/
struct LDKCResult_RouteHintDecodeErrorZ CResult_RouteHintDecodeErrorZ_err(struct LDKDecodeError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_RouteHintDecodeErrorZ_is_ok(const struct LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_RouteHintDecodeErrorZ.
*/
*/
struct LDKCResult_RouteHintHopDecodeErrorZ CResult_RouteHintHopDecodeErrorZ_err(struct LDKDecodeError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_RouteHintHopDecodeErrorZ_is_ok(const struct LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_RouteHintHopDecodeErrorZ.
*/
*/
struct LDKCResult_RouteLightningErrorZ CResult_RouteLightningErrorZ_err(struct LDKLightningError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_RouteLightningErrorZ_is_ok(const struct LDKCResult_RouteLightningErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_RouteLightningErrorZ.
*/
*/
struct LDKCResult_TxOutAccessErrorZ CResult_TxOutAccessErrorZ_err(enum LDKAccessError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_TxOutAccessErrorZ_is_ok(const struct LDKCResult_TxOutAccessErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_TxOutAccessErrorZ.
*/
*/
struct LDKCResult_NoneChannelMonitorUpdateErrZ CResult_NoneChannelMonitorUpdateErrZ_err(enum LDKChannelMonitorUpdateErr e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_NoneChannelMonitorUpdateErrZ_is_ok(const struct LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_NoneChannelMonitorUpdateErrZ.
*/
*/
struct LDKCOption_C2Tuple_usizeTransactionZZ COption_C2Tuple_usizeTransactionZZ_clone(const struct LDKCOption_C2Tuple_usizeTransactionZZ *NONNULL_PTR orig);
+/**
+ * Constructs a new COption_ClosureReasonZ containing a crate::lightning::util::events::ClosureReason
+ */
+struct LDKCOption_ClosureReasonZ COption_ClosureReasonZ_some(struct LDKClosureReason o);
+
+/**
+ * Constructs a new COption_ClosureReasonZ containing nothing
+ */
+struct LDKCOption_ClosureReasonZ COption_ClosureReasonZ_none(void);
+
+/**
+ * Frees any resources associated with the crate::lightning::util::events::ClosureReason, if we are in the Some state
+ */
+void COption_ClosureReasonZ_free(struct LDKCOption_ClosureReasonZ _res);
+
+/**
+ * Creates a new COption_ClosureReasonZ which has the same data as `orig`
+ * but with all dynamically-allocated buffers duplicated in new buffers.
+ */
+struct LDKCOption_ClosureReasonZ COption_ClosureReasonZ_clone(const struct LDKCOption_ClosureReasonZ *NONNULL_PTR orig);
+
+/**
+ * Creates a new CResult_COption_ClosureReasonZDecodeErrorZ in the success state.
+ */
+struct LDKCResult_COption_ClosureReasonZDecodeErrorZ CResult_COption_ClosureReasonZDecodeErrorZ_ok(struct LDKCOption_ClosureReasonZ o);
+
+/**
+ * Creates a new CResult_COption_ClosureReasonZDecodeErrorZ in the error state.
+ */
+struct LDKCResult_COption_ClosureReasonZDecodeErrorZ CResult_COption_ClosureReasonZDecodeErrorZ_err(struct LDKDecodeError e);
+
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(const struct LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR o);
+
+/**
+ * Frees any resources used by the CResult_COption_ClosureReasonZDecodeErrorZ.
+ */
+void CResult_COption_ClosureReasonZDecodeErrorZ_free(struct LDKCResult_COption_ClosureReasonZDecodeErrorZ _res);
+
+/**
+ * Creates a new CResult_COption_ClosureReasonZDecodeErrorZ which has the same data as `orig`
+ * but with all dynamically-allocated buffers duplicated in new buffers.
+ */
+struct LDKCResult_COption_ClosureReasonZDecodeErrorZ CResult_COption_ClosureReasonZDecodeErrorZ_clone(const struct LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR orig);
+
/**
* Constructs a new COption_NetworkUpdateZ containing a crate::lightning::routing::network_graph::NetworkUpdate
*/
struct LDKCOption_NetworkUpdateZ COption_NetworkUpdateZ_some(struct LDKNetworkUpdate o);
/**
- * Constructs a new COption_NetworkUpdateZ containing nothing
+ * Constructs a new COption_NetworkUpdateZ containing nothing
+ */
+struct LDKCOption_NetworkUpdateZ COption_NetworkUpdateZ_none(void);
+
+/**
+ * Frees any resources associated with the crate::lightning::routing::network_graph::NetworkUpdate, if we are in the Some state
+ */
+void COption_NetworkUpdateZ_free(struct LDKCOption_NetworkUpdateZ _res);
+
+/**
+ * Creates a new COption_NetworkUpdateZ which has the same data as `orig`
+ * but with all dynamically-allocated buffers duplicated in new buffers.
+ */
+struct LDKCOption_NetworkUpdateZ COption_NetworkUpdateZ_clone(const struct LDKCOption_NetworkUpdateZ *NONNULL_PTR orig);
+
+/**
+ * Frees the buffer pointed to by `data` if `datalen` is non-0.
+ */
+void CVec_SpendableOutputDescriptorZ_free(struct LDKCVec_SpendableOutputDescriptorZ _res);
+
+/**
+ * Constructs a new COption_EventZ containing a crate::lightning::util::events::Event
+ */
+struct LDKCOption_EventZ COption_EventZ_some(struct LDKEvent o);
+
+/**
+ * Constructs a new COption_EventZ containing nothing
+ */
+struct LDKCOption_EventZ COption_EventZ_none(void);
+
+/**
+ * Frees any resources associated with the crate::lightning::util::events::Event, if we are in the Some state
+ */
+void COption_EventZ_free(struct LDKCOption_EventZ _res);
+
+/**
+ * Creates a new COption_EventZ which has the same data as `orig`
+ * but with all dynamically-allocated buffers duplicated in new buffers.
+ */
+struct LDKCOption_EventZ COption_EventZ_clone(const struct LDKCOption_EventZ *NONNULL_PTR orig);
+
+/**
+ * Creates a new CResult_COption_EventZDecodeErrorZ in the success state.
+ */
+struct LDKCResult_COption_EventZDecodeErrorZ CResult_COption_EventZDecodeErrorZ_ok(struct LDKCOption_EventZ o);
+
+/**
+ * Creates a new CResult_COption_EventZDecodeErrorZ in the error state.
+ */
+struct LDKCResult_COption_EventZDecodeErrorZ CResult_COption_EventZDecodeErrorZ_err(struct LDKDecodeError e);
+
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_COption_EventZDecodeErrorZ_is_ok(const struct LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR o);
+
+/**
+ * Frees any resources used by the CResult_COption_EventZDecodeErrorZ.
+ */
+void CResult_COption_EventZDecodeErrorZ_free(struct LDKCResult_COption_EventZDecodeErrorZ _res);
+
+/**
+ * Creates a new CResult_COption_EventZDecodeErrorZ which has the same data as `orig`
+ * but with all dynamically-allocated buffers duplicated in new buffers.
+ */
+struct LDKCResult_COption_EventZDecodeErrorZ CResult_COption_EventZDecodeErrorZ_clone(const struct LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR orig);
+
+/**
+ * Frees the buffer pointed to by `data` if `datalen` is non-0.
+ */
+void CVec_MessageSendEventZ_free(struct LDKCVec_MessageSendEventZ _res);
+
+/**
+ * Creates a new CResult_ScoringParametersDecodeErrorZ in the success state.
+ */
+struct LDKCResult_ScoringParametersDecodeErrorZ CResult_ScoringParametersDecodeErrorZ_ok(struct LDKScoringParameters o);
+
+/**
+ * Creates a new CResult_ScoringParametersDecodeErrorZ in the error state.
+ */
+struct LDKCResult_ScoringParametersDecodeErrorZ CResult_ScoringParametersDecodeErrorZ_err(struct LDKDecodeError e);
+
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_ScoringParametersDecodeErrorZ_is_ok(const struct LDKCResult_ScoringParametersDecodeErrorZ *NONNULL_PTR o);
+
+/**
+ * Frees any resources used by the CResult_ScoringParametersDecodeErrorZ.
*/
-struct LDKCOption_NetworkUpdateZ COption_NetworkUpdateZ_none(void);
+void CResult_ScoringParametersDecodeErrorZ_free(struct LDKCResult_ScoringParametersDecodeErrorZ _res);
/**
- * Frees any resources associated with the crate::lightning::routing::network_graph::NetworkUpdate, if we are in the Some state
+ * Creates a new CResult_ScorerDecodeErrorZ in the success state.
*/
-void COption_NetworkUpdateZ_free(struct LDKCOption_NetworkUpdateZ _res);
+struct LDKCResult_ScorerDecodeErrorZ CResult_ScorerDecodeErrorZ_ok(struct LDKScorer o);
/**
- * Creates a new COption_NetworkUpdateZ which has the same data as `orig`
- * but with all dynamically-allocated buffers duplicated in new buffers.
+ * Creates a new CResult_ScorerDecodeErrorZ in the error state.
*/
-struct LDKCOption_NetworkUpdateZ COption_NetworkUpdateZ_clone(const struct LDKCOption_NetworkUpdateZ *NONNULL_PTR orig);
+struct LDKCResult_ScorerDecodeErrorZ CResult_ScorerDecodeErrorZ_err(struct LDKDecodeError e);
/**
- * Frees the buffer pointed to by `data` if `datalen` is non-0.
+ * Checks if the given object is currently in the success state
*/
-void CVec_SpendableOutputDescriptorZ_free(struct LDKCVec_SpendableOutputDescriptorZ _res);
+bool CResult_ScorerDecodeErrorZ_is_ok(const struct LDKCResult_ScorerDecodeErrorZ *NONNULL_PTR o);
/**
- * Frees the buffer pointed to by `data` if `datalen` is non-0.
+ * Frees any resources used by the CResult_ScorerDecodeErrorZ.
*/
-void CVec_MessageSendEventZ_free(struct LDKCVec_MessageSendEventZ _res);
+void CResult_ScorerDecodeErrorZ_free(struct LDKCResult_ScorerDecodeErrorZ _res);
/**
* Creates a new CResult_InitFeaturesDecodeErrorZ in the success state.
*/
struct LDKCResult_InitFeaturesDecodeErrorZ CResult_InitFeaturesDecodeErrorZ_err(struct LDKDecodeError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_InitFeaturesDecodeErrorZ_is_ok(const struct LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_InitFeaturesDecodeErrorZ.
*/
void CResult_InitFeaturesDecodeErrorZ_free(struct LDKCResult_InitFeaturesDecodeErrorZ _res);
/**
- * Creates a new CResult_NodeFeaturesDecodeErrorZ in the success state.
+ * Creates a new CResult_ChannelFeaturesDecodeErrorZ in the success state.
*/
-struct LDKCResult_NodeFeaturesDecodeErrorZ CResult_NodeFeaturesDecodeErrorZ_ok(struct LDKNodeFeatures o);
+struct LDKCResult_ChannelFeaturesDecodeErrorZ CResult_ChannelFeaturesDecodeErrorZ_ok(struct LDKChannelFeatures o);
/**
- * Creates a new CResult_NodeFeaturesDecodeErrorZ in the error state.
+ * Creates a new CResult_ChannelFeaturesDecodeErrorZ in the error state.
*/
-struct LDKCResult_NodeFeaturesDecodeErrorZ CResult_NodeFeaturesDecodeErrorZ_err(struct LDKDecodeError e);
+struct LDKCResult_ChannelFeaturesDecodeErrorZ CResult_ChannelFeaturesDecodeErrorZ_err(struct LDKDecodeError e);
/**
- * Frees any resources used by the CResult_NodeFeaturesDecodeErrorZ.
+ * Checks if the given object is currently in the success state
*/
-void CResult_NodeFeaturesDecodeErrorZ_free(struct LDKCResult_NodeFeaturesDecodeErrorZ _res);
+bool CResult_ChannelFeaturesDecodeErrorZ_is_ok(const struct LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR o);
/**
- * Creates a new CResult_ChannelFeaturesDecodeErrorZ in the success state.
+ * Frees any resources used by the CResult_ChannelFeaturesDecodeErrorZ.
*/
-struct LDKCResult_ChannelFeaturesDecodeErrorZ CResult_ChannelFeaturesDecodeErrorZ_ok(struct LDKChannelFeatures o);
+void CResult_ChannelFeaturesDecodeErrorZ_free(struct LDKCResult_ChannelFeaturesDecodeErrorZ _res);
/**
- * Creates a new CResult_ChannelFeaturesDecodeErrorZ in the error state.
+ * Creates a new CResult_NodeFeaturesDecodeErrorZ in the success state.
*/
-struct LDKCResult_ChannelFeaturesDecodeErrorZ CResult_ChannelFeaturesDecodeErrorZ_err(struct LDKDecodeError e);
+struct LDKCResult_NodeFeaturesDecodeErrorZ CResult_NodeFeaturesDecodeErrorZ_ok(struct LDKNodeFeatures o);
/**
- * Frees any resources used by the CResult_ChannelFeaturesDecodeErrorZ.
+ * Creates a new CResult_NodeFeaturesDecodeErrorZ in the error state.
*/
-void CResult_ChannelFeaturesDecodeErrorZ_free(struct LDKCResult_ChannelFeaturesDecodeErrorZ _res);
+struct LDKCResult_NodeFeaturesDecodeErrorZ CResult_NodeFeaturesDecodeErrorZ_err(struct LDKDecodeError e);
+
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_NodeFeaturesDecodeErrorZ_is_ok(const struct LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR o);
+
+/**
+ * Frees any resources used by the CResult_NodeFeaturesDecodeErrorZ.
+ */
+void CResult_NodeFeaturesDecodeErrorZ_free(struct LDKCResult_NodeFeaturesDecodeErrorZ _res);
/**
* Creates a new CResult_InvoiceFeaturesDecodeErrorZ in the success state.
struct LDKCResult_InvoiceFeaturesDecodeErrorZ CResult_InvoiceFeaturesDecodeErrorZ_err(struct LDKDecodeError e);
/**
- * Frees any resources used by the CResult_InvoiceFeaturesDecodeErrorZ.
- */
-void CResult_InvoiceFeaturesDecodeErrorZ_free(struct LDKCResult_InvoiceFeaturesDecodeErrorZ _res);
-
-/**
- * Creates a new CResult_ScoringParametersDecodeErrorZ in the success state.
+ * Checks if the given object is currently in the success state
*/
-struct LDKCResult_ScoringParametersDecodeErrorZ CResult_ScoringParametersDecodeErrorZ_ok(struct LDKScoringParameters o);
+bool CResult_InvoiceFeaturesDecodeErrorZ_is_ok(const struct LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR o);
/**
- * Creates a new CResult_ScoringParametersDecodeErrorZ in the error state.
+ * Frees any resources used by the CResult_InvoiceFeaturesDecodeErrorZ.
*/
-struct LDKCResult_ScoringParametersDecodeErrorZ CResult_ScoringParametersDecodeErrorZ_err(struct LDKDecodeError e);
+void CResult_InvoiceFeaturesDecodeErrorZ_free(struct LDKCResult_InvoiceFeaturesDecodeErrorZ _res);
/**
- * Frees any resources used by the CResult_ScoringParametersDecodeErrorZ.
+ * Creates a new CResult_ChannelTypeFeaturesDecodeErrorZ in the success state.
*/
-void CResult_ScoringParametersDecodeErrorZ_free(struct LDKCResult_ScoringParametersDecodeErrorZ _res);
+struct LDKCResult_ChannelTypeFeaturesDecodeErrorZ CResult_ChannelTypeFeaturesDecodeErrorZ_ok(struct LDKChannelTypeFeatures o);
/**
- * Creates a new CResult_ScorerDecodeErrorZ in the success state.
+ * Creates a new CResult_ChannelTypeFeaturesDecodeErrorZ in the error state.
*/
-struct LDKCResult_ScorerDecodeErrorZ CResult_ScorerDecodeErrorZ_ok(struct LDKScorer o);
+struct LDKCResult_ChannelTypeFeaturesDecodeErrorZ CResult_ChannelTypeFeaturesDecodeErrorZ_err(struct LDKDecodeError e);
/**
- * Creates a new CResult_ScorerDecodeErrorZ in the error state.
+ * Checks if the given object is currently in the success state
*/
-struct LDKCResult_ScorerDecodeErrorZ CResult_ScorerDecodeErrorZ_err(struct LDKDecodeError e);
+bool CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(const struct LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR o);
/**
- * Frees any resources used by the CResult_ScorerDecodeErrorZ.
+ * Frees any resources used by the CResult_ChannelTypeFeaturesDecodeErrorZ.
*/
-void CResult_ScorerDecodeErrorZ_free(struct LDKCResult_ScorerDecodeErrorZ _res);
+void CResult_ChannelTypeFeaturesDecodeErrorZ_free(struct LDKCResult_ChannelTypeFeaturesDecodeErrorZ _res);
/**
* Creates a new CResult_DelayedPaymentOutputDescriptorDecodeErrorZ in the success state.
*/
struct LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(struct LDKDecodeError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(const struct LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_DelayedPaymentOutputDescriptorDecodeErrorZ.
*/
*/
struct LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(struct LDKDecodeError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(const struct LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_StaticPaymentOutputDescriptorDecodeErrorZ.
*/
*/
struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ CResult_SpendableOutputDescriptorDecodeErrorZ_err(struct LDKDecodeError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(const struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_SpendableOutputDescriptorDecodeErrorZ.
*/
*/
struct LDKCResult_NoneNoneZ CResult_NoneNoneZ_err(void);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_NoneNoneZ_is_ok(const struct LDKCResult_NoneNoneZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_NoneNoneZ.
*/
*/
struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err(void);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok(const struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ.
*/
*/
struct LDKCResult_SignatureNoneZ CResult_SignatureNoneZ_err(void);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_SignatureNoneZ_is_ok(const struct LDKCResult_SignatureNoneZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_SignatureNoneZ.
*/
*/
struct LDKCResult_SignDecodeErrorZ CResult_SignDecodeErrorZ_err(struct LDKDecodeError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_SignDecodeErrorZ_is_ok(const struct LDKCResult_SignDecodeErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_SignDecodeErrorZ.
*/
*/
struct LDKCResult_RecoverableSignatureNoneZ CResult_RecoverableSignatureNoneZ_err(void);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_RecoverableSignatureNoneZ_is_ok(const struct LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_RecoverableSignatureNoneZ.
*/
*/
struct LDKCResult_CVec_CVec_u8ZZNoneZ CResult_CVec_CVec_u8ZZNoneZ_err(void);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_CVec_CVec_u8ZZNoneZ_is_ok(const struct LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_CVec_CVec_u8ZZNoneZ.
*/
*/
struct LDKCResult_InMemorySignerDecodeErrorZ CResult_InMemorySignerDecodeErrorZ_err(struct LDKDecodeError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_InMemorySignerDecodeErrorZ_is_ok(const struct LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_InMemorySignerDecodeErrorZ.
*/
*/
struct LDKCResult_TransactionNoneZ CResult_TransactionNoneZ_err(void);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_TransactionNoneZ_is_ok(const struct LDKCResult_TransactionNoneZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_TransactionNoneZ.
*/
*/
struct LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(enum LDKIOError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_is_ok(const struct LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ.
*/
*/
struct LDKCResult_NoneAPIErrorZ CResult_NoneAPIErrorZ_err(struct LDKAPIError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_NoneAPIErrorZ_is_ok(const struct LDKCResult_NoneAPIErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_NoneAPIErrorZ.
*/
*/
struct LDKCResult__u832APIErrorZ CResult__u832APIErrorZ_err(struct LDKAPIError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult__u832APIErrorZ_is_ok(const struct LDKCResult__u832APIErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult__u832APIErrorZ.
*/
*/
struct LDKCResult_PaymentIdPaymentSendFailureZ CResult_PaymentIdPaymentSendFailureZ_err(struct LDKPaymentSendFailure e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_PaymentIdPaymentSendFailureZ_is_ok(const struct LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_PaymentIdPaymentSendFailureZ.
*/
*/
struct LDKCResult_NonePaymentSendFailureZ CResult_NonePaymentSendFailureZ_err(struct LDKPaymentSendFailure e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_NonePaymentSendFailureZ_is_ok(const struct LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_NonePaymentSendFailureZ.
*/
*/
struct LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(struct LDKPaymentSendFailure e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok(const struct LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ.
*/
*/
void C2Tuple_PaymentHashPaymentSecretZ_free(struct LDKC2Tuple_PaymentHashPaymentSecretZ _res);
+/**
+ * Creates a new CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ in the success state.
+ */
+struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok(struct LDKC2Tuple_PaymentHashPaymentSecretZ o);
+
+/**
+ * Creates a new CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ in the error state.
+ */
+struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err(void);
+
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok(const struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR o);
+
+/**
+ * Frees any resources used by the CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ.
+ */
+void CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free(struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ _res);
+
+/**
+ * Creates a new CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ which has the same data as `orig`
+ * but with all dynamically-allocated buffers duplicated in new buffers.
+ */
+struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(const struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR orig);
+
+/**
+ * Creates a new CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ in the success state.
+ */
+struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok(struct LDKC2Tuple_PaymentHashPaymentSecretZ o);
+
+/**
+ * Creates a new CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ in the error state.
+ */
+struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err(struct LDKAPIError e);
+
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok(const struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR o);
+
+/**
+ * Frees any resources used by the CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ.
+ */
+void CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free(struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ _res);
+
+/**
+ * Creates a new CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ which has the same data as `orig`
+ * but with all dynamically-allocated buffers duplicated in new buffers.
+ */
+struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(const struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR orig);
+
+/**
+ * Creates a new CResult_PaymentSecretNoneZ in the success state.
+ */
+struct LDKCResult_PaymentSecretNoneZ CResult_PaymentSecretNoneZ_ok(struct LDKThirtyTwoBytes o);
+
+/**
+ * Creates a new CResult_PaymentSecretNoneZ in the error state.
+ */
+struct LDKCResult_PaymentSecretNoneZ CResult_PaymentSecretNoneZ_err(void);
+
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_PaymentSecretNoneZ_is_ok(const struct LDKCResult_PaymentSecretNoneZ *NONNULL_PTR o);
+
+/**
+ * Frees any resources used by the CResult_PaymentSecretNoneZ.
+ */
+void CResult_PaymentSecretNoneZ_free(struct LDKCResult_PaymentSecretNoneZ _res);
+
+/**
+ * Creates a new CResult_PaymentSecretNoneZ which has the same data as `orig`
+ * but with all dynamically-allocated buffers duplicated in new buffers.
+ */
+struct LDKCResult_PaymentSecretNoneZ CResult_PaymentSecretNoneZ_clone(const struct LDKCResult_PaymentSecretNoneZ *NONNULL_PTR orig);
+
/**
* Creates a new CResult_PaymentSecretAPIErrorZ in the success state.
*/
*/
struct LDKCResult_PaymentSecretAPIErrorZ CResult_PaymentSecretAPIErrorZ_err(struct LDKAPIError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_PaymentSecretAPIErrorZ_is_ok(const struct LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_PaymentSecretAPIErrorZ.
*/
*/
struct LDKCResult_PaymentSecretAPIErrorZ CResult_PaymentSecretAPIErrorZ_clone(const struct LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR orig);
+/**
+ * Creates a new CResult_PaymentPreimageAPIErrorZ in the success state.
+ */
+struct LDKCResult_PaymentPreimageAPIErrorZ CResult_PaymentPreimageAPIErrorZ_ok(struct LDKThirtyTwoBytes o);
+
+/**
+ * Creates a new CResult_PaymentPreimageAPIErrorZ in the error state.
+ */
+struct LDKCResult_PaymentPreimageAPIErrorZ CResult_PaymentPreimageAPIErrorZ_err(struct LDKAPIError e);
+
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_PaymentPreimageAPIErrorZ_is_ok(const struct LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR o);
+
+/**
+ * Frees any resources used by the CResult_PaymentPreimageAPIErrorZ.
+ */
+void CResult_PaymentPreimageAPIErrorZ_free(struct LDKCResult_PaymentPreimageAPIErrorZ _res);
+
+/**
+ * Creates a new CResult_PaymentPreimageAPIErrorZ which has the same data as `orig`
+ * but with all dynamically-allocated buffers duplicated in new buffers.
+ */
+struct LDKCResult_PaymentPreimageAPIErrorZ CResult_PaymentPreimageAPIErrorZ_clone(const struct LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR orig);
+
/**
* Frees the buffer pointed to by `data` if `datalen` is non-0.
*/
*/
struct LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(struct LDKDecodeError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok(const struct LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ.
*/
*/
struct LDKCResult_ChannelConfigDecodeErrorZ CResult_ChannelConfigDecodeErrorZ_err(struct LDKDecodeError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_ChannelConfigDecodeErrorZ_is_ok(const struct LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_ChannelConfigDecodeErrorZ.
*/
*/
struct LDKCResult_OutPointDecodeErrorZ CResult_OutPointDecodeErrorZ_err(struct LDKDecodeError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_OutPointDecodeErrorZ_is_ok(const struct LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_OutPointDecodeErrorZ.
*/
*/
struct LDKCResult_COption_TypeZDecodeErrorZ CResult_COption_TypeZDecodeErrorZ_err(struct LDKDecodeError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_COption_TypeZDecodeErrorZ_is_ok(const struct LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_COption_TypeZDecodeErrorZ.
*/
*/
struct LDKCResult_PaymentIdPaymentErrorZ CResult_PaymentIdPaymentErrorZ_err(struct LDKPaymentError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_PaymentIdPaymentErrorZ_is_ok(const struct LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_PaymentIdPaymentErrorZ.
*/
*/
struct LDKCResult_SiPrefixNoneZ CResult_SiPrefixNoneZ_err(void);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_SiPrefixNoneZ_is_ok(const struct LDKCResult_SiPrefixNoneZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_SiPrefixNoneZ.
*/
*/
struct LDKCResult_InvoiceNoneZ CResult_InvoiceNoneZ_err(void);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_InvoiceNoneZ_is_ok(const struct LDKCResult_InvoiceNoneZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_InvoiceNoneZ.
*/
*/
struct LDKCResult_SignedRawInvoiceNoneZ CResult_SignedRawInvoiceNoneZ_err(void);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_SignedRawInvoiceNoneZ_is_ok(const struct LDKCResult_SignedRawInvoiceNoneZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_SignedRawInvoiceNoneZ.
*/
*/
struct LDKCResult_PayeePubKeyErrorZ CResult_PayeePubKeyErrorZ_err(enum LDKSecp256k1Error e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_PayeePubKeyErrorZ_is_ok(const struct LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_PayeePubKeyErrorZ.
*/
*/
struct LDKCResult_PositiveTimestampCreationErrorZ CResult_PositiveTimestampCreationErrorZ_err(enum LDKCreationError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_PositiveTimestampCreationErrorZ_is_ok(const struct LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_PositiveTimestampCreationErrorZ.
*/
*/
struct LDKCResult_NoneSemanticErrorZ CResult_NoneSemanticErrorZ_err(enum LDKSemanticError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_NoneSemanticErrorZ_is_ok(const struct LDKCResult_NoneSemanticErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_NoneSemanticErrorZ.
*/
*/
struct LDKCResult_InvoiceSemanticErrorZ CResult_InvoiceSemanticErrorZ_err(enum LDKSemanticError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_InvoiceSemanticErrorZ_is_ok(const struct LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_InvoiceSemanticErrorZ.
*/
*/
struct LDKCResult_DescriptionCreationErrorZ CResult_DescriptionCreationErrorZ_err(enum LDKCreationError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_DescriptionCreationErrorZ_is_ok(const struct LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_DescriptionCreationErrorZ.
*/
*/
struct LDKCResult_ExpiryTimeCreationErrorZ CResult_ExpiryTimeCreationErrorZ_err(enum LDKCreationError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_ExpiryTimeCreationErrorZ_is_ok(const struct LDKCResult_ExpiryTimeCreationErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_ExpiryTimeCreationErrorZ.
*/
*/
struct LDKCResult_PrivateRouteCreationErrorZ CResult_PrivateRouteCreationErrorZ_err(enum LDKCreationError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_PrivateRouteCreationErrorZ_is_ok(const struct LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_PrivateRouteCreationErrorZ.
*/
*/
struct LDKCResult_StringErrorZ CResult_StringErrorZ_err(enum LDKSecp256k1Error e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_StringErrorZ_is_ok(const struct LDKCResult_StringErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_StringErrorZ.
*/
*/
struct LDKCResult_ChannelMonitorUpdateDecodeErrorZ CResult_ChannelMonitorUpdateDecodeErrorZ_err(struct LDKDecodeError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(const struct LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_ChannelMonitorUpdateDecodeErrorZ.
*/
struct LDKCResult_ChannelMonitorUpdateDecodeErrorZ CResult_ChannelMonitorUpdateDecodeErrorZ_clone(const struct LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR orig);
/**
- * Creates a new CResult_HTLCUpdateDecodeErrorZ in the success state.
+ * Constructs a new COption_MonitorEventZ containing a crate::lightning::chain::channelmonitor::MonitorEvent
+ */
+struct LDKCOption_MonitorEventZ COption_MonitorEventZ_some(struct LDKMonitorEvent o);
+
+/**
+ * Constructs a new COption_MonitorEventZ containing nothing
+ */
+struct LDKCOption_MonitorEventZ COption_MonitorEventZ_none(void);
+
+/**
+ * Frees any resources associated with the crate::lightning::chain::channelmonitor::MonitorEvent, if we are in the Some state
+ */
+void COption_MonitorEventZ_free(struct LDKCOption_MonitorEventZ _res);
+
+/**
+ * Creates a new COption_MonitorEventZ which has the same data as `orig`
+ * but with all dynamically-allocated buffers duplicated in new buffers.
+ */
+struct LDKCOption_MonitorEventZ COption_MonitorEventZ_clone(const struct LDKCOption_MonitorEventZ *NONNULL_PTR orig);
+
+/**
+ * Creates a new CResult_COption_MonitorEventZDecodeErrorZ in the success state.
+ */
+struct LDKCResult_COption_MonitorEventZDecodeErrorZ CResult_COption_MonitorEventZDecodeErrorZ_ok(struct LDKCOption_MonitorEventZ o);
+
+/**
+ * Creates a new CResult_COption_MonitorEventZDecodeErrorZ in the error state.
*/
-struct LDKCResult_HTLCUpdateDecodeErrorZ CResult_HTLCUpdateDecodeErrorZ_ok(struct LDKHTLCUpdate o);
+struct LDKCResult_COption_MonitorEventZDecodeErrorZ CResult_COption_MonitorEventZDecodeErrorZ_err(struct LDKDecodeError e);
/**
- * Creates a new CResult_HTLCUpdateDecodeErrorZ in the error state.
+ * Checks if the given object is currently in the success state
*/
-struct LDKCResult_HTLCUpdateDecodeErrorZ CResult_HTLCUpdateDecodeErrorZ_err(struct LDKDecodeError e);
+bool CResult_COption_MonitorEventZDecodeErrorZ_is_ok(const struct LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR o);
/**
- * Frees any resources used by the CResult_HTLCUpdateDecodeErrorZ.
+ * Frees any resources used by the CResult_COption_MonitorEventZDecodeErrorZ.
*/
-void CResult_HTLCUpdateDecodeErrorZ_free(struct LDKCResult_HTLCUpdateDecodeErrorZ _res);
+void CResult_COption_MonitorEventZDecodeErrorZ_free(struct LDKCResult_COption_MonitorEventZDecodeErrorZ _res);
/**
- * Creates a new CResult_HTLCUpdateDecodeErrorZ which has the same data as `orig`
+ * Creates a new CResult_COption_MonitorEventZDecodeErrorZ which has the same data as `orig`
* but with all dynamically-allocated buffers duplicated in new buffers.
*/
-struct LDKCResult_HTLCUpdateDecodeErrorZ CResult_HTLCUpdateDecodeErrorZ_clone(const struct LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR orig);
+struct LDKCResult_COption_MonitorEventZDecodeErrorZ CResult_COption_MonitorEventZDecodeErrorZ_clone(const struct LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR orig);
/**
- * Creates a new CResult_NoneMonitorUpdateErrorZ in the success state.
+ * Creates a new CResult_HTLCUpdateDecodeErrorZ in the success state.
+ */
+struct LDKCResult_HTLCUpdateDecodeErrorZ CResult_HTLCUpdateDecodeErrorZ_ok(struct LDKHTLCUpdate o);
+
+/**
+ * Creates a new CResult_HTLCUpdateDecodeErrorZ in the error state.
*/
-struct LDKCResult_NoneMonitorUpdateErrorZ CResult_NoneMonitorUpdateErrorZ_ok(void);
+struct LDKCResult_HTLCUpdateDecodeErrorZ CResult_HTLCUpdateDecodeErrorZ_err(struct LDKDecodeError e);
/**
- * Creates a new CResult_NoneMonitorUpdateErrorZ in the error state.
+ * Checks if the given object is currently in the success state
*/
-struct LDKCResult_NoneMonitorUpdateErrorZ CResult_NoneMonitorUpdateErrorZ_err(struct LDKMonitorUpdateError e);
+bool CResult_HTLCUpdateDecodeErrorZ_is_ok(const struct LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR o);
/**
- * Frees any resources used by the CResult_NoneMonitorUpdateErrorZ.
+ * Frees any resources used by the CResult_HTLCUpdateDecodeErrorZ.
*/
-void CResult_NoneMonitorUpdateErrorZ_free(struct LDKCResult_NoneMonitorUpdateErrorZ _res);
+void CResult_HTLCUpdateDecodeErrorZ_free(struct LDKCResult_HTLCUpdateDecodeErrorZ _res);
/**
- * Creates a new CResult_NoneMonitorUpdateErrorZ which has the same data as `orig`
+ * Creates a new CResult_HTLCUpdateDecodeErrorZ which has the same data as `orig`
* but with all dynamically-allocated buffers duplicated in new buffers.
*/
-struct LDKCResult_NoneMonitorUpdateErrorZ CResult_NoneMonitorUpdateErrorZ_clone(const struct LDKCResult_NoneMonitorUpdateErrorZ *NONNULL_PTR orig);
+struct LDKCResult_HTLCUpdateDecodeErrorZ CResult_HTLCUpdateDecodeErrorZ_clone(const struct LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR orig);
/**
* Creates a new tuple which has the same data as `orig`
*/
struct LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(struct LDKDecodeError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok(const struct LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ.
*/
*/
struct LDKCResult_NoneLightningErrorZ CResult_NoneLightningErrorZ_err(struct LDKLightningError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_NoneLightningErrorZ_is_ok(const struct LDKCResult_NoneLightningErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_NoneLightningErrorZ.
*/
*/
struct LDKCResult_boolLightningErrorZ CResult_boolLightningErrorZ_err(struct LDKLightningError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_boolLightningErrorZ_is_ok(const struct LDKCResult_boolLightningErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_boolLightningErrorZ.
*/
*/
struct LDKCResult_CVec_u8ZPeerHandleErrorZ CResult_CVec_u8ZPeerHandleErrorZ_err(struct LDKPeerHandleError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_CVec_u8ZPeerHandleErrorZ_is_ok(const struct LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_CVec_u8ZPeerHandleErrorZ.
*/
*/
struct LDKCResult_NonePeerHandleErrorZ CResult_NonePeerHandleErrorZ_err(struct LDKPeerHandleError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_NonePeerHandleErrorZ_is_ok(const struct LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_NonePeerHandleErrorZ.
*/
*/
struct LDKCResult_boolPeerHandleErrorZ CResult_boolPeerHandleErrorZ_err(struct LDKPeerHandleError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_boolPeerHandleErrorZ_is_ok(const struct LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_boolPeerHandleErrorZ.
*/
*/
struct LDKCResult_NodeIdDecodeErrorZ CResult_NodeIdDecodeErrorZ_err(struct LDKDecodeError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_NodeIdDecodeErrorZ_is_ok(const struct LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_NodeIdDecodeErrorZ.
*/
*/
struct LDKCResult_NodeIdDecodeErrorZ CResult_NodeIdDecodeErrorZ_clone(const struct LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR orig);
+/**
+ * Creates a new CResult_COption_NetworkUpdateZDecodeErrorZ in the success state.
+ */
+struct LDKCResult_COption_NetworkUpdateZDecodeErrorZ CResult_COption_NetworkUpdateZDecodeErrorZ_ok(struct LDKCOption_NetworkUpdateZ o);
+
+/**
+ * Creates a new CResult_COption_NetworkUpdateZDecodeErrorZ in the error state.
+ */
+struct LDKCResult_COption_NetworkUpdateZDecodeErrorZ CResult_COption_NetworkUpdateZDecodeErrorZ_err(struct LDKDecodeError e);
+
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok(const struct LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR o);
+
+/**
+ * Frees any resources used by the CResult_COption_NetworkUpdateZDecodeErrorZ.
+ */
+void CResult_COption_NetworkUpdateZDecodeErrorZ_free(struct LDKCResult_COption_NetworkUpdateZDecodeErrorZ _res);
+
+/**
+ * Creates a new CResult_COption_NetworkUpdateZDecodeErrorZ which has the same data as `orig`
+ * but with all dynamically-allocated buffers duplicated in new buffers.
+ */
+struct LDKCResult_COption_NetworkUpdateZDecodeErrorZ CResult_COption_NetworkUpdateZDecodeErrorZ_clone(const struct LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR orig);
+
/**
* Constructs a new COption_AccessZ containing a crate::lightning::chain::Access
*/
*/
struct LDKCResult_DirectionalChannelInfoDecodeErrorZ CResult_DirectionalChannelInfoDecodeErrorZ_err(struct LDKDecodeError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_DirectionalChannelInfoDecodeErrorZ_is_ok(const struct LDKCResult_DirectionalChannelInfoDecodeErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_DirectionalChannelInfoDecodeErrorZ.
*/
*/
struct LDKCResult_ChannelInfoDecodeErrorZ CResult_ChannelInfoDecodeErrorZ_err(struct LDKDecodeError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_ChannelInfoDecodeErrorZ_is_ok(const struct LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_ChannelInfoDecodeErrorZ.
*/
*/
struct LDKCResult_RoutingFeesDecodeErrorZ CResult_RoutingFeesDecodeErrorZ_err(struct LDKDecodeError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_RoutingFeesDecodeErrorZ_is_ok(const struct LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_RoutingFeesDecodeErrorZ.
*/
*/
struct LDKCResult_NodeAnnouncementInfoDecodeErrorZ CResult_NodeAnnouncementInfoDecodeErrorZ_err(struct LDKDecodeError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok(const struct LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_NodeAnnouncementInfoDecodeErrorZ.
*/
*/
struct LDKCResult_NodeInfoDecodeErrorZ CResult_NodeInfoDecodeErrorZ_err(struct LDKDecodeError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_NodeInfoDecodeErrorZ_is_ok(const struct LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_NodeInfoDecodeErrorZ.
*/
*/
struct LDKCResult_NetworkGraphDecodeErrorZ CResult_NetworkGraphDecodeErrorZ_err(struct LDKDecodeError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_NetworkGraphDecodeErrorZ_is_ok(const struct LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_NetworkGraphDecodeErrorZ.
*/
*/
struct LDKCResult_NetAddressDecodeErrorZ CResult_NetAddressDecodeErrorZ_err(struct LDKDecodeError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_NetAddressDecodeErrorZ_is_ok(const struct LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_NetAddressDecodeErrorZ.
*/
*/
struct LDKCResult_AcceptChannelDecodeErrorZ CResult_AcceptChannelDecodeErrorZ_err(struct LDKDecodeError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_AcceptChannelDecodeErrorZ_is_ok(const struct LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_AcceptChannelDecodeErrorZ.
*/
*/
struct LDKCResult_AnnouncementSignaturesDecodeErrorZ CResult_AnnouncementSignaturesDecodeErrorZ_err(struct LDKDecodeError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(const struct LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_AnnouncementSignaturesDecodeErrorZ.
*/
*/
struct LDKCResult_ChannelReestablishDecodeErrorZ CResult_ChannelReestablishDecodeErrorZ_err(struct LDKDecodeError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_ChannelReestablishDecodeErrorZ_is_ok(const struct LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_ChannelReestablishDecodeErrorZ.
*/
*/
struct LDKCResult_ClosingSignedDecodeErrorZ CResult_ClosingSignedDecodeErrorZ_err(struct LDKDecodeError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_ClosingSignedDecodeErrorZ_is_ok(const struct LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_ClosingSignedDecodeErrorZ.
*/
*/
struct LDKCResult_ClosingSignedFeeRangeDecodeErrorZ CResult_ClosingSignedFeeRangeDecodeErrorZ_err(struct LDKDecodeError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(const struct LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_ClosingSignedFeeRangeDecodeErrorZ.
*/
*/
struct LDKCResult_CommitmentSignedDecodeErrorZ CResult_CommitmentSignedDecodeErrorZ_err(struct LDKDecodeError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_CommitmentSignedDecodeErrorZ_is_ok(const struct LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_CommitmentSignedDecodeErrorZ.
*/
*/
struct LDKCResult_FundingCreatedDecodeErrorZ CResult_FundingCreatedDecodeErrorZ_err(struct LDKDecodeError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_FundingCreatedDecodeErrorZ_is_ok(const struct LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_FundingCreatedDecodeErrorZ.
*/
*/
struct LDKCResult_FundingSignedDecodeErrorZ CResult_FundingSignedDecodeErrorZ_err(struct LDKDecodeError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_FundingSignedDecodeErrorZ_is_ok(const struct LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_FundingSignedDecodeErrorZ.
*/
*/
struct LDKCResult_FundingLockedDecodeErrorZ CResult_FundingLockedDecodeErrorZ_err(struct LDKDecodeError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_FundingLockedDecodeErrorZ_is_ok(const struct LDKCResult_FundingLockedDecodeErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_FundingLockedDecodeErrorZ.
*/
*/
struct LDKCResult_InitDecodeErrorZ CResult_InitDecodeErrorZ_err(struct LDKDecodeError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_InitDecodeErrorZ_is_ok(const struct LDKCResult_InitDecodeErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_InitDecodeErrorZ.
*/
*/
struct LDKCResult_OpenChannelDecodeErrorZ CResult_OpenChannelDecodeErrorZ_err(struct LDKDecodeError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_OpenChannelDecodeErrorZ_is_ok(const struct LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_OpenChannelDecodeErrorZ.
*/
*/
struct LDKCResult_RevokeAndACKDecodeErrorZ CResult_RevokeAndACKDecodeErrorZ_err(struct LDKDecodeError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_RevokeAndACKDecodeErrorZ_is_ok(const struct LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_RevokeAndACKDecodeErrorZ.
*/
*/
struct LDKCResult_ShutdownDecodeErrorZ CResult_ShutdownDecodeErrorZ_err(struct LDKDecodeError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_ShutdownDecodeErrorZ_is_ok(const struct LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_ShutdownDecodeErrorZ.
*/
*/
struct LDKCResult_UpdateFailHTLCDecodeErrorZ CResult_UpdateFailHTLCDecodeErrorZ_err(struct LDKDecodeError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_UpdateFailHTLCDecodeErrorZ_is_ok(const struct LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_UpdateFailHTLCDecodeErrorZ.
*/
*/
struct LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(struct LDKDecodeError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(const struct LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_UpdateFailMalformedHTLCDecodeErrorZ.
*/
*/
struct LDKCResult_UpdateFeeDecodeErrorZ CResult_UpdateFeeDecodeErrorZ_err(struct LDKDecodeError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_UpdateFeeDecodeErrorZ_is_ok(const struct LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_UpdateFeeDecodeErrorZ.
*/
*/
struct LDKCResult_UpdateFulfillHTLCDecodeErrorZ CResult_UpdateFulfillHTLCDecodeErrorZ_err(struct LDKDecodeError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(const struct LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_UpdateFulfillHTLCDecodeErrorZ.
*/
*/
struct LDKCResult_UpdateAddHTLCDecodeErrorZ CResult_UpdateAddHTLCDecodeErrorZ_err(struct LDKDecodeError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_UpdateAddHTLCDecodeErrorZ_is_ok(const struct LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_UpdateAddHTLCDecodeErrorZ.
*/
*/
struct LDKCResult_PingDecodeErrorZ CResult_PingDecodeErrorZ_err(struct LDKDecodeError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_PingDecodeErrorZ_is_ok(const struct LDKCResult_PingDecodeErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_PingDecodeErrorZ.
*/
*/
struct LDKCResult_PongDecodeErrorZ CResult_PongDecodeErrorZ_err(struct LDKDecodeError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_PongDecodeErrorZ_is_ok(const struct LDKCResult_PongDecodeErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_PongDecodeErrorZ.
*/
*/
struct LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(struct LDKDecodeError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(const struct LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_UnsignedChannelAnnouncementDecodeErrorZ.
*/
*/
struct LDKCResult_ChannelAnnouncementDecodeErrorZ CResult_ChannelAnnouncementDecodeErrorZ_err(struct LDKDecodeError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_ChannelAnnouncementDecodeErrorZ_is_ok(const struct LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_ChannelAnnouncementDecodeErrorZ.
*/
*/
struct LDKCResult_UnsignedChannelUpdateDecodeErrorZ CResult_UnsignedChannelUpdateDecodeErrorZ_err(struct LDKDecodeError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(const struct LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_UnsignedChannelUpdateDecodeErrorZ.
*/
*/
struct LDKCResult_ChannelUpdateDecodeErrorZ CResult_ChannelUpdateDecodeErrorZ_err(struct LDKDecodeError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_ChannelUpdateDecodeErrorZ_is_ok(const struct LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_ChannelUpdateDecodeErrorZ.
*/
*/
struct LDKCResult_ErrorMessageDecodeErrorZ CResult_ErrorMessageDecodeErrorZ_err(struct LDKDecodeError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_ErrorMessageDecodeErrorZ_is_ok(const struct LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_ErrorMessageDecodeErrorZ.
*/
*/
struct LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(struct LDKDecodeError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(const struct LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_UnsignedNodeAnnouncementDecodeErrorZ.
*/
*/
struct LDKCResult_NodeAnnouncementDecodeErrorZ CResult_NodeAnnouncementDecodeErrorZ_err(struct LDKDecodeError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_NodeAnnouncementDecodeErrorZ_is_ok(const struct LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_NodeAnnouncementDecodeErrorZ.
*/
*/
struct LDKCResult_QueryShortChannelIdsDecodeErrorZ CResult_QueryShortChannelIdsDecodeErrorZ_err(struct LDKDecodeError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(const struct LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_QueryShortChannelIdsDecodeErrorZ.
*/
*/
struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(struct LDKDecodeError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(const struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_ReplyShortChannelIdsEndDecodeErrorZ.
*/
*/
struct LDKCResult_QueryChannelRangeDecodeErrorZ CResult_QueryChannelRangeDecodeErrorZ_err(struct LDKDecodeError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_QueryChannelRangeDecodeErrorZ_is_ok(const struct LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_QueryChannelRangeDecodeErrorZ.
*/
*/
struct LDKCResult_ReplyChannelRangeDecodeErrorZ CResult_ReplyChannelRangeDecodeErrorZ_err(struct LDKDecodeError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_ReplyChannelRangeDecodeErrorZ_is_ok(const struct LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_ReplyChannelRangeDecodeErrorZ.
*/
*/
struct LDKCResult_GossipTimestampFilterDecodeErrorZ CResult_GossipTimestampFilterDecodeErrorZ_err(struct LDKDecodeError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_GossipTimestampFilterDecodeErrorZ_is_ok(const struct LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_GossipTimestampFilterDecodeErrorZ.
*/
*/
struct LDKCResult_InvoiceSignOrCreationErrorZ CResult_InvoiceSignOrCreationErrorZ_err(struct LDKSignOrCreationError e);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_InvoiceSignOrCreationErrorZ_is_ok(const struct LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_InvoiceSignOrCreationErrorZ.
*/
*/
struct LDKCResult_LockedChannelMonitorNoneZ CResult_LockedChannelMonitorNoneZ_err(void);
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_LockedChannelMonitorNoneZ_is_ok(const struct LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR o);
+
/**
* Frees any resources used by the CResult_LockedChannelMonitorNoneZ.
*/
/**
* 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);
+struct LDKPaymentPurpose PaymentPurpose_invoice_payment(struct LDKThirtyTwoBytes payment_preimage, struct LDKThirtyTwoBytes payment_secret);
/**
* Utility method to constructs a new SpontaneousPayment-variant PaymentPurpose
*/
struct LDKClosureReason ClosureReason_commitment_tx_confirmed(void);
+/**
+ * Utility method to constructs a new FundingTimedOut-variant ClosureReason
+ */
+struct LDKClosureReason ClosureReason_funding_timed_out(void);
+
/**
* Utility method to constructs a new ProcessingError-variant ClosureReason
*/
*/
struct LDKCVec_u8Z ClosureReason_write(const struct LDKClosureReason *NONNULL_PTR obj);
+/**
+ * Read a ClosureReason from a byte array, created by ClosureReason_write
+ */
+struct LDKCResult_COption_ClosureReasonZDecodeErrorZ ClosureReason_read(struct LDKu8slice ser);
+
/**
* Frees any resources used by the Event
*/
*/
struct LDKEvent Event_payment_path_failed(struct LDKThirtyTwoBytes payment_id, struct LDKThirtyTwoBytes payment_hash, bool rejected_by_dest, struct LDKCOption_NetworkUpdateZ network_update, bool all_paths_failed, struct LDKCVec_RouteHopZ path, struct LDKCOption_u64Z short_channel_id, struct LDKRouteParameters retry);
+/**
+ * Utility method to constructs a new PaymentFailed-variant Event
+ */
+struct LDKEvent Event_payment_failed(struct LDKThirtyTwoBytes payment_id, struct LDKThirtyTwoBytes payment_hash);
+
/**
* Utility method to constructs a new PendingHTLCsForwardable-variant Event
*/
*/
struct LDKEvent Event_discard_funding(struct LDKThirtyTwoBytes channel_id, struct LDKTransaction transaction);
+/**
+ * Utility method to constructs a new PaymentPathSuccessful-variant Event
+ */
+struct LDKEvent Event_payment_path_successful(struct LDKThirtyTwoBytes payment_id, struct LDKThirtyTwoBytes payment_hash, struct LDKCVec_RouteHopZ path);
+
/**
* Serialize the Event object into a byte array which can be read by Event_read
*/
struct LDKCVec_u8Z Event_write(const struct LDKEvent *NONNULL_PTR obj);
+/**
+ * Read a Event from a byte array, created by Event_write
+ */
+struct LDKCResult_COption_EventZDecodeErrorZ Event_read(struct LDKu8slice ser);
+
/**
* Frees any resources used by the MessageSendEvent
*/
/**
* 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);
+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 Gossip-variant Level
+ */
+enum LDKLevel Level_gossip(void);
+
+/**
+ * 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);
+
+/**
+ * Frees any resources used by the Record, if is_owned is set and inner is non-NULL.
+ */
+void Record_free(struct LDKRecord this_obj);
+
+/**
+ * The verbosity level of the message.
+ */
+enum LDKLevel Record_get_level(const struct LDKRecord *NONNULL_PTR this_ptr);
/**
- * Verifies a message was signed by a PrivateKey that derives to a given PublicKey, given a message, a signature,
- * and the PublicKey.
+ * The verbosity level of the message.
*/
-bool verify(struct LDKu8slice msg, struct LDKStr sig, struct LDKPublicKey pk);
+void Record_set_level(struct LDKRecord *NONNULL_PTR this_ptr, enum LDKLevel val);
/**
- * Creates a copy of the Level
+ * The message body.
*/
-enum LDKLevel Level_clone(const enum LDKLevel *NONNULL_PTR orig);
+struct LDKStr Record_get_args(const struct LDKRecord *NONNULL_PTR this_ptr);
/**
- * Utility method to constructs a new Trace-variant Level
+ * The message body.
*/
-enum LDKLevel Level_trace(void);
+void Record_set_args(struct LDKRecord *NONNULL_PTR this_ptr, struct LDKStr val);
/**
- * Utility method to constructs a new Debug-variant Level
+ * The module path of the message.
*/
-enum LDKLevel Level_debug(void);
+struct LDKStr Record_get_module_path(const struct LDKRecord *NONNULL_PTR this_ptr);
/**
- * Utility method to constructs a new Info-variant Level
+ * The module path of the message.
*/
-enum LDKLevel Level_info(void);
+void Record_set_module_path(struct LDKRecord *NONNULL_PTR this_ptr, struct LDKStr val);
/**
- * Utility method to constructs a new Warn-variant Level
+ * The source file containing the message.
*/
-enum LDKLevel Level_warn(void);
+struct LDKStr Record_get_file(const struct LDKRecord *NONNULL_PTR this_ptr);
/**
- * Utility method to constructs a new Error-variant Level
+ * The source file containing the message.
*/
-enum LDKLevel Level_error(void);
+void Record_set_file(struct LDKRecord *NONNULL_PTR this_ptr, struct LDKStr val);
/**
- * Checks if two Levels contain equal inner contents.
- * This ignores pointers and is_owned flags and looks at the values in fields.
+ * The line containing the message.
*/
-bool Level_eq(const enum LDKLevel *NONNULL_PTR a, const enum LDKLevel *NONNULL_PTR b);
+uint32_t Record_get_line(const struct LDKRecord *NONNULL_PTR this_ptr);
/**
- * Checks if two Levels contain equal inner contents.
+ * The line containing the message.
*/
-uint64_t Level_hash(const enum LDKLevel *NONNULL_PTR o);
+void Record_set_line(struct LDKRecord *NONNULL_PTR this_ptr, uint32_t val);
/**
- * Returns the most verbose logging level.
+ * Creates a copy of the Record
*/
-MUST_USE_RES enum LDKLevel Level_max(void);
+struct LDKRecord Record_clone(const struct LDKRecord *NONNULL_PTR orig);
/**
* Calls the free function if one is set
*/
void UserConfig_set_accept_forwards_to_priv_channels(struct LDKUserConfig *NONNULL_PTR this_ptr, bool val);
+/**
+ * If this is set to false, we do not accept inbound requests to open a new channel.
+ * Default value: true.
+ */
+bool UserConfig_get_accept_inbound_channels(const struct LDKUserConfig *NONNULL_PTR this_ptr);
+
+/**
+ * If this is set to false, we do not accept inbound requests to open a new channel.
+ * Default value: true.
+ */
+void UserConfig_set_accept_inbound_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);
+MUST_USE_RES struct LDKUserConfig UserConfig_new(struct LDKChannelHandshakeConfig own_channel_config_arg, struct LDKChannelHandshakeLimits peer_channel_config_limits_arg, struct LDKChannelConfig channel_options_arg, bool accept_forwards_to_priv_channels_arg, bool accept_inbound_channels_arg);
/**
* Creates a copy of the UserConfig
*/
struct LDKCResult_ChannelMonitorUpdateDecodeErrorZ ChannelMonitorUpdate_read(struct LDKu8slice ser);
-/**
- * Frees any resources used by the MonitorUpdateError, if is_owned is set and inner is non-NULL.
- */
-void MonitorUpdateError_free(struct LDKMonitorUpdateError this_obj);
-
-struct LDKStr MonitorUpdateError_get_a(const struct LDKMonitorUpdateError *NONNULL_PTR this_ptr);
-
-void MonitorUpdateError_set_a(struct LDKMonitorUpdateError *NONNULL_PTR this_ptr, struct LDKStr val);
-
-/**
- * Constructs a new MonitorUpdateError given each field
- */
-MUST_USE_RES struct LDKMonitorUpdateError MonitorUpdateError_new(struct LDKStr a_arg);
-
-/**
- * Creates a copy of the MonitorUpdateError
- */
-struct LDKMonitorUpdateError MonitorUpdateError_clone(const struct LDKMonitorUpdateError *NONNULL_PTR orig);
-
/**
* Frees any resources used by the MonitorEvent
*/
*/
struct LDKCVec_u8Z MonitorEvent_write(const struct LDKMonitorEvent *NONNULL_PTR obj);
+/**
+ * Read a MonitorEvent from a byte array, created by MonitorEvent_write
+ */
+struct LDKCResult_COption_MonitorEventZDecodeErrorZ MonitorEvent_read(struct LDKu8slice ser);
+
/**
* Frees any resources used by the HTLCUpdate, if is_owned is set and inner is non-NULL.
*/
*
* panics if the given update is not the next update by update_id.
*/
-MUST_USE_RES struct LDKCResult_NoneMonitorUpdateErrorZ ChannelMonitor_update_monitor(const struct LDKChannelMonitor *NONNULL_PTR this_arg, const struct LDKChannelMonitorUpdate *NONNULL_PTR updates, const struct LDKBroadcasterInterface *NONNULL_PTR broadcaster, const struct LDKFeeEstimator *NONNULL_PTR fee_estimator, const struct LDKLogger *NONNULL_PTR logger);
+MUST_USE_RES struct LDKCResult_NoneNoneZ ChannelMonitor_update_monitor(const struct LDKChannelMonitor *NONNULL_PTR this_arg, const struct LDKChannelMonitorUpdate *NONNULL_PTR updates, const struct LDKBroadcasterInterface *NONNULL_PTR broadcaster, const struct LDKFeeEstimator *NONNULL_PTR fee_estimator, const struct LDKLogger *NONNULL_PTR logger);
/**
* Gets the update_id from the latest ChannelMonitorUpdate which was applied to this
*/
MUST_USE_RES struct LDKChannelTransactionParameters InMemorySigner_get_channel_parameters(const struct LDKInMemorySigner *NONNULL_PTR this_arg);
+/**
+ * Whether anchors should be used.
+ * Will panic if ready_channel wasn't called.
+ */
+MUST_USE_RES bool InMemorySigner_opt_anchors(const struct LDKInMemorySigner *NONNULL_PTR this_arg);
+
/**
* Sign the single input of spend_tx at index `input_idx` which spends the output
* described by descriptor, returning the witness stack for the input.
*/
void ChannelDetails_set_user_channel_id(struct LDKChannelDetails *NONNULL_PTR this_ptr, uint64_t val);
+/**
+ * Our total balance. This is the amount we would get if we close the channel.
+ * This value is not exact. Due to various in-flight changes and feerate changes, exactly this
+ * amount is not likely to be recoverable on close.
+ *
+ * This does not include any pending HTLCs which are not yet fully resolved (and, thus, whose
+ * balance is not available for inclusion in new outbound HTLCs). This further does not include
+ * any pending outgoing HTLCs which are awaiting some other resolution to be sent.
+ * This does not consider any on-chain fees.
+ *
+ * See also [`ChannelDetails::outbound_capacity_msat`]
+ */
+uint64_t ChannelDetails_get_balance_msat(const struct LDKChannelDetails *NONNULL_PTR this_ptr);
+
+/**
+ * Our total balance. This is the amount we would get if we close the channel.
+ * This value is not exact. Due to various in-flight changes and feerate changes, exactly this
+ * amount is not likely to be recoverable on close.
+ *
+ * This does not include any pending HTLCs which are not yet fully resolved (and, thus, whose
+ * balance is not available for inclusion in new outbound HTLCs). This further does not include
+ * any pending outgoing HTLCs which are awaiting some other resolution to be sent.
+ * This does not consider any on-chain fees.
+ *
+ * See also [`ChannelDetails::outbound_capacity_msat`]
+ */
+void ChannelDetails_set_balance_msat(struct LDKChannelDetails *NONNULL_PTR this_ptr, uint64_t val);
+
/**
* The available outbound capacity for sending HTLCs to the remote peer. This does not include
- * any pending HTLCs which are not yet fully resolved (and, thus, who's balance is not
+ * any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not
* available for inclusion in new outbound HTLCs). This further does not include any pending
* outgoing HTLCs which are awaiting some other resolution to be sent.
*
+ * See also [`ChannelDetails::balance_msat`]
+ *
* This value is not exact. Due to various in-flight changes, feerate changes, and our
* conflict-avoidance policy, exactly this amount is not likely to be spendable. However, we
* should be able to spend nearly this amount.
/**
* The available outbound capacity for sending HTLCs to the remote peer. This does not include
- * any pending HTLCs which are not yet fully resolved (and, thus, who's balance is not
+ * any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not
* available for inclusion in new outbound HTLCs). This further does not include any pending
* outgoing HTLCs which are awaiting some other resolution to be sent.
*
+ * See also [`ChannelDetails::balance_msat`]
+ *
* This value is not exact. Due to various in-flight changes, feerate changes, and our
* conflict-avoidance policy, exactly this amount is not likely to be spendable. However, we
* should be able to spend nearly this amount.
/**
* The available inbound capacity for the remote peer to send HTLCs to us. This does not
- * include any pending HTLCs which are not yet fully resolved (and, thus, who's balance is not
+ * include any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not
* available for inclusion in new inbound HTLCs).
* Note that there are some corner cases not fully handled here, so the actual available
* inbound capacity may be slightly higher than this.
/**
* The available inbound capacity for the remote peer to send HTLCs to us. This does not
- * include any pending HTLCs which are not yet fully resolved (and, thus, who's balance is not
+ * include any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not
* available for inclusion in new inbound HTLCs).
* Note that there are some corner cases not fully handled here, so the actual available
* inbound capacity may be slightly higher than this.
/**
* 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_channel_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);
+MUST_USE_RES struct LDKChannelDetails ChannelDetails_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKChannelCounterparty counterparty_arg, struct LDKOutPoint funding_txo_arg, struct LDKCOption_u64Z short_channel_id_arg, uint64_t channel_value_satoshis_arg, struct LDKCOption_u64Z unspendable_punishment_reserve_arg, uint64_t user_channel_id_arg, uint64_t balance_msat_arg, uint64_t outbound_capacity_msat_arg, uint64_t inbound_capacity_msat_arg, struct LDKCOption_u32Z confirmations_required_arg, struct LDKCOption_u16Z force_close_spend_delay_arg, bool is_outbound_arg, bool is_funding_locked_arg, bool is_usable_arg, bool is_public_arg);
/**
* Creates a copy of the ChannelDetails
*
* Errors returned are a superset of those returned from [`send_payment`], so see
* [`send_payment`] documentation for more details on errors. This method will also error if the
- * retry amount puts the payment more than 10% over the payment's total amount, or if the payment
- * for the given `payment_id` cannot be found (likely due to timeout or success).
+ * retry amount puts the payment more than 10% over the payment's total amount, if the payment
+ * for the given `payment_id` cannot be found (likely due to timeout or success), or if
+ * further retries have been disabled with [`abandon_payment`].
*
* [`send_payment`]: [`ChannelManager::send_payment`]
+ * [`abandon_payment`]: [`ChannelManager::abandon_payment`]
*/
MUST_USE_RES struct LDKCResult_NonePaymentSendFailureZ ChannelManager_retry_payment(const struct LDKChannelManager *NONNULL_PTR this_arg, const struct LDKRoute *NONNULL_PTR route, struct LDKThirtyTwoBytes payment_id);
+/**
+ * Signals that no further retries for the given payment will occur.
+ *
+ * After this method returns, any future calls to [`retry_payment`] for the given `payment_id`
+ * will fail with [`PaymentSendFailure::ParameterError`]. If no such event has been generated,
+ * an [`Event::PaymentFailed`] event will be generated as soon as there are no remaining
+ * pending HTLCs for this payment.
+ *
+ * Note that calling this method does *not* prevent a payment from succeeding. You must still
+ * wait until you receive either a [`Event::PaymentFailed`] or [`Event::PaymentSent`] event to
+ * determine the ultimate status of a payment.
+ *
+ * [`retry_payment`]: Self::retry_payment
+ * [`Event::PaymentFailed`]: events::Event::PaymentFailed
+ * [`Event::PaymentSent`]: events::Event::PaymentSent
+ */
+void ChannelManager_abandon_payment(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes payment_id);
+
/**
* 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
* Returns an [`APIError::APIMisuseError`] if the funding_transaction spent non-SegWit outputs
* or if no output was found which matches the parameters in [`Event::FundingGenerationReady`].
*
- * Panics if a funding transaction has already been provided for this channel.
+ * Returns [`APIError::ChannelUnavailable`] if a funding transaction has already been provided
+ * for the channel or if the channel has been closed as indicated by [`Event::ChannelClosed`].
*
* May panic if the output found in the funding transaction is duplicative with some other
* channel (note that this should be trivially prevented by using unique funding transaction
* create a new channel with a conflicting funding transaction.
*
* [`Event::FundingGenerationReady`]: crate::util::events::Event::FundingGenerationReady
+ * [`Event::ChannelClosed`]: crate::util::events::Event::ChannelClosed
*/
MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_funding_transaction_generated(const struct LDKChannelManager *NONNULL_PTR this_arg, const uint8_t (*temporary_channel_id)[32], struct LDKTransaction funding_transaction);
MUST_USE_RES bool ChannelManager_fail_htlc_backwards(const struct LDKChannelManager *NONNULL_PTR this_arg, const uint8_t (*payment_hash)[32]);
/**
- * Provides a payment preimage in response to a PaymentReceived event, returning true and
- * generating message events for the net layer to claim the payment, if possible. Thus, you
- * should probably kick the net layer to go send messages if this returns true!
+ * Provides a payment preimage in response to [`Event::PaymentReceived`], generating any
+ * [`MessageSendEvent`]s needed to claim the payment.
*
* Note that if you did not set an `amount_msat` when calling [`create_inbound_payment`] or
* [`create_inbound_payment_for_hash`] you must check that the amount in the `PaymentReceived`
* event matches your expectation. If you fail to do so and call this method, you may provide
* the sender \"proof-of-payment\" when they did not fulfill the full expected payment.
*
- * May panic if called except in response to a PaymentReceived event.
+ * Returns whether any HTLCs were claimed, and thus if any new [`MessageSendEvent`]s are now
+ * pending for processing via [`get_and_clear_pending_msg_events`].
*
+ * [`Event::PaymentReceived`]: crate::util::events::Event::PaymentReceived
* [`create_inbound_payment`]: Self::create_inbound_payment
* [`create_inbound_payment_for_hash`]: Self::create_inbound_payment_for_hash
+ * [`get_and_clear_pending_msg_events`]: MessageSendEventsProvider::get_and_clear_pending_msg_events
*/
MUST_USE_RES bool ChannelManager_claim_funds(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes payment_preimage);
* to pay us.
*
* This differs from [`create_inbound_payment_for_hash`] only in that it generates the
- * [`PaymentHash`] and [`PaymentPreimage`] for you, returning the first and storing the second.
+ * [`PaymentHash`] and [`PaymentPreimage`] for you.
*
* The [`PaymentPreimage`] will ultimately be returned to you in the [`PaymentReceived`], which
* will have the [`PaymentReceived::payment_preimage`] field filled in. That should then be
*
* See [`create_inbound_payment_for_hash`] for detailed documentation on behavior and requirements.
*
+ * Note that a malicious eavesdropper can intuit whether an inbound payment was created by
+ * `create_inbound_payment` or `create_inbound_payment_for_hash` based on runtime.
+ *
+ * # Note
+ *
+ * If you register an inbound payment with this method, then serialize the `ChannelManager`, then
+ * deserialize it with a node running 0.0.103 and earlier, the payment will fail to be received.
+ *
+ * Errors if `min_value_msat` is greater than total bitcoin supply.
+ *
* [`claim_funds`]: Self::claim_funds
* [`PaymentReceived`]: events::Event::PaymentReceived
* [`PaymentReceived::payment_preimage`]: events::Event::PaymentReceived::payment_preimage
* [`create_inbound_payment_for_hash`]: Self::create_inbound_payment_for_hash
*/
-MUST_USE_RES struct LDKC2Tuple_PaymentHashPaymentSecretZ ChannelManager_create_inbound_payment(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKCOption_u64Z min_value_msat, uint32_t invoice_expiry_delta_secs, uint64_t user_payment_id);
+MUST_USE_RES struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ ChannelManager_create_inbound_payment(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKCOption_u64Z min_value_msat, uint32_t invoice_expiry_delta_secs);
+
+/**
+ * Legacy version of [`create_inbound_payment`]. Use this method if you wish to share
+ * serialized state with LDK node(s) running 0.0.103 and earlier.
+ *
+ * # Note
+ * This method is deprecated and will be removed soon.
+ *
+ * [`create_inbound_payment`]: Self::create_inbound_payment
+ */
+MUST_USE_RES struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ ChannelManager_create_inbound_payment_legacy(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKCOption_u64Z min_value_msat, uint32_t invoice_expiry_delta_secs);
/**
* Gets a [`PaymentSecret`] for a given [`PaymentHash`], for which the payment preimage is
* payment secret fetched via this method or [`create_inbound_payment`], and which is at least
* the `min_value_msat` provided here, if one is provided.
*
- * The [`PaymentHash`] (and corresponding [`PaymentPreimage`]) 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 [`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
- * with invoice metadata stored elsewhere.
+ * The [`PaymentHash`] (and corresponding [`PaymentPreimage`]) should be globally unique, though
+ * note that LDK will not stop you from registering duplicate payment hashes for inbound
+ * payments.
*
* `min_value_msat` should be set if the invoice being generated contains a value. Any payment
* received for the returned [`PaymentHash`] will be required to be at least `min_value_msat`
* If you need exact expiry semantics, you should enforce them upon receipt of
* [`PaymentReceived`].
*
- * Pending inbound payments are stored in memory and in serialized versions of this
- * [`ChannelManager`]. If potentially unbounded numbers of inbound payments may exist and
- * space is limited, you may wish to rate-limit inbound payment creation.
- *
* May panic if `invoice_expiry_delta_secs` is greater than one year.
*
* Note that invoices generated for inbound payments should have their `min_final_cltv_expiry`
* set to at least [`MIN_FINAL_CLTV_EXPIRY`].
*
+ * Note that a malicious eavesdropper can intuit whether an inbound payment was created by
+ * `create_inbound_payment` or `create_inbound_payment_for_hash` based on runtime.
+ *
+ * # Note
+ *
+ * If you register an inbound payment with this method, then serialize the `ChannelManager`, then
+ * deserialize it with a node running 0.0.103 and earlier, the payment will fail to be received.
+ *
+ * Errors if `min_value_msat` is greater than total bitcoin supply.
+ *
* [`create_inbound_payment`]: Self::create_inbound_payment
* [`PaymentReceived`]: events::Event::PaymentReceived
- * [`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);
+MUST_USE_RES struct LDKCResult_PaymentSecretNoneZ ChannelManager_create_inbound_payment_for_hash(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes payment_hash, struct LDKCOption_u64Z min_value_msat, uint32_t invoice_expiry_delta_secs);
+
+/**
+ * Legacy version of [`create_inbound_payment_for_hash`]. Use this method if you wish to share
+ * serialized state with LDK node(s) running 0.0.103 and earlier.
+ *
+ * # Note
+ * This method is deprecated and will be removed soon.
+ *
+ * [`create_inbound_payment_for_hash`]: Self::create_inbound_payment_for_hash
+ */
+MUST_USE_RES struct LDKCResult_PaymentSecretAPIErrorZ ChannelManager_create_inbound_payment_for_hash_legacy(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes payment_hash, struct LDKCOption_u64Z min_value_msat, uint32_t invoice_expiry_delta_secs);
+
+/**
+ * Gets an LDK-generated payment preimage from a payment hash and payment secret that were
+ * previously returned from [`create_inbound_payment`].
+ *
+ * [`create_inbound_payment`]: Self::create_inbound_payment
+ */
+MUST_USE_RES struct LDKCResult_PaymentPreimageAPIErrorZ ChannelManager_get_payment_preimage(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes payment_hash, struct LDKThirtyTwoBytes payment_secret);
/**
* Constructs a new MessageSendEventsProvider which calls the relevant methods on this_arg.
* indicating whether persistence is necessary. Only one listener on
* `await_persistable_update` or `await_persistable_update_timeout` is guaranteed to be woken
* up.
- * Note that the feature `allow_wallclock_use` must be enabled to use this function.
+ *
+ * Note that this method is not available with the `no-std` feature.
*/
MUST_USE_RES bool ChannelManager_await_persistable_update_timeout(const struct LDKChannelManager *NONNULL_PTR this_arg, uint64_t max_wait);
*/
void OpenChannel_set_channel_flags(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint8_t val);
+/**
+ * The channel type that this channel will represent. If none is set, we derive the channel
+ * type from the intersection of our feature bits with our counterparty's feature bits from
+ * the Init message.
+ *
+ * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
+ */
+struct LDKChannelTypeFeatures OpenChannel_get_channel_type(const struct LDKOpenChannel *NONNULL_PTR this_ptr);
+
+/**
+ * The channel type that this channel will represent. If none is set, we derive the channel
+ * type from the intersection of our feature bits with our counterparty's feature bits from
+ * the Init message.
+ *
+ * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
+ */
+void OpenChannel_set_channel_type(struct LDKOpenChannel *NONNULL_PTR this_ptr, struct LDKChannelTypeFeatures val);
+
/**
* Creates a copy of the OpenChannel
*/
/**
* Utility method to constructs a new OnionV2-variant NetAddress
*/
-struct LDKNetAddress NetAddress_onion_v2(struct LDKTenBytes addr, uint16_t port);
+struct LDKNetAddress NetAddress_onion_v2(struct LDKTwelveBytes a);
/**
* Utility method to constructs a new OnionV3-variant NetAddress
*/
struct LDKErrorAction ErrorAction_ignore_and_log(enum LDKLevel a);
+/**
+ * Utility method to constructs a new IgnoreDuplicateGossip-variant ErrorAction
+ */
+struct LDKErrorAction ErrorAction_ignore_duplicate_gossip(void);
+
/**
* Utility method to constructs a new SendErrorMessage-variant ErrorAction
*/
*/
void PeerManager_timer_tick_occurred(const struct LDKPeerManager *NONNULL_PTR this_arg);
+/**
+ * Gets the weight for an HTLC-Success transaction.
+ */
+uint64_t htlc_success_tx_weight(bool opt_anchors);
+
+/**
+ * Gets the weight for an HTLC-Timeout transaction.
+ */
+uint64_t htlc_timeout_tx_weight(bool opt_anchors);
+
/**
* Build the commitment secret from the seed and the commitment number
*/
* Gets the witness redeemscript for an HTLC output in a commitment transaction. Note that htlc
* does not need to have its previous_output_index filled.
*/
-struct LDKCVec_u8Z get_htlc_redeemscript(const struct LDKHTLCOutputInCommitment *NONNULL_PTR htlc, const struct LDKTxCreationKeys *NONNULL_PTR keys);
+struct LDKCVec_u8Z get_htlc_redeemscript(const struct LDKHTLCOutputInCommitment *NONNULL_PTR htlc, bool opt_anchors, const struct LDKTxCreationKeys *NONNULL_PTR keys);
/**
* Gets the redeemscript for a funding output from the two funding public keys.
* Panics if htlc.transaction_output_index.is_none() (as such HTLCs do not appear in the
* commitment transaction).
*/
-struct LDKTransaction build_htlc_transaction(const uint8_t (*commitment_txid)[32], uint32_t feerate_per_kw, uint16_t contest_delay, const struct LDKHTLCOutputInCommitment *NONNULL_PTR htlc, struct LDKPublicKey broadcaster_delayed_payment_key, struct LDKPublicKey revocation_key);
+struct LDKTransaction build_htlc_transaction(const uint8_t (*commitment_txid)[32], uint32_t feerate_per_kw, uint16_t contest_delay, const struct LDKHTLCOutputInCommitment *NONNULL_PTR htlc, bool opt_anchors, struct LDKPublicKey broadcaster_delayed_payment_key, struct LDKPublicKey revocation_key);
+
+/**
+ * Gets the witnessScript for an anchor output from the funding public key.
+ * The witness in the spending input must be:
+ * <BIP 143 funding_signature>
+ * After 16 blocks of confirmation, an alternative satisfying witness could be:
+ * <>
+ * (empty vector required to satisfy compliance with MINIMALIF-standard rule)
+ */
+struct LDKCVec_u8Z get_anchor_redeemscript(struct LDKPublicKey funding_pubkey);
/**
* Frees any resources used by the ChannelTransactionParameters, if is_owned is set and inner is non-NULL.
*/
void ChannelTransactionParameters_set_funding_outpoint(struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr, struct LDKOutPoint val);
+/**
+ * Are anchors used for this channel. Boolean is serialization backwards-compatible
+ */
+enum LDKCOption_NoneZ ChannelTransactionParameters_get_opt_anchors(const struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr);
+
+/**
+ * Are anchors used for this channel. Boolean is serialization backwards-compatible
+ */
+void ChannelTransactionParameters_set_opt_anchors(struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr, enum LDKCOption_NoneZ val);
+
/**
* Constructs a new ChannelTransactionParameters given each field
*/
-MUST_USE_RES struct LDKChannelTransactionParameters ChannelTransactionParameters_new(struct LDKChannelPublicKeys holder_pubkeys_arg, uint16_t holder_selected_contest_delay_arg, bool is_outbound_from_holder_arg, struct LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg, struct LDKOutPoint funding_outpoint_arg);
+MUST_USE_RES struct LDKChannelTransactionParameters ChannelTransactionParameters_new(struct LDKChannelPublicKeys holder_pubkeys_arg, uint16_t holder_selected_contest_delay_arg, bool is_outbound_from_holder_arg, struct LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg, struct LDKOutPoint funding_outpoint_arg, enum LDKCOption_NoneZ opt_anchors_arg);
/**
* Creates a copy of the ChannelTransactionParameters
*/
MUST_USE_RES struct LDKOutPoint DirectedChannelTransactionParameters_funding_outpoint(const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR this_arg);
+/**
+ * Whether to use anchors for this channel
+ */
+MUST_USE_RES bool DirectedChannelTransactionParameters_opt_anchors(const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR this_arg);
+
/**
* Frees any resources used by the HolderCommitmentTransaction, if is_owned is set and inner is non-NULL.
*/
*/
void ClosingTransaction_free(struct LDKClosingTransaction this_obj);
+/**
+ * Creates a copy of the ClosingTransaction
+ */
+struct LDKClosingTransaction ClosingTransaction_clone(const struct LDKClosingTransaction *NONNULL_PTR orig);
+
+/**
+ * Checks if two ClosingTransactions contain equal inner contents.
+ */
+uint64_t ClosingTransaction_hash(const struct LDKClosingTransaction *NONNULL_PTR o);
+
/**
* Construct an object of the class
*/
*/
MUST_USE_RES struct LDKTxCreationKeys TrustedCommitmentTransaction_keys(const struct LDKTrustedCommitmentTransaction *NONNULL_PTR this_arg);
+/**
+ * Should anchors be used.
+ */
+MUST_USE_RES bool TrustedCommitmentTransaction_opt_anchors(const struct LDKTrustedCommitmentTransaction *NONNULL_PTR this_arg);
+
/**
* Get a signature for each HTLC which was included in the commitment transaction (ie for
* which HTLCOutputInCommitment::transaction_output_index.is_some()).
*/
bool InvoiceFeatures_eq(const struct LDKInvoiceFeatures *NONNULL_PTR a, const struct LDKInvoiceFeatures *NONNULL_PTR b);
+/**
+ * Checks if two ChannelTypeFeaturess contain equal inner contents.
+ * This ignores pointers and is_owned flags and looks at the values in fields.
+ * Two objects with NULL inner values will be considered "equal" here.
+ */
+bool ChannelTypeFeatures_eq(const struct LDKChannelTypeFeatures *NONNULL_PTR a, const struct LDKChannelTypeFeatures *NONNULL_PTR b);
+
/**
* Creates a copy of the InitFeatures
*/
*/
struct LDKInvoiceFeatures InvoiceFeatures_clone(const struct LDKInvoiceFeatures *NONNULL_PTR orig);
+/**
+ * Creates a copy of the ChannelTypeFeatures
+ */
+struct LDKChannelTypeFeatures ChannelTypeFeatures_clone(const struct LDKChannelTypeFeatures *NONNULL_PTR orig);
+
/**
* Frees any resources used by the InitFeatures, if is_owned is set and inner is non-NULL.
*/
*/
void InvoiceFeatures_free(struct LDKInvoiceFeatures this_obj);
+/**
+ * Frees any resources used by the ChannelTypeFeatures, if is_owned is set and inner is non-NULL.
+ */
+void ChannelTypeFeatures_free(struct LDKChannelTypeFeatures this_obj);
+
/**
* Create a blank Features with no features set
*/
MUST_USE_RES bool InvoiceFeatures_requires_unknown_bits(const struct LDKInvoiceFeatures *NONNULL_PTR this_arg);
/**
- * Returns whether the `payment_secret` feature is supported.
+ * Create a blank Features with no features set
*/
-MUST_USE_RES bool InitFeatures_supports_payment_secret(const struct LDKInitFeatures *NONNULL_PTR this_arg);
+MUST_USE_RES struct LDKChannelTypeFeatures ChannelTypeFeatures_empty(void);
/**
- * Returns whether the `payment_secret` feature is supported.
+ * Creates a Features with the bits set which are known by the implementation
*/
-MUST_USE_RES bool NodeFeatures_supports_payment_secret(const struct LDKNodeFeatures *NONNULL_PTR this_arg);
+MUST_USE_RES struct LDKChannelTypeFeatures ChannelTypeFeatures_known(void);
/**
- * Returns whether the `payment_secret` feature is supported.
+ * Returns true if this `Features` object contains unknown feature flags which are set as
+ * \"required\".
*/
-MUST_USE_RES bool InvoiceFeatures_supports_payment_secret(const struct LDKInvoiceFeatures *NONNULL_PTR this_arg);
+MUST_USE_RES bool ChannelTypeFeatures_requires_unknown_bits(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg);
/**
* Serialize the InitFeatures object into a byte array which can be read by InitFeatures_read
struct LDKCVec_u8Z InitFeatures_write(const struct LDKInitFeatures *NONNULL_PTR obj);
/**
- * Serialize the NodeFeatures object into a byte array which can be read by NodeFeatures_read
+ * Read a InitFeatures from a byte array, created by InitFeatures_write
*/
-struct LDKCVec_u8Z NodeFeatures_write(const struct LDKNodeFeatures *NONNULL_PTR obj);
+struct LDKCResult_InitFeaturesDecodeErrorZ InitFeatures_read(struct LDKu8slice ser);
/**
* Serialize the ChannelFeatures object into a byte array which can be read by ChannelFeatures_read
struct LDKCVec_u8Z ChannelFeatures_write(const struct LDKChannelFeatures *NONNULL_PTR obj);
/**
- * Serialize the InvoiceFeatures object into a byte array which can be read by InvoiceFeatures_read
+ * Read a ChannelFeatures from a byte array, created by ChannelFeatures_write
*/
-struct LDKCVec_u8Z InvoiceFeatures_write(const struct LDKInvoiceFeatures *NONNULL_PTR obj);
+struct LDKCResult_ChannelFeaturesDecodeErrorZ ChannelFeatures_read(struct LDKu8slice ser);
/**
- * Read a InitFeatures from a byte array, created by InitFeatures_write
+ * Serialize the NodeFeatures object into a byte array which can be read by NodeFeatures_read
*/
-struct LDKCResult_InitFeaturesDecodeErrorZ InitFeatures_read(struct LDKu8slice ser);
+struct LDKCVec_u8Z NodeFeatures_write(const struct LDKNodeFeatures *NONNULL_PTR obj);
/**
* Read a NodeFeatures from a byte array, created by NodeFeatures_write
struct LDKCResult_NodeFeaturesDecodeErrorZ NodeFeatures_read(struct LDKu8slice ser);
/**
- * Read a ChannelFeatures from a byte array, created by ChannelFeatures_write
+ * Serialize the InvoiceFeatures object into a byte array which can be read by InvoiceFeatures_read
*/
-struct LDKCResult_ChannelFeaturesDecodeErrorZ ChannelFeatures_read(struct LDKu8slice ser);
+struct LDKCVec_u8Z InvoiceFeatures_write(const struct LDKInvoiceFeatures *NONNULL_PTR obj);
/**
* Read a InvoiceFeatures from a byte array, created by InvoiceFeatures_write
*/
struct LDKCResult_InvoiceFeaturesDecodeErrorZ InvoiceFeatures_read(struct LDKu8slice ser);
+/**
+ * Serialize the ChannelTypeFeatures object into a byte array which can be read by ChannelTypeFeatures_read
+ */
+struct LDKCVec_u8Z ChannelTypeFeatures_write(const struct LDKChannelTypeFeatures *NONNULL_PTR obj);
+
+/**
+ * Read a ChannelTypeFeatures from a byte array, created by ChannelTypeFeatures_write
+ */
+struct LDKCResult_ChannelTypeFeaturesDecodeErrorZ ChannelTypeFeatures_read(struct LDKu8slice ser);
+
/**
* Frees any resources used by the ShutdownScript, if is_owned is set and inner is non-NULL.
*/
*/
MUST_USE_RES struct LDKInvalidShutdownScript InvalidShutdownScript_new(struct LDKCVec_u8Z script_arg);
+/**
+ * Creates a copy of the InvalidShutdownScript
+ */
+struct LDKInvalidShutdownScript InvalidShutdownScript_clone(const struct LDKInvalidShutdownScript *NONNULL_PTR orig);
+
/**
* Serialize the ShutdownScript object into a byte array which can be read by ShutdownScript_read
*/
*/
void Type_free(struct LDKType this_ptr);
-/**
- * Calls the free function if one is set
- */
-void Score_free(struct LDKScore this_ptr);
-
-/**
- * Frees any resources used by the LockableScore, if is_owned is set and inner is non-NULL.
- */
-void LockableScore_free(struct LDKLockableScore this_obj);
-
-/**
- * Constructs a new LockableScore from a Score
- */
-MUST_USE_RES struct LDKLockableScore LockableScore_new(struct LDKScore score);
-
-/**
- * Serialize the LockableScore object into a byte array which can be read by LockableScore_read
- */
-struct LDKCVec_u8Z LockableScore_write(const struct LDKLockableScore *NONNULL_PTR obj);
-
/**
* Frees any resources used by the NodeId, if is_owned is set and inner is non-NULL.
*/
*/
struct LDKCVec_u8Z NetworkUpdate_write(const struct LDKNetworkUpdate *NONNULL_PTR obj);
+/**
+ * Read a NetworkUpdate from a byte array, created by NetworkUpdate_write
+ */
+struct LDKCResult_COption_NetworkUpdateZDecodeErrorZ NetworkUpdate_read(struct LDKu8slice ser);
+
/**
* Constructs a new EventHandler which calls the relevant methods on this_arg.
* This copies the `inner` pointer in this_arg and thus the returned EventHandler must be freed before this_arg is
*/
void ChannelInfo_set_announcement_message(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKChannelAnnouncement val);
-/**
- * Constructs a new ChannelInfo given each field
- */
-MUST_USE_RES struct LDKChannelInfo ChannelInfo_new(struct LDKChannelFeatures features_arg, struct LDKNodeId node_one_arg, struct LDKDirectionalChannelInfo one_to_two_arg, struct LDKNodeId node_two_arg, struct LDKDirectionalChannelInfo two_to_one_arg, struct LDKCOption_u64Z capacity_sats_arg, struct LDKChannelAnnouncement announcement_message_arg);
-
/**
* Creates a copy of the ChannelInfo
*/
*/
void NetworkGraph_fail_node(const struct LDKNetworkGraph *NONNULL_PTR this_arg, struct LDKPublicKey _node_id, bool is_permanent);
+/**
+ * Removes information about channels that we haven't heard any updates about in some time.
+ * This can be used regularly to prune the network graph of channels that likely no longer
+ * exist.
+ *
+ * While there is no formal requirement that nodes regularly re-broadcast their channel
+ * updates every two weeks, the non-normative section of BOLT 7 currently suggests that
+ * pruning occur for updates which are at least two weeks old, which we implement here.
+ *
+ * This function takes the current unix time as an argument. For users with the `std` feature
+ * enabled, [`NetworkGraph::remove_stale_channels`] may be preferable.
+ */
+void NetworkGraph_remove_stale_channels_with_time(const struct LDKNetworkGraph *NONNULL_PTR this_arg, uint64_t current_time_unix);
+
/**
* For an already known (from announcement) channel, update info about one of the directions
* of the channel.
* You probably don't want to call this directly, instead relying on a NetGraphMsgHandler's
* RoutingMessageHandler implementation to call it indirectly. This may be useful to accept
* routing messages from a source using a protocol other than the lightning P2P protocol.
+ *
+ * If built with `no-std`, any updates with a timestamp more than two weeks in the past or
+ * materially in the future will be rejected.
*/
MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKChannelUpdate *NONNULL_PTR msg);
* For an already known (from announcement) channel, update info about one of the directions
* of the channel without verifying the associated signatures. Because we aren't given the
* associated signatures here we cannot relay the channel update to any of our peers.
+ *
+ * If built with `no-std`, any updates with a timestamp more than two weeks in the past or
+ * materially in the future will be rejected.
*/
MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel_unsigned(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKUnsignedChannelUpdate *NONNULL_PTR msg);
*/
struct LDKCResult_RouteLightningErrorZ find_route(struct LDKPublicKey our_node_pubkey, const struct LDKRouteParameters *NONNULL_PTR params, const struct LDKNetworkGraph *NONNULL_PTR network, struct LDKCVec_ChannelDetailsZ *first_hops, struct LDKLogger logger, const struct LDKScore *NONNULL_PTR scorer);
+/**
+ * Calls the free function if one is set
+ */
+void Score_free(struct LDKScore this_ptr);
+
+/**
+ * Calls the free function if one is set
+ */
+void LockableScore_free(struct LDKLockableScore this_ptr);
+
+/**
+ * Frees any resources used by the MultiThreadedLockableScore, if is_owned is set and inner is non-NULL.
+ */
+void MultiThreadedLockableScore_free(struct LDKMultiThreadedLockableScore this_obj);
+
+/**
+ * Creates a new [`MultiThreadedLockableScore`] given an underlying [`Score`].
+ */
+MUST_USE_RES struct LDKMultiThreadedLockableScore MultiThreadedLockableScore_new(struct LDKScore score);
+
/**
* Frees any resources used by the Scorer, if is_owned is set and inner is non-NULL.
*/
/**
* A fixed penalty in msats to apply to each channel.
+ *
+ * Default value: 500 msat
*/
uint64_t ScoringParameters_get_base_penalty_msat(const struct LDKScoringParameters *NONNULL_PTR this_ptr);
/**
* A fixed penalty in msats to apply to each channel.
+ *
+ * Default value: 500 msat
*/
void ScoringParameters_set_base_penalty_msat(struct LDKScoringParameters *NONNULL_PTR this_ptr, uint64_t val);
* A penalty in msats to apply to a channel upon failing to relay a payment.
*
* This accumulates for each failure but may be reduced over time based on
- * [`failure_penalty_half_life`].
+ * [`failure_penalty_half_life`] or when successfully routing through a channel.
+ *
+ * Default value: 1,024,000 msat
*
* [`failure_penalty_half_life`]: Self::failure_penalty_half_life
*/
* A penalty in msats to apply to a channel upon failing to relay a payment.
*
* This accumulates for each failure but may be reduced over time based on
- * [`failure_penalty_half_life`].
+ * [`failure_penalty_half_life`] or when successfully routing through a channel.
+ *
+ * Default value: 1,024,000 msat
*
* [`failure_penalty_half_life`]: Self::failure_penalty_half_life
*/
void ScoringParameters_set_failure_penalty_msat(struct LDKScoringParameters *NONNULL_PTR this_ptr, uint64_t val);
+/**
+ * When the amount being sent over a channel is this many 1024ths of the total channel
+ * capacity, we begin applying [`overuse_penalty_msat_per_1024th`].
+ *
+ * Default value: 128 1024ths (i.e. begin penalizing when an HTLC uses 1/8th of a channel)
+ *
+ * [`overuse_penalty_msat_per_1024th`]: Self::overuse_penalty_msat_per_1024th
+ */
+uint16_t ScoringParameters_get_overuse_penalty_start_1024th(const struct LDKScoringParameters *NONNULL_PTR this_ptr);
+
+/**
+ * When the amount being sent over a channel is this many 1024ths of the total channel
+ * capacity, we begin applying [`overuse_penalty_msat_per_1024th`].
+ *
+ * Default value: 128 1024ths (i.e. begin penalizing when an HTLC uses 1/8th of a channel)
+ *
+ * [`overuse_penalty_msat_per_1024th`]: Self::overuse_penalty_msat_per_1024th
+ */
+void ScoringParameters_set_overuse_penalty_start_1024th(struct LDKScoringParameters *NONNULL_PTR this_ptr, uint16_t val);
+
+/**
+ * A penalty applied, per whole 1024ths of the channel capacity which the amount being sent
+ * over the channel exceeds [`overuse_penalty_start_1024th`] by.
+ *
+ * Default value: 20 msat (i.e. 2560 msat penalty to use 1/4th of a channel, 7680 msat penalty
+ * to use half a channel, and 12,560 msat penalty to use 3/4ths of a channel)
+ *
+ * [`overuse_penalty_start_1024th`]: Self::overuse_penalty_start_1024th
+ */
+uint64_t ScoringParameters_get_overuse_penalty_msat_per_1024th(const struct LDKScoringParameters *NONNULL_PTR this_ptr);
+
+/**
+ * A penalty applied, per whole 1024ths of the channel capacity which the amount being sent
+ * over the channel exceeds [`overuse_penalty_start_1024th`] by.
+ *
+ * Default value: 20 msat (i.e. 2560 msat penalty to use 1/4th of a channel, 7680 msat penalty
+ * to use half a channel, and 12,560 msat penalty to use 3/4ths of a channel)
+ *
+ * [`overuse_penalty_start_1024th`]: Self::overuse_penalty_start_1024th
+ */
+void ScoringParameters_set_overuse_penalty_msat_per_1024th(struct LDKScoringParameters *NONNULL_PTR this_ptr, uint64_t val);
+
/**
* The time required to elapse before any accumulated [`failure_penalty_msat`] penalties are
* cut in half.
*
+ * Successfully routing through a channel will immediately cut the penalty in half as well.
+ *
* # Note
*
- * When time is an [`Eternity`], as is default when enabling feature `no-std`, it will never
- * elapse. Therefore, this penalty will never decay.
+ * When built with the `no-std` feature, time will never elapse. Therefore, this penalty will
+ * never decay.
*
* [`failure_penalty_msat`]: Self::failure_penalty_msat
*/
* The time required to elapse before any accumulated [`failure_penalty_msat`] penalties are
* cut in half.
*
+ * Successfully routing through a channel will immediately cut the penalty in half as well.
+ *
* # Note
*
- * When time is an [`Eternity`], as is default when enabling feature `no-std`, it will never
- * elapse. Therefore, this penalty will never decay.
+ * When built with the `no-std` feature, time will never elapse. Therefore, this penalty will
+ * never decay.
*
* [`failure_penalty_msat`]: Self::failure_penalty_msat
*/
/**
* Constructs a new ScoringParameters given each field
*/
-MUST_USE_RES struct LDKScoringParameters ScoringParameters_new(uint64_t base_penalty_msat_arg, uint64_t failure_penalty_msat_arg, uint64_t failure_penalty_half_life_arg);
+MUST_USE_RES struct LDKScoringParameters ScoringParameters_new(uint64_t base_penalty_msat_arg, uint64_t failure_penalty_msat_arg, uint16_t overuse_penalty_start_1024th_arg, uint64_t overuse_penalty_msat_per_1024th_arg, uint64_t failure_penalty_half_life_arg);
/**
* Serialize the ScoringParameters object into a byte array which can be read by ScoringParameters_read
* functionality implemented by other handlers.
* * [`NetGraphMsgHandler`] if given will update the [`NetworkGraph`] based on payment failures.
*
- * [top-level documentation]: Self
+ * [top-level documentation]: BackgroundProcessor
* [`join`]: Self::join
* [`stop`]: Self::stop
* [`ChannelManager`]: lightning::ln::channelmanager::ChannelManager
*/
enum LDKCreationError CreationError_expiry_time_out_of_bounds(void);
+/**
+ * Utility method to constructs a new InvalidAmount-variant CreationError
+ */
+enum LDKCreationError CreationError_invalid_amount(void);
+
/**
* Checks if two CreationErrors contain equal inner contents.
* This ignores pointers and is_owned flags and looks at the values in fields.
* Will forward any [`Event::PaymentPathFailed`] events to the decorated `event_handler` once
* `retry_attempts` has been exceeded for a given [`Invoice`].
*/
-MUST_USE_RES struct LDKInvoicePayer InvoicePayer_new(struct LDKPayer payer, struct LDKRouter router, const struct LDKLockableScore *NONNULL_PTR scorer, struct LDKLogger logger, struct LDKEventHandler event_handler, struct LDKRetryAttempts retry_attempts);
+MUST_USE_RES struct LDKInvoicePayer InvoicePayer_new(struct LDKPayer payer, struct LDKRouter router, const struct LDKMultiThreadedLockableScore *NONNULL_PTR scorer, struct LDKLogger logger, struct LDKEventHandler event_handler, struct LDKRetryAttempts retry_attempts);
/**
* Pays the given [`Invoice`], caching it for later use in case a retry is needed.
*/
MUST_USE_RES struct LDKCResult_PaymentIdPaymentErrorZ InvoicePayer_pay_zero_value_invoice(const struct LDKInvoicePayer *NONNULL_PTR this_arg, const struct LDKInvoice *NONNULL_PTR invoice, uint64_t amount_msats);
+/**
+ * Pays `pubkey` an amount using the hash of the given preimage, caching it for later use in
+ * case a retry is needed.
+ *
+ * You should ensure that `payment_preimage` is unique and that its `payment_hash` has never
+ * been paid before. Because [`InvoicePayer`] is stateless no effort is made to do so for you.
+ */
+MUST_USE_RES struct LDKCResult_PaymentIdPaymentErrorZ InvoicePayer_pay_pubkey(const struct LDKInvoicePayer *NONNULL_PTR this_arg, struct LDKPublicKey pubkey, struct LDKThirtyTwoBytes payment_preimage, uint64_t amount_msats, uint32_t final_cltv_expiry_delta);
+
/**
* Removes the payment cached by the given payment hash.
*