* The invoice contains multiple descriptions and/or description hashes which isn't allowed
*/
LDKSemanticError_MultipleDescriptions,
+ /**
+ * The invoice contains multiple payment secrets
+ */
+ LDKSemanticError_MultiplePaymentSecrets,
+ /**
+ * The invoice's features are invalid
+ */
+ LDKSemanticError_InvalidFeatures,
/**
* The recovery id doesn't fit the signature/pub key
*/
/**
* Indicates an outbound payment we made succeeded (ie it made it all the way to its target
* and we got back the payment preimage for it).
- * Note that duplicative PaymentSent Events may be generated - it is your responsibility to
- * deduplicate them by payment_preimage (which MUST be unique)!
*/
LDKEvent_PaymentSent,
/**
* Indicates an outbound payment we made failed. Probably some intermediary node dropped
* something. You may wish to retry with a different route.
- * Note that duplicative PaymentFailed Events may be generated - it is your responsibility to
- * deduplicate them by payment_hash (which MUST be unique)!
*/
LDKEvent_PaymentFailed,
/**
*/
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 or commitment
- * transaction output when our counterparty broadcasts an old state.
+ * 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 multiples outputs at the same time if timelocks are
+ * 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 multiples time for same output(s) if a fee-bump is needed with regards
+ * 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.
* not allow the spending of any funds by itself (you need our holder revocation_secret to do
* so).
*
- * htlc holds HTLC elements (hash, timelock) if the output being spent is a HTLC output, thus
- * changing the format of the witness script (which is committed to in the BIP 143
- * signatures).
+ * 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_transaction)(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);
+ 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.
bool result_ok;
} LDKCResult_CResult_NetAddressu8ZDecodeErrorZ;
+/**
+ * The contents of CResult_NetAddressDecodeErrorZ
+ */
+typedef union LDKCResult_NetAddressDecodeErrorZPtr {
+ /**
+ * A pointer to the contents in the success state.
+ * Reading from this pointer when `result_ok` is not set is undefined.
+ */
+ struct LDKNetAddress *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_NetAddressDecodeErrorZPtr;
+
+/**
+ * A CResult_NetAddressDecodeErrorZ represents the result of a fallible operation,
+ * containing a crate::lightning::ln::msgs::NetAddress 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_NetAddressDecodeErrorZ {
+ /**
+ * The contents of this CResult_NetAddressDecodeErrorZ, accessible via either
+ * `err` or `result` depending on the state of `result_ok`.
+ */
+ union LDKCResult_NetAddressDecodeErrorZPtr contents;
+ /**
+ * Whether this CResult_NetAddressDecodeErrorZ represents a success state.
+ */
+ bool result_ok;
+} LDKCResult_NetAddressDecodeErrorZ;
+
/**
} LDKMessageSendEventsProvider;
/**
- * A trait indicating an object may generate events
+ * A trait implemented for objects handling events from [`EventsProvider`].
+ */
+typedef struct LDKEventHandler {
+ /**
+ * 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;
+ /**
+ * Handles the given [`Event`].
+ *
+ * See [`EventsProvider`] for details that must be considered when implementing this method.
+ */
+ void (*handle_event)(const void *this_arg, struct LDKEvent event);
+ /**
+ * 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);
+} LDKEventHandler;
+
+/**
+ * A trait indicating an object may generate events.
+ *
+ * Events are processed by passing an [`EventHandler`] to [`process_pending_events`].
+ *
+ * # Requirements
+ *
+ * See [`process_pending_events`] for requirements around event processing.
+ *
+ * When using this trait, [`process_pending_events`] will call [`handle_event`] for each pending
+ * event since the last invocation. The handler must either act upon the event immediately
+ * or preserve it for later handling.
+ *
+ * Note, handlers may call back into the provider and thus deadlocking must be avoided. Be sure to
+ * consult the provider's documentation on the implication of processing events and how a handler
+ * may safely use the provider (e.g., see [`ChannelManager::process_pending_events`] and
+ * [`ChainMonitor::process_pending_events`]).
+ *
+ * (C-not implementable) As there is likely no reason for a user to implement this trait on their
+ * own type(s).
+ *
+ * [`process_pending_events`]: Self::process_pending_events
+ * [`handle_event`]: EventHandler::handle_event
+ * [`ChannelManager::process_pending_events`]: crate::ln::channelmanager::ChannelManager#method.process_pending_events
+ * [`ChainMonitor::process_pending_events`]: crate::chain::chainmonitor::ChainMonitor#method.process_pending_events
*/
typedef struct LDKEventsProvider {
/**
*/
void *this_arg;
/**
- * Gets the list of pending events which were generated by previous actions, clearing the list
- * in the process.
+ * Processes any events generated since the last call using the given event handler.
+ *
+ * Subsequent calls must only process new events. However, handlers must be capable of handling
+ * duplicate events across process restarts. This may occur if the provider was recovered from
+ * an old state (i.e., it hadn't been successfully persisted after processing pending events).
*/
- struct LDKCVec_EventZ (*get_and_clear_pending_events)(const void *this_arg);
+ void (*process_pending_events)(const void *this_arg, struct LDKEventHandler handler);
/**
* 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.
extern const uint64_t CLOSED_CHANNEL_UPDATE_ID;
+extern const uint32_t ANTI_REORG_DELAY;
+
extern const uint16_t BREAKDOWN_TIMEOUT;
extern const uint16_t MIN_CLTV_EXPIRY_DELTA;
*/
struct LDKCResult_CResult_NetAddressu8ZDecodeErrorZ CResult_CResult_NetAddressu8ZDecodeErrorZ_clone(const struct LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *NONNULL_PTR orig);
+/**
+ * Creates a new CResult_NetAddressDecodeErrorZ in the success state.
+ */
+struct LDKCResult_NetAddressDecodeErrorZ CResult_NetAddressDecodeErrorZ_ok(struct LDKNetAddress o);
+
+/**
+ * Creates a new CResult_NetAddressDecodeErrorZ in the error state.
+ */
+struct LDKCResult_NetAddressDecodeErrorZ CResult_NetAddressDecodeErrorZ_err(struct LDKDecodeError e);
+
+/**
+ * Frees any resources used by the CResult_NetAddressDecodeErrorZ.
+ */
+void CResult_NetAddressDecodeErrorZ_free(struct LDKCResult_NetAddressDecodeErrorZ _res);
+
+/**
+ * Creates a new CResult_NetAddressDecodeErrorZ which has the same data as `orig`
+ * but with all dynamically-allocated buffers duplicated in new buffers.
+ */
+struct LDKCResult_NetAddressDecodeErrorZ CResult_NetAddressDecodeErrorZ_clone(const struct LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR orig);
+
/**
* Frees the buffer pointed to by `data` if `datalen` is non-0.
*/
*/
void EventsProvider_free(struct LDKEventsProvider this_ptr);
+/**
+ * Calls the free function if one is set
+ */
+void EventHandler_free(struct LDKEventHandler this_ptr);
+
/**
* Frees any resources used by the APIError
*/
*/
enum LDKLevel Level_clone(const enum LDKLevel *NONNULL_PTR orig);
+/**
+ * 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.
*/
*/
void ChannelHandshakeLimits_set_min_max_accepted_htlcs(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, uint16_t val);
-/**
- * Outputs below a certain value will not be added to on-chain transactions. The dust value is
- * required to always be higher than this value so this only applies to HTLC outputs (and
- * potentially to-self outputs before any payments have been made).
- * Thus, HTLCs below this amount plus HTLC transaction fees are not enforceable on-chain.
- * This setting allows you to set a minimum dust limit for their commitment transactions,
- * reflecting the reality that tiny outputs are not considered standard transactions and will
- * not propagate through the Bitcoin network.
- *
- * Default value: 546, the current dust limit on the Bitcoin network.
- */
-uint64_t ChannelHandshakeLimits_get_min_dust_limit_satoshis(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr);
-
-/**
- * Outputs below a certain value will not be added to on-chain transactions. The dust value is
- * required to always be higher than this value so this only applies to HTLC outputs (and
- * potentially to-self outputs before any payments have been made).
- * Thus, HTLCs below this amount plus HTLC transaction fees are not enforceable on-chain.
- * This setting allows you to set a minimum dust limit for their commitment transactions,
- * reflecting the reality that tiny outputs are not considered standard transactions and will
- * not propagate through the Bitcoin network.
- *
- * Default value: 546, the current dust limit on the Bitcoin network.
- */
-void ChannelHandshakeLimits_set_min_dust_limit_satoshis(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, uint64_t val);
-
-/**
- * Maximum allowed threshold above which outputs will not be generated in their commitment
- * transactions.
- * HTLCs below this amount plus HTLC transaction fees are not enforceable on-chain.
- *
- * Default value: u64::max_value.
- */
-uint64_t ChannelHandshakeLimits_get_max_dust_limit_satoshis(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr);
-
-/**
- * Maximum allowed threshold above which outputs will not be generated in their commitment
- * transactions.
- * HTLCs below this amount plus HTLC transaction fees are not enforceable on-chain.
- *
- * Default value: u64::max_value.
- */
-void ChannelHandshakeLimits_set_max_dust_limit_satoshis(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, uint64_t val);
-
/**
* Before a channel is usable the funding transaction will need to be confirmed by at least a
* certain number of blocks, specified by the node which is not the funder (as the funder can
/**
* Constructs a new ChannelHandshakeLimits given each field
*/
-MUST_USE_RES struct LDKChannelHandshakeLimits ChannelHandshakeLimits_new(uint64_t min_funding_satoshis_arg, uint64_t max_htlc_minimum_msat_arg, uint64_t min_max_htlc_value_in_flight_msat_arg, uint64_t max_channel_reserve_satoshis_arg, uint16_t min_max_accepted_htlcs_arg, uint64_t min_dust_limit_satoshis_arg, uint64_t max_dust_limit_satoshis_arg, uint32_t max_minimum_depth_arg, bool force_announced_channel_preference_arg, uint16_t their_to_self_delay_arg);
+MUST_USE_RES struct LDKChannelHandshakeLimits ChannelHandshakeLimits_new(uint64_t min_funding_satoshis_arg, uint64_t max_htlc_minimum_msat_arg, uint64_t min_max_htlc_value_in_flight_msat_arg, uint64_t max_channel_reserve_satoshis_arg, uint16_t min_max_accepted_htlcs_arg, uint32_t max_minimum_depth_arg, bool force_announced_channel_preference_arg, uint16_t their_to_self_delay_arg);
/**
* Creates a copy of the ChannelHandshakeLimits
*/
struct LDKOutPoint OutPoint_clone(const struct LDKOutPoint *NONNULL_PTR orig);
+/**
+ * Checks if two OutPoints 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 OutPoint_eq(const struct LDKOutPoint *NONNULL_PTR a, const struct LDKOutPoint *NONNULL_PTR b);
+
+/**
+ * Checks if two OutPoints contain equal inner contents.
+ */
+uint64_t OutPoint_hash(const struct LDKOutPoint *NONNULL_PTR o);
+
/**
* Convert an `OutPoint` to a lightning channel id.
*/
*/
void ChannelDetails_set_channel_id(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val);
+/**
+ * The Channel's funding transaction output, if we've negotiated the funding transaction with
+ * our counterparty already.
+ *
+ * Note that, if this has been set, `channel_id` will be equivalent to
+ * `funding_txo.unwrap().to_channel_id()`.
+ */
+struct LDKOutPoint ChannelDetails_get_funding_txo(const struct LDKChannelDetails *NONNULL_PTR this_ptr);
+
+/**
+ * The Channel's funding transaction output, if we've negotiated the funding transaction with
+ * our counterparty already.
+ *
+ * Note that, if this has been set, `channel_id` will be equivalent to
+ * `funding_txo.unwrap().to_channel_id()`.
+ */
+void ChannelDetails_set_funding_txo(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKOutPoint val);
+
/**
* The position of the funding transaction in the chain. None if the funding transaction has
* not yet been confirmed and the channel fully opened.
*/
void ChannelDetails_set_inbound_capacity_msat(struct LDKChannelDetails *NONNULL_PTR this_ptr, uint64_t val);
+/**
+ * True if the channel was initiated (and thus funded) by us.
+ */
+bool ChannelDetails_get_is_outbound(const struct LDKChannelDetails *NONNULL_PTR this_ptr);
+
+/**
+ * True if the channel was initiated (and thus funded) by us.
+ */
+void ChannelDetails_set_is_outbound(struct LDKChannelDetails *NONNULL_PTR this_ptr, bool val);
+
+/**
+ * True if the channel is confirmed, funding_locked messages have been exchanged, and the
+ * channel is not currently being shut down. `funding_locked` message exchange implies the
+ * required confirmation count has been reached (and we were connected to the peer at some
+ * point after the funding transaction received enough confirmations).
+ */
+bool ChannelDetails_get_is_funding_locked(const struct LDKChannelDetails *NONNULL_PTR this_ptr);
+
+/**
+ * True if the channel is confirmed, funding_locked messages have been exchanged, and the
+ * channel is not currently being shut down. `funding_locked` message exchange implies the
+ * required confirmation count has been reached (and we were connected to the peer at some
+ * point after the funding transaction received enough confirmations).
+ */
+void ChannelDetails_set_is_funding_locked(struct LDKChannelDetails *NONNULL_PTR this_ptr, bool val);
+
/**
* True if the channel is (a) confirmed and funding_locked messages have been exchanged, (b)
- * the peer is connected, and (c) no monitor update failure is pending resolution.
+ * the peer is connected, (c) no monitor update failure is pending resolution, and (d) the
+ * channel is not currently negotiating a shutdown.
+ *
+ * This is a strict superset of `is_funding_locked`.
*/
-bool ChannelDetails_get_is_live(const struct LDKChannelDetails *NONNULL_PTR this_ptr);
+bool ChannelDetails_get_is_usable(const struct LDKChannelDetails *NONNULL_PTR this_ptr);
/**
* True if the channel is (a) confirmed and funding_locked messages have been exchanged, (b)
- * the peer is connected, and (c) no monitor update failure is pending resolution.
+ * the peer is connected, (c) no monitor update failure is pending resolution, and (d) the
+ * channel is not currently negotiating a shutdown.
+ *
+ * This is a strict superset of `is_funding_locked`.
+ */
+void ChannelDetails_set_is_usable(struct LDKChannelDetails *NONNULL_PTR this_ptr, bool val);
+
+/**
+ * True if this channel is (or will be) publicly-announced.
*/
-void ChannelDetails_set_is_live(struct LDKChannelDetails *NONNULL_PTR this_ptr, bool val);
+bool ChannelDetails_get_is_public(const struct LDKChannelDetails *NONNULL_PTR this_ptr);
+
+/**
+ * True if this channel is (or will be) publicly-announced.
+ */
+void ChannelDetails_set_is_public(struct LDKChannelDetails *NONNULL_PTR this_ptr, bool val);
/**
* Creates a copy of the ChannelDetails
* Gets the list of usable channels, in random order. Useful as an argument to
* get_route to ensure non-announced channels are used.
*
- * These are guaranteed to have their is_live value set to true, see the documentation for
- * ChannelDetails::is_live for more info on exactly what the criteria are.
+ * These are guaranteed to have their [`ChannelDetails::is_usable`] value set to true, see the
+ * documentation for [`ChannelDetails::is_usable`] for more info on exactly what the criteria
+ * are.
*/
MUST_USE_RES struct LDKCVec_ChannelDetailsZ ChannelManager_list_usable_channels(const struct LDKChannelManager *NONNULL_PTR this_arg);
* Note that this includes RBF or similar transaction replacement strategies - lightning does
* not currently support replacing a funding transaction on an existing channel. Instead,
* create a new channel with a conflicting funding transaction.
+ *
+ * [`Event::FundingGenerationReady`]: crate::util::events::Event::FundingGenerationReady
*/
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);
/**
- * Generates a signed node_announcement from the given arguments and creates a
- * BroadcastNodeAnnouncement event. Note that such messages will be ignored unless peers have
- * seen a channel_announcement from us (ie unless we have public channels open).
+ * Regenerates channel_announcements and generates a signed node_announcement from the given
+ * arguments, providing them in corresponding events via
+ * [`get_and_clear_pending_msg_events`], if at least one public channel has been confirmed
+ * on-chain. This effectively re-broadcasts all channel announcements and sends our node
+ * announcement to ensure that the lightning P2P network is aware of the channels we have and
+ * our network addresses.
*
- * RGB is a node \"color\" and alias is a printable human-readable string to describe this node
- * to humans. They carry no in-protocol meaning.
+ * `rgb` is a node \"color\" and `alias` is a printable human-readable string to describe this
+ * node to humans. They carry no in-protocol meaning.
*
- * addresses represent the set (possibly empty) of socket addresses on which this node accepts
- * incoming connections. These will be broadcast to the network, publicly tying these
- * addresses together. If you wish to preserve user privacy, addresses should likely contain
- * only Tor Onion addresses.
+ * `addresses` represent the set (possibly empty) of socket addresses on which this node
+ * accepts incoming connections. These will be included in the node_announcement, publicly
+ * tying these addresses together and to this node. If you wish to preserve user privacy,
+ * addresses should likely contain only Tor Onion addresses.
*
- * Panics if addresses is absurdly large (more than 500).
+ * Panics if `addresses` is absurdly large (more than 500).
+ *
+ * [`get_and_clear_pending_msg_events`]: MessageSendEventsProvider::get_and_clear_pending_msg_events
*/
void ChannelManager_broadcast_node_announcement(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKThreeBytes rgb, struct LDKThirtyTwoBytes alias, struct LDKCVec_NetAddressZ addresses);
* `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for
* in excess of the current time. This should roughly match the expiry time set in the invoice.
* After this many seconds, we will remove the inbound payment, resulting in any attempts to
- * pay the invoice failing. The BOLT spec suggests 7,200 secs as a default validity time for
+ * pay the invoice failing. The BOLT spec suggests 3,600 secs as a default validity time for
* invoices when no timeout is set.
*
* Note that we use block header time to time-out pending inbound payments (with some margin
*/
struct LDKCResult_CResult_NetAddressu8ZDecodeErrorZ Result_read(struct LDKu8slice ser);
+/**
+ * Read a NetAddress from a byte array, created by NetAddress_write
+ */
+struct LDKCResult_NetAddressDecodeErrorZ NetAddress_read(struct LDKu8slice ser);
+
/**
* Frees any resources used by the UnsignedNodeAnnouncement, if is_owned is set and inner is non-NULL.
*/
*/
uint64_t get_commitment_transaction_number_obscure_factor(struct LDKPublicKey broadcaster_payment_basepoint, struct LDKPublicKey countersignatory_payment_basepoint, bool outbound_from_broadcaster);
+/**
+ * Checks if two InitFeaturess 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 InitFeatures_eq(const struct LDKInitFeatures *NONNULL_PTR a, const struct LDKInitFeatures *NONNULL_PTR b);
+
+/**
+ * Checks if two NodeFeaturess 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 NodeFeatures_eq(const struct LDKNodeFeatures *NONNULL_PTR a, const struct LDKNodeFeatures *NONNULL_PTR b);
+
+/**
+ * Checks if two ChannelFeaturess 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 ChannelFeatures_eq(const struct LDKChannelFeatures *NONNULL_PTR a, const struct LDKChannelFeatures *NONNULL_PTR b);
+
+/**
+ * Checks if two InvoiceFeaturess 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 InvoiceFeatures_eq(const struct LDKInvoiceFeatures *NONNULL_PTR a, const struct LDKInvoiceFeatures *NONNULL_PTR b);
+
/**
* Creates a copy of the InitFeatures
*/
*/
MUST_USE_RES struct LDKInvoiceFeatures InvoiceFeatures_known(void);
+/**
+ * Returns whether the `payment_secret` feature is supported.
+ */
+MUST_USE_RES bool InitFeatures_supports_payment_secret(const struct LDKInitFeatures *NONNULL_PTR this_arg);
+
+/**
+ * Returns whether the `payment_secret` feature is supported.
+ */
+MUST_USE_RES bool NodeFeatures_supports_payment_secret(const struct LDKNodeFeatures *NONNULL_PTR this_arg);
+
+/**
+ * Returns whether the `payment_secret` feature is supported.
+ */
+MUST_USE_RES bool InvoiceFeatures_supports_payment_secret(const struct LDKInvoiceFeatures *NONNULL_PTR this_arg);
+
/**
* Serialize the InitFeatures object into a byte array which can be read by InitFeatures_read
*/
*/
MUST_USE_RES struct LDKRouteHintHop RouteHintHop_new(struct LDKPublicKey src_node_id_arg, uint64_t short_channel_id_arg, struct LDKRoutingFees fees_arg, uint16_t cltv_expiry_delta_arg, struct LDKCOption_u64Z htlc_minimum_msat_arg, struct LDKCOption_u64Z htlc_maximum_msat_arg);
+/**
+ * Checks if two RouteHintHops 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 RouteHintHop_eq(const struct LDKRouteHintHop *NONNULL_PTR a, const struct LDKRouteHintHop *NONNULL_PTR b);
+
/**
* Creates a copy of the RouteHintHop
*/
MUST_USE_RES struct LDKRoutingFees RoutingFees_new(uint32_t base_msat_arg, uint32_t proportional_millionths_arg);
/**
- * Creates a copy of the RoutingFees
+ * Checks if two RoutingFeess contain equal inner contents.
+ * This ignores pointers and is_owned flags and looks at the values in fields.
+ * Two objects with NULL inner values will be considered "equal" here.
*/
-struct LDKRoutingFees RoutingFees_clone(const struct LDKRoutingFees *NONNULL_PTR orig);
+bool RoutingFees_eq(const struct LDKRoutingFees *NONNULL_PTR a, const struct LDKRoutingFees *NONNULL_PTR b);
/**
- * Read a RoutingFees from a byte array, created by RoutingFees_write
+ * Creates a copy of the RoutingFees
*/
-struct LDKCResult_RoutingFeesDecodeErrorZ RoutingFees_read(struct LDKu8slice ser);
+struct LDKRoutingFees RoutingFees_clone(const struct LDKRoutingFees *NONNULL_PTR orig);
/**
* Serialize the RoutingFees object into a byte array which can be read by RoutingFees_read
*/
struct LDKCVec_u8Z RoutingFees_write(const struct LDKRoutingFees *NONNULL_PTR obj);
+/**
+ * Read a RoutingFees from a byte array, created by RoutingFees_write
+ */
+struct LDKCResult_RoutingFeesDecodeErrorZ RoutingFees_read(struct LDKu8slice ser);
+
/**
* Frees any resources used by the NodeAnnouncementInfo, if is_owned is set and inner is non-NULL.
*/
*/
void Invoice_free(struct LDKInvoice this_obj);
+/**
+ * Checks if two Invoices 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 Invoice_eq(const struct LDKInvoice *NONNULL_PTR a, const struct LDKInvoice *NONNULL_PTR b);
+
/**
* Creates a copy of the Invoice
*/
*/
void SignedRawInvoice_free(struct LDKSignedRawInvoice this_obj);
+/**
+ * Checks if two SignedRawInvoices 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 SignedRawInvoice_eq(const struct LDKSignedRawInvoice *NONNULL_PTR a, const struct LDKSignedRawInvoice *NONNULL_PTR b);
+
/**
* Creates a copy of the SignedRawInvoice
*/
*/
void RawInvoice_set_data(struct LDKRawInvoice *NONNULL_PTR this_ptr, struct LDKRawDataPart val);
+/**
+ * Checks if two RawInvoices 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 RawInvoice_eq(const struct LDKRawInvoice *NONNULL_PTR a, const struct LDKRawInvoice *NONNULL_PTR b);
+
/**
* Creates a copy of the RawInvoice
*/
*/
void RawDataPart_set_timestamp(struct LDKRawDataPart *NONNULL_PTR this_ptr, struct LDKPositiveTimestamp val);
+/**
+ * Checks if two RawDataParts 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 RawDataPart_eq(const struct LDKRawDataPart *NONNULL_PTR a, const struct LDKRawDataPart *NONNULL_PTR b);
+
/**
* Creates a copy of the RawDataPart
*/
*/
void PositiveTimestamp_free(struct LDKPositiveTimestamp this_obj);
+/**
+ * Checks if two PositiveTimestamps 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 PositiveTimestamp_eq(const struct LDKPositiveTimestamp *NONNULL_PTR a, const struct LDKPositiveTimestamp *NONNULL_PTR b);
+
/**
* Creates a copy of the PositiveTimestamp
*/
*/
enum LDKSiPrefix SiPrefix_clone(const enum LDKSiPrefix *NONNULL_PTR orig);
+/**
+ * Checks if two SiPrefixs contain equal inner contents.
+ * This ignores pointers and is_owned flags and looks at the values in fields.
+ */
+bool SiPrefix_eq(const enum LDKSiPrefix *NONNULL_PTR a, const enum LDKSiPrefix *NONNULL_PTR b);
+
/**
* Returns the multiplier to go from a BTC value to picoBTC implied by this SiPrefix.
* This is effectively 10^12 * the prefix multiplier
*/
enum LDKCurrency Currency_clone(const enum LDKCurrency *NONNULL_PTR orig);
+/**
+ * Checks if two Currencys contain equal inner contents.
+ * This ignores pointers and is_owned flags and looks at the values in fields.
+ */
+bool Currency_eq(const enum LDKCurrency *NONNULL_PTR a, const enum LDKCurrency *NONNULL_PTR b);
+
/**
* Frees any resources used by the Sha256, if is_owned is set and inner is non-NULL.
*/
void Sha256_free(struct LDKSha256 this_obj);
+/**
+ * Checks if two Sha256s 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 Sha256_eq(const struct LDKSha256 *NONNULL_PTR a, const struct LDKSha256 *NONNULL_PTR b);
+
/**
* Creates a copy of the Sha256
*/
*/
void Description_free(struct LDKDescription this_obj);
+/**
+ * Checks if two Descriptions 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 Description_eq(const struct LDKDescription *NONNULL_PTR a, const struct LDKDescription *NONNULL_PTR b);
+
/**
* Creates a copy of the Description
*/
*/
void PayeePubKey_free(struct LDKPayeePubKey this_obj);
+/**
+ * Checks if two PayeePubKeys 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 PayeePubKey_eq(const struct LDKPayeePubKey *NONNULL_PTR a, const struct LDKPayeePubKey *NONNULL_PTR b);
+
/**
* Creates a copy of the PayeePubKey
*/
*/
void ExpiryTime_free(struct LDKExpiryTime this_obj);
+/**
+ * Checks if two ExpiryTimes 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 ExpiryTime_eq(const struct LDKExpiryTime *NONNULL_PTR a, const struct LDKExpiryTime *NONNULL_PTR b);
+
/**
* Creates a copy of the ExpiryTime
*/
*/
void MinFinalCltvExpiry_free(struct LDKMinFinalCltvExpiry this_obj);
+/**
+ * Checks if two MinFinalCltvExpirys 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 MinFinalCltvExpiry_eq(const struct LDKMinFinalCltvExpiry *NONNULL_PTR a, const struct LDKMinFinalCltvExpiry *NONNULL_PTR b);
+
/**
* Creates a copy of the MinFinalCltvExpiry
*/
*/
struct LDKFallback Fallback_clone(const struct LDKFallback *NONNULL_PTR orig);
+/**
+ * Checks if two Fallbacks contain equal inner contents.
+ * This ignores pointers and is_owned flags and looks at the values in fields.
+ */
+bool Fallback_eq(const struct LDKFallback *NONNULL_PTR a, const struct LDKFallback *NONNULL_PTR b);
+
/**
* Frees any resources used by the InvoiceSignature, if is_owned is set and inner is non-NULL.
*/
void InvoiceSignature_free(struct LDKInvoiceSignature this_obj);
+/**
+ * Checks if two InvoiceSignatures 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 InvoiceSignature_eq(const struct LDKInvoiceSignature *NONNULL_PTR a, const struct LDKInvoiceSignature *NONNULL_PTR b);
+
/**
* Creates a copy of the InvoiceSignature
*/
*/
void RouteHint_free(struct LDKRouteHint this_obj);
+/**
+ * Checks if two RouteHints 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 RouteHint_eq(const struct LDKRouteHint *NONNULL_PTR a, const struct LDKRouteHint *NONNULL_PTR b);
+
/**
* Creates a copy of the RouteHint
*/
*/
enum LDKCreationError CreationError_clone(const enum LDKCreationError *NONNULL_PTR orig);
+/**
+ * Checks if two CreationErrors contain equal inner contents.
+ * This ignores pointers and is_owned flags and looks at the values in fields.
+ */
+bool CreationError_eq(const enum LDKCreationError *NONNULL_PTR a, const enum LDKCreationError *NONNULL_PTR b);
+
/**
* Get the string representation of a CreationError object
*/
*/
enum LDKSemanticError SemanticError_clone(const enum LDKSemanticError *NONNULL_PTR orig);
+/**
+ * Checks if two SemanticErrors contain equal inner contents.
+ * This ignores pointers and is_owned flags and looks at the values in fields.
+ */
+bool SemanticError_eq(const enum LDKSemanticError *NONNULL_PTR a, const enum LDKSemanticError *NONNULL_PTR b);
+
/**
* Get the string representation of a SemanticError object
*/
*/
struct LDKSignOrCreationError SignOrCreationError_clone(const struct LDKSignOrCreationError *NONNULL_PTR orig);
+/**
+ * Checks if two SignOrCreationErrors contain equal inner contents.
+ * This ignores pointers and is_owned flags and looks at the values in fields.
+ */
+bool SignOrCreationError_eq(const struct LDKSignOrCreationError *NONNULL_PTR a, const struct LDKSignOrCreationError *NONNULL_PTR b);
+
/**
* Get the string representation of a SignOrCreationError object
*/
const LDKEventsProvider* operator &() const { return &self; }
const LDKEventsProvider* operator ->() const { return &self; }
};
+class EventHandler {
+private:
+ LDKEventHandler self;
+public:
+ EventHandler(const EventHandler&) = delete;
+ EventHandler(EventHandler&& o) : self(o.self) { memset(&o, 0, sizeof(EventHandler)); }
+ EventHandler(LDKEventHandler&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKEventHandler)); }
+ operator LDKEventHandler() && { LDKEventHandler res = self; memset(&self, 0, sizeof(LDKEventHandler)); return res; }
+ ~EventHandler() { EventHandler_free(self); }
+ EventHandler& operator=(EventHandler&& o) { EventHandler_free(self); self = o.self; memset(&o, 0, sizeof(EventHandler)); return *this; }
+ LDKEventHandler* operator &() { return &self; }
+ LDKEventHandler* operator ->() { return &self; }
+ const LDKEventHandler* operator &() const { return &self; }
+ const LDKEventHandler* operator ->() const { return &self; }
+};
class NetworkGraph {
private:
LDKNetworkGraph self;
const LDKCResult_TxOutAccessErrorZ* operator &() const { return &self; }
const LDKCResult_TxOutAccessErrorZ* operator ->() const { return &self; }
};
+class CResult_NetAddressDecodeErrorZ {
+private:
+ LDKCResult_NetAddressDecodeErrorZ self;
+public:
+ CResult_NetAddressDecodeErrorZ(const CResult_NetAddressDecodeErrorZ&) = delete;
+ CResult_NetAddressDecodeErrorZ(CResult_NetAddressDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_NetAddressDecodeErrorZ)); }
+ CResult_NetAddressDecodeErrorZ(LDKCResult_NetAddressDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_NetAddressDecodeErrorZ)); }
+ operator LDKCResult_NetAddressDecodeErrorZ() && { LDKCResult_NetAddressDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_NetAddressDecodeErrorZ)); return res; }
+ ~CResult_NetAddressDecodeErrorZ() { CResult_NetAddressDecodeErrorZ_free(self); }
+ CResult_NetAddressDecodeErrorZ& operator=(CResult_NetAddressDecodeErrorZ&& o) { CResult_NetAddressDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_NetAddressDecodeErrorZ)); return *this; }
+ LDKCResult_NetAddressDecodeErrorZ* operator &() { return &self; }
+ LDKCResult_NetAddressDecodeErrorZ* operator ->() { return &self; }
+ const LDKCResult_NetAddressDecodeErrorZ* operator &() const { return &self; }
+ const LDKCResult_NetAddressDecodeErrorZ* operator ->() const { return &self; }
+};
class CResult_UnsignedNodeAnnouncementDecodeErrorZ {
private:
LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ self;
const LDKCResult_ReplyChannelRangeDecodeErrorZ* operator &() const { return &self; }
const LDKCResult_ReplyChannelRangeDecodeErrorZ* operator ->() const { return &self; }
};
-class CResult_GossipTimestampFilterDecodeErrorZ {
-private:
- LDKCResult_GossipTimestampFilterDecodeErrorZ self;
-public:
- CResult_GossipTimestampFilterDecodeErrorZ(const CResult_GossipTimestampFilterDecodeErrorZ&) = delete;
- CResult_GossipTimestampFilterDecodeErrorZ(CResult_GossipTimestampFilterDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_GossipTimestampFilterDecodeErrorZ)); }
- CResult_GossipTimestampFilterDecodeErrorZ(LDKCResult_GossipTimestampFilterDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ)); }
- operator LDKCResult_GossipTimestampFilterDecodeErrorZ() && { LDKCResult_GossipTimestampFilterDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ)); return res; }
- ~CResult_GossipTimestampFilterDecodeErrorZ() { CResult_GossipTimestampFilterDecodeErrorZ_free(self); }
- CResult_GossipTimestampFilterDecodeErrorZ& operator=(CResult_GossipTimestampFilterDecodeErrorZ&& o) { CResult_GossipTimestampFilterDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_GossipTimestampFilterDecodeErrorZ)); return *this; }
- LDKCResult_GossipTimestampFilterDecodeErrorZ* operator &() { return &self; }
- LDKCResult_GossipTimestampFilterDecodeErrorZ* operator ->() { return &self; }
- const LDKCResult_GossipTimestampFilterDecodeErrorZ* operator &() const { return &self; }
- const LDKCResult_GossipTimestampFilterDecodeErrorZ* operator ->() const { return &self; }
-};
class CResult_ChannelReestablishDecodeErrorZ {
private:
LDKCResult_ChannelReestablishDecodeErrorZ self;
const LDKCResult_ChannelReestablishDecodeErrorZ* operator &() const { return &self; }
const LDKCResult_ChannelReestablishDecodeErrorZ* operator ->() const { return &self; }
};
+class CResult_GossipTimestampFilterDecodeErrorZ {
+private:
+ LDKCResult_GossipTimestampFilterDecodeErrorZ self;
+public:
+ CResult_GossipTimestampFilterDecodeErrorZ(const CResult_GossipTimestampFilterDecodeErrorZ&) = delete;
+ CResult_GossipTimestampFilterDecodeErrorZ(CResult_GossipTimestampFilterDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_GossipTimestampFilterDecodeErrorZ)); }
+ CResult_GossipTimestampFilterDecodeErrorZ(LDKCResult_GossipTimestampFilterDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ)); }
+ operator LDKCResult_GossipTimestampFilterDecodeErrorZ() && { LDKCResult_GossipTimestampFilterDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ)); return res; }
+ ~CResult_GossipTimestampFilterDecodeErrorZ() { CResult_GossipTimestampFilterDecodeErrorZ_free(self); }
+ CResult_GossipTimestampFilterDecodeErrorZ& operator=(CResult_GossipTimestampFilterDecodeErrorZ&& o) { CResult_GossipTimestampFilterDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_GossipTimestampFilterDecodeErrorZ)); return *this; }
+ LDKCResult_GossipTimestampFilterDecodeErrorZ* operator &() { return &self; }
+ LDKCResult_GossipTimestampFilterDecodeErrorZ* operator ->() { return &self; }
+ const LDKCResult_GossipTimestampFilterDecodeErrorZ* operator &() const { return &self; }
+ const LDKCResult_GossipTimestampFilterDecodeErrorZ* operator ->() const { return &self; }
+};
class CResult_InvoiceSignOrCreationErrorZ {
private:
LDKCResult_InvoiceSignOrCreationErrorZ self;
/// but with all dynamically-allocated buffers duplicated in new buffers.
pub extern "C" fn CResult_CResult_NetAddressu8ZDecodeErrorZ_clone(orig: &CResult_CResult_NetAddressu8ZDecodeErrorZ) -> CResult_CResult_NetAddressu8ZDecodeErrorZ { orig.clone() }
#[repr(C)]
+/// The contents of CResult_NetAddressDecodeErrorZ
+pub union CResult_NetAddressDecodeErrorZPtr {
+ /// A pointer to the contents in the success state.
+ /// Reading from this pointer when `result_ok` is not set is undefined.
+ pub result: *mut crate::lightning::ln::msgs::NetAddress,
+ /// A pointer to the contents in the error state.
+ /// Reading from this pointer when `result_ok` is set is undefined.
+ pub err: *mut crate::lightning::ln::msgs::DecodeError,
+}
+#[repr(C)]
+/// A CResult_NetAddressDecodeErrorZ represents the result of a fallible operation,
+/// containing a crate::lightning::ln::msgs::NetAddress on success and a crate::lightning::ln::msgs::DecodeError on failure.
+/// `result_ok` indicates the overall state, and the contents are provided via `contents`.
+pub struct CResult_NetAddressDecodeErrorZ {
+ /// The contents of this CResult_NetAddressDecodeErrorZ, accessible via either
+ /// `err` or `result` depending on the state of `result_ok`.
+ pub contents: CResult_NetAddressDecodeErrorZPtr,
+ /// Whether this CResult_NetAddressDecodeErrorZ represents a success state.
+ pub result_ok: bool,
+}
+#[no_mangle]
+/// Creates a new CResult_NetAddressDecodeErrorZ in the success state.
+pub extern "C" fn CResult_NetAddressDecodeErrorZ_ok(o: crate::lightning::ln::msgs::NetAddress) -> CResult_NetAddressDecodeErrorZ {
+ CResult_NetAddressDecodeErrorZ {
+ contents: CResult_NetAddressDecodeErrorZPtr {
+ result: Box::into_raw(Box::new(o)),
+ },
+ result_ok: true,
+ }
+}
+#[no_mangle]
+/// Creates a new CResult_NetAddressDecodeErrorZ in the error state.
+pub extern "C" fn CResult_NetAddressDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_NetAddressDecodeErrorZ {
+ CResult_NetAddressDecodeErrorZ {
+ contents: CResult_NetAddressDecodeErrorZPtr {
+ err: Box::into_raw(Box::new(e)),
+ },
+ result_ok: false,
+ }
+}
+#[no_mangle]
+/// Frees any resources used by the CResult_NetAddressDecodeErrorZ.
+pub extern "C" fn CResult_NetAddressDecodeErrorZ_free(_res: CResult_NetAddressDecodeErrorZ) { }
+impl Drop for CResult_NetAddressDecodeErrorZ {
+ fn drop(&mut self) {
+ if self.result_ok {
+ if unsafe { !(self.contents.result as *mut ()).is_null() } {
+ let _ = unsafe { Box::from_raw(self.contents.result) };
+ }
+ } else {
+ if unsafe { !(self.contents.err as *mut ()).is_null() } {
+ let _ = unsafe { Box::from_raw(self.contents.err) };
+ }
+ }
+ }
+}
+impl From<crate::c_types::CResultTempl<crate::lightning::ln::msgs::NetAddress, crate::lightning::ln::msgs::DecodeError>> for CResult_NetAddressDecodeErrorZ {
+ fn from(mut o: crate::c_types::CResultTempl<crate::lightning::ln::msgs::NetAddress, crate::lightning::ln::msgs::DecodeError>) -> Self {
+ let contents = if o.result_ok {
+ let result = unsafe { o.contents.result };
+ unsafe { o.contents.result = std::ptr::null_mut() };
+ CResult_NetAddressDecodeErrorZPtr { result }
+ } else {
+ let err = unsafe { o.contents.err };
+ unsafe { o.contents.err = std::ptr::null_mut(); }
+ CResult_NetAddressDecodeErrorZPtr { err }
+ };
+ Self {
+ contents,
+ result_ok: o.result_ok,
+ }
+ }
+}
+impl Clone for CResult_NetAddressDecodeErrorZ {
+ fn clone(&self) -> Self {
+ if self.result_ok {
+ Self { result_ok: true, contents: CResult_NetAddressDecodeErrorZPtr {
+ result: Box::into_raw(Box::new(<crate::lightning::ln::msgs::NetAddress>::clone(unsafe { &*self.contents.result })))
+ } }
+ } else {
+ Self { result_ok: false, contents: CResult_NetAddressDecodeErrorZPtr {
+ err: Box::into_raw(Box::new(<crate::lightning::ln::msgs::DecodeError>::clone(unsafe { &*self.contents.err })))
+ } }
+ }
+ }
+}
+#[no_mangle]
+/// Creates a new CResult_NetAddressDecodeErrorZ which has the same data as `orig`
+/// but with all dynamically-allocated buffers duplicated in new buffers.
+pub extern "C" fn CResult_NetAddressDecodeErrorZ_clone(orig: &CResult_NetAddressDecodeErrorZ) -> CResult_NetAddressDecodeErrorZ { orig.clone() }
+#[repr(C)]
/// A dynamically-allocated array of crate::lightning::ln::msgs::UpdateAddHTLCs of arbitrary size.
/// This corresponds to std::vector in C++
pub struct CVec_UpdateAddHTLCZ {
crate::lightning::util::events::EventsProvider {
this_arg: unsafe { (*this_arg).inner as *mut c_void },
free: None,
- get_and_clear_pending_events: ChainMonitor_EventsProvider_get_and_clear_pending_events,
+ process_pending_events: ChainMonitor_EventsProvider_process_pending_events,
}
}
-#[must_use]
-extern "C" fn ChainMonitor_EventsProvider_get_and_clear_pending_events(this_arg: *const c_void) -> crate::c_types::derived::CVec_EventZ {
- let mut ret = <nativeChainMonitor as lightning::util::events::EventsProvider<>>::get_and_clear_pending_events(unsafe { &mut *(this_arg as *mut nativeChainMonitor) }, );
- let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::util::events::Event::native_into(item) }); };
- local_ret.into()
+extern "C" fn ChainMonitor_EventsProvider_process_pending_events(this_arg: *const c_void, mut handler: crate::lightning::util::events::EventHandler) {
+ <nativeChainMonitor as lightning::util::events::EventsProvider<>>::process_pending_events(unsafe { &mut *(this_arg as *mut nativeChainMonitor) }, handler)
}
let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::chain::channelmonitor::HTLCUpdate { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
local_res
}
+/// Number of blocks we wait on seeing a HTLC output being solved before we fail corresponding inbound
+/// HTLCs. This prevents us from failing backwards and then getting a reorg resulting in us losing money.
+
+#[no_mangle]
+pub static ANTI_REORG_DELAY: u32 = lightning::chain::channelmonitor::ANTI_REORG_DELAY;
use lightning::chain::channelmonitor::ChannelMonitor as nativeChannelMonitorImport;
type nativeChannelMonitor = nativeChannelMonitorImport<crate::lightning::chain::keysinterface::Sign>;
/// May return Err if key derivation fails. Callers, such as ChannelMonitor, will panic in such a case.
#[must_use]
pub sign_holder_commitment_and_htlcs: extern "C" fn (this_arg: *const c_void, commitment_tx: &crate::lightning::ln::chan_utils::HolderCommitmentTransaction) -> crate::c_types::derived::CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ,
- /// Create a signature for the given input in a transaction spending an HTLC or commitment
- /// transaction output when our counterparty broadcasts an old state.
+ /// 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 multiples outputs at the same time if timelocks are
+ /// 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 multiples time for same output(s) if a fee-bump is needed with regards
+ /// 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).
+ #[must_use]
+ pub sign_justice_revoked_output: extern "C" fn (this_arg: *const c_void, justice_tx: crate::c_types::Transaction, input: usize, amount: u64, per_commitment_key: *const [u8; 32]) -> crate::c_types::derived::CResult_SignatureNoneZ,
+ /// 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.
/// not allow the spending of any funds by itself (you need our holder revocation_secret to do
/// so).
///
- /// htlc holds HTLC elements (hash, timelock) if the output being spent is a HTLC output, thus
- /// changing the format of the witness script (which is committed to in the BIP 143
- /// signatures).
+ /// htlc holds HTLC elements (hash, timelock), thus changing the format of the witness script
+ /// (which is committed to in the BIP 143 signatures).
#[must_use]
- pub sign_justice_transaction: extern "C" fn (this_arg: *const c_void, justice_tx: crate::c_types::Transaction, input: usize, amount: u64, per_commitment_key: *const [u8; 32], htlc: &crate::lightning::ln::chan_utils::HTLCOutputInCommitment) -> crate::c_types::derived::CResult_SignatureNoneZ,
+ pub sign_justice_revoked_htlc: extern "C" fn (this_arg: *const c_void, justice_tx: crate::c_types::Transaction, input: usize, amount: u64, per_commitment_key: *const [u8; 32], htlc: &crate::lightning::ln::chan_utils::HTLCOutputInCommitment) -> crate::c_types::derived::CResult_SignatureNoneZ,
/// Create a signature for a claiming transaction for a HTLC output on a counterparty's commitment
/// transaction, either offered or received.
///
let mut local_ret = match ret.result_ok { true => Ok( { let (mut orig_ret_0_0, mut orig_ret_0_1) = (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).to_rust(); let mut local_orig_ret_0_1 = Vec::new(); for mut item in orig_ret_0_1.into_rust().drain(..) { local_orig_ret_0_1.push( { item.into_rust() }); }; let mut local_ret_0 = (orig_ret_0_0.into_rust(), local_orig_ret_0_1); local_ret_0 }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })};
local_ret
}
- fn sign_justice_transaction(&self, mut justice_tx: &bitcoin::blockdata::transaction::Transaction, mut input: usize, mut amount: u64, mut per_commitment_key: &bitcoin::secp256k1::key::SecretKey, mut htlc: &Option<lightning::ln::chan_utils::HTLCOutputInCommitment>, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1<bitcoin::secp256k1::All>) -> Result<bitcoin::secp256k1::Signature, ()> {
- let mut local_htlc = &crate::lightning::ln::chan_utils::HTLCOutputInCommitment { inner: unsafe { (if htlc.is_none() { std::ptr::null() } else { { (htlc.as_ref().unwrap()) } } as *const _) as *mut _ }, is_owned: false };
- let mut ret = (self.sign_justice_transaction)(self.this_arg, crate::c_types::Transaction::from_bitcoin(justice_tx), input, amount, per_commitment_key.as_ref(), local_htlc);
+ fn sign_justice_revoked_output(&self, mut justice_tx: &bitcoin::blockdata::transaction::Transaction, mut input: usize, mut amount: u64, mut per_commitment_key: &bitcoin::secp256k1::key::SecretKey, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1<bitcoin::secp256k1::All>) -> Result<bitcoin::secp256k1::Signature, ()> {
+ let mut ret = (self.sign_justice_revoked_output)(self.this_arg, crate::c_types::Transaction::from_bitcoin(justice_tx), input, amount, per_commitment_key.as_ref());
+ let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })};
+ local_ret
+ }
+ fn sign_justice_revoked_htlc(&self, mut justice_tx: &bitcoin::blockdata::transaction::Transaction, mut input: usize, mut amount: u64, mut per_commitment_key: &bitcoin::secp256k1::key::SecretKey, mut htlc: &lightning::ln::chan_utils::HTLCOutputInCommitment, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1<bitcoin::secp256k1::All>) -> Result<bitcoin::secp256k1::Signature, ()> {
+ let mut ret = (self.sign_justice_revoked_htlc)(self.this_arg, crate::c_types::Transaction::from_bitcoin(justice_tx), input, amount, per_commitment_key.as_ref(), &crate::lightning::ln::chan_utils::HTLCOutputInCommitment { inner: unsafe { (htlc as *const _) as *mut _ }, is_owned: false });
let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })};
local_ret
}
let mut local_ret = match ret.result_ok { true => Ok( { let (mut orig_ret_0_0, mut orig_ret_0_1) = (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).to_rust(); let mut local_orig_ret_0_1 = Vec::new(); for mut item in orig_ret_0_1.into_rust().drain(..) { local_orig_ret_0_1.push( { item.into_rust() }); }; let mut local_ret_0 = (orig_ret_0_0.into_rust(), local_orig_ret_0_1); local_ret_0 }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })};
local_ret
}
- fn sign_justice_transaction(&self, mut justice_tx: &bitcoin::blockdata::transaction::Transaction, mut input: usize, mut amount: u64, mut per_commitment_key: &bitcoin::secp256k1::key::SecretKey, mut htlc: &Option<lightning::ln::chan_utils::HTLCOutputInCommitment>, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1<bitcoin::secp256k1::All>) -> Result<bitcoin::secp256k1::Signature, ()> {
- let mut local_htlc = &crate::lightning::ln::chan_utils::HTLCOutputInCommitment { inner: unsafe { (if htlc.is_none() { std::ptr::null() } else { { (htlc.as_ref().unwrap()) } } as *const _) as *mut _ }, is_owned: false };
- let mut ret = (self.BaseSign.sign_justice_transaction)(self.this_arg, crate::c_types::Transaction::from_bitcoin(justice_tx), input, amount, per_commitment_key.as_ref(), local_htlc);
+ fn sign_justice_revoked_output(&self, mut justice_tx: &bitcoin::blockdata::transaction::Transaction, mut input: usize, mut amount: u64, mut per_commitment_key: &bitcoin::secp256k1::key::SecretKey, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1<bitcoin::secp256k1::All>) -> Result<bitcoin::secp256k1::Signature, ()> {
+ let mut ret = (self.BaseSign.sign_justice_revoked_output)(self.this_arg, crate::c_types::Transaction::from_bitcoin(justice_tx), input, amount, per_commitment_key.as_ref());
+ let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })};
+ local_ret
+ }
+ fn sign_justice_revoked_htlc(&self, mut justice_tx: &bitcoin::blockdata::transaction::Transaction, mut input: usize, mut amount: u64, mut per_commitment_key: &bitcoin::secp256k1::key::SecretKey, mut htlc: &lightning::ln::chan_utils::HTLCOutputInCommitment, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1<bitcoin::secp256k1::All>) -> Result<bitcoin::secp256k1::Signature, ()> {
+ let mut ret = (self.BaseSign.sign_justice_revoked_htlc)(self.this_arg, crate::c_types::Transaction::from_bitcoin(justice_tx), input, amount, per_commitment_key.as_ref(), &crate::lightning::ln::chan_utils::HTLCOutputInCommitment { inner: unsafe { (htlc as *const _) as *mut _ }, is_owned: false });
let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })};
local_ret
}
channel_keys_id: InMemorySigner_BaseSign_channel_keys_id,
sign_counterparty_commitment: InMemorySigner_BaseSign_sign_counterparty_commitment,
sign_holder_commitment_and_htlcs: InMemorySigner_BaseSign_sign_holder_commitment_and_htlcs,
- sign_justice_transaction: InMemorySigner_BaseSign_sign_justice_transaction,
+ sign_justice_revoked_output: InMemorySigner_BaseSign_sign_justice_revoked_output,
+ sign_justice_revoked_htlc: InMemorySigner_BaseSign_sign_justice_revoked_htlc,
sign_counterparty_htlc_transaction: InMemorySigner_BaseSign_sign_counterparty_htlc_transaction,
sign_closing_transaction: InMemorySigner_BaseSign_sign_closing_transaction,
sign_channel_announcement: InMemorySigner_BaseSign_sign_channel_announcement,
local_ret
}
#[must_use]
-extern "C" fn InMemorySigner_BaseSign_sign_justice_transaction(this_arg: *const c_void, mut justice_tx: crate::c_types::Transaction, mut input: usize, mut amount: u64, per_commitment_key: *const [u8; 32], htlc: &crate::lightning::ln::chan_utils::HTLCOutputInCommitment) -> crate::c_types::derived::CResult_SignatureNoneZ {
- let mut local_htlc = if htlc.inner.is_null() { None } else { Some((* { unsafe { &*htlc.inner } }).clone()) };
- let mut ret = <nativeInMemorySigner as lightning::chain::keysinterface::BaseSign<>>::sign_justice_transaction(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, &justice_tx.into_bitcoin(), input, amount, &::bitcoin::secp256k1::key::SecretKey::from_slice(&unsafe { *per_commitment_key}[..]).unwrap(), &local_htlc, secp256k1::SECP256K1);
+extern "C" fn InMemorySigner_BaseSign_sign_justice_revoked_output(this_arg: *const c_void, mut justice_tx: crate::c_types::Transaction, mut input: usize, mut amount: u64, per_commitment_key: *const [u8; 32]) -> crate::c_types::derived::CResult_SignatureNoneZ {
+ let mut ret = <nativeInMemorySigner as lightning::chain::keysinterface::BaseSign<>>::sign_justice_revoked_output(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, &justice_tx.into_bitcoin(), input, amount, &::bitcoin::secp256k1::key::SecretKey::from_slice(&unsafe { *per_commitment_key}[..]).unwrap(), secp256k1::SECP256K1);
+ let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::Signature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() };
+ local_ret
+}
+#[must_use]
+extern "C" fn InMemorySigner_BaseSign_sign_justice_revoked_htlc(this_arg: *const c_void, mut justice_tx: crate::c_types::Transaction, mut input: usize, mut amount: u64, per_commitment_key: *const [u8; 32], htlc: &crate::lightning::ln::chan_utils::HTLCOutputInCommitment) -> crate::c_types::derived::CResult_SignatureNoneZ {
+ let mut ret = <nativeInMemorySigner as lightning::chain::keysinterface::BaseSign<>>::sign_justice_revoked_htlc(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, &justice_tx.into_bitcoin(), input, amount, &::bitcoin::secp256k1::key::SecretKey::from_slice(&unsafe { *per_commitment_key}[..]).unwrap(), unsafe { &*htlc.inner }, secp256k1::SECP256K1);
let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::Signature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() };
local_ret
}
channel_keys_id: InMemorySigner_BaseSign_channel_keys_id,
sign_counterparty_commitment: InMemorySigner_BaseSign_sign_counterparty_commitment,
sign_holder_commitment_and_htlcs: InMemorySigner_BaseSign_sign_holder_commitment_and_htlcs,
- sign_justice_transaction: InMemorySigner_BaseSign_sign_justice_transaction,
+ sign_justice_revoked_output: InMemorySigner_BaseSign_sign_justice_revoked_output,
+ sign_justice_revoked_htlc: InMemorySigner_BaseSign_sign_justice_revoked_htlc,
sign_counterparty_htlc_transaction: InMemorySigner_BaseSign_sign_counterparty_htlc_transaction,
sign_closing_transaction: InMemorySigner_BaseSign_sign_closing_transaction,
sign_channel_announcement: InMemorySigner_BaseSign_sign_channel_announcement,
channel_keys_id: InMemorySigner_BaseSign_channel_keys_id,
sign_counterparty_commitment: InMemorySigner_BaseSign_sign_counterparty_commitment,
sign_holder_commitment_and_htlcs: InMemorySigner_BaseSign_sign_holder_commitment_and_htlcs,
- sign_justice_transaction: InMemorySigner_BaseSign_sign_justice_transaction,
+ sign_justice_revoked_output: InMemorySigner_BaseSign_sign_justice_revoked_output,
+ sign_justice_revoked_htlc: InMemorySigner_BaseSign_sign_justice_revoked_htlc,
sign_counterparty_htlc_transaction: InMemorySigner_BaseSign_sign_counterparty_htlc_transaction,
sign_closing_transaction: InMemorySigner_BaseSign_sign_closing_transaction,
sign_channel_announcement: InMemorySigner_BaseSign_sign_channel_announcement,
pub mod channelmonitor;
pub mod transaction;
pub mod keysinterface;
+mod onchaintx {
+
+use std::str::FromStr;
+use std::ffi::c_void;
+use bitcoin::hashes::Hash;
+use crate::c_types::*;
+
+}
+mod package {
+
+use std::str::FromStr;
+use std::ffi::c_void;
+use bitcoin::hashes::Hash;
+use crate::c_types::*;
+
+}
/// An error when accessing the chain via [`Access`].
#[must_use]
#[derive(Clone)]
pub extern "C" fn OutPoint_clone(orig: &OutPoint) -> OutPoint {
orig.clone()
}
+/// Checks if two OutPoints 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.
+#[no_mangle]
+pub extern "C" fn OutPoint_eq(a: &OutPoint, b: &OutPoint) -> bool {
+ if a.inner == b.inner { return true; }
+ if a.inner.is_null() || b.inner.is_null() { return false; }
+ if unsafe { &*a.inner } == unsafe { &*b.inner } { true } else { false }
+}
+/// Checks if two OutPoints contain equal inner contents.
+#[no_mangle]
+pub extern "C" fn OutPoint_hash(o: &OutPoint) -> u64 {
+ if o.inner.is_null() { return 0; }
+ // Note that we'd love to use std::collections::hash_map::DefaultHasher but its not in core
+ #[allow(deprecated)]
+ let mut hasher = core::hash::SipHasher::new();
+ std::hash::Hash::hash(unsafe { &*o.inner }, &mut hasher);
+ std::hash::Hasher::finish(&hasher)
+}
/// Convert an `OutPoint` to a lightning channel id.
#[must_use]
#[no_mangle]
#[no_mangle]
pub static BREAKDOWN_TIMEOUT: u16 = lightning::ln::channelmanager::BREAKDOWN_TIMEOUT;
/// The minimum number of blocks between an inbound HTLC's CLTV and the corresponding outbound
-/// HTLC's CLTV. The current default represents roughly six hours of blocks at six blocks/hour.
+/// HTLC's CLTV. The current default represents roughly seven hours of blocks at six blocks/hour.
///
/// This can be increased (but not decreased) through [`ChannelConfig::cltv_expiry_delta`]
///
pub extern "C" fn ChannelDetails_set_channel_id(this_ptr: &mut ChannelDetails, mut val: crate::c_types::ThirtyTwoBytes) {
unsafe { &mut *this_ptr.inner }.channel_id = val.data;
}
+/// The Channel's funding transaction output, if we've negotiated the funding transaction with
+/// our counterparty already.
+///
+/// Note that, if this has been set, `channel_id` will be equivalent to
+/// `funding_txo.unwrap().to_channel_id()`.
+#[no_mangle]
+pub extern "C" fn ChannelDetails_get_funding_txo(this_ptr: &ChannelDetails) -> crate::lightning::chain::transaction::OutPoint {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.funding_txo;
+ let mut local_inner_val = crate::lightning::chain::transaction::OutPoint { inner: unsafe { (if inner_val.is_none() { std::ptr::null() } else { { (inner_val.as_ref().unwrap()) } } as *const _) as *mut _ }, is_owned: false };
+ local_inner_val
+}
+/// The Channel's funding transaction output, if we've negotiated the funding transaction with
+/// our counterparty already.
+///
+/// Note that, if this has been set, `channel_id` will be equivalent to
+/// `funding_txo.unwrap().to_channel_id()`.
+#[no_mangle]
+pub extern "C" fn ChannelDetails_set_funding_txo(this_ptr: &mut ChannelDetails, mut val: crate::lightning::chain::transaction::OutPoint) {
+ let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
+ unsafe { &mut *this_ptr.inner }.funding_txo = local_val;
+}
/// The position of the funding transaction in the chain. None if the funding transaction has
/// not yet been confirmed and the channel fully opened.
#[no_mangle]
pub extern "C" fn ChannelDetails_set_inbound_capacity_msat(this_ptr: &mut ChannelDetails, mut val: u64) {
unsafe { &mut *this_ptr.inner }.inbound_capacity_msat = val;
}
+/// True if the channel was initiated (and thus funded) by us.
+#[no_mangle]
+pub extern "C" fn ChannelDetails_get_is_outbound(this_ptr: &ChannelDetails) -> bool {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.is_outbound;
+ *inner_val
+}
+/// True if the channel was initiated (and thus funded) by us.
+#[no_mangle]
+pub extern "C" fn ChannelDetails_set_is_outbound(this_ptr: &mut ChannelDetails, mut val: bool) {
+ unsafe { &mut *this_ptr.inner }.is_outbound = val;
+}
+/// True if the channel is confirmed, funding_locked messages have been exchanged, and the
+/// channel is not currently being shut down. `funding_locked` message exchange implies the
+/// required confirmation count has been reached (and we were connected to the peer at some
+/// point after the funding transaction received enough confirmations).
+#[no_mangle]
+pub extern "C" fn ChannelDetails_get_is_funding_locked(this_ptr: &ChannelDetails) -> bool {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.is_funding_locked;
+ *inner_val
+}
+/// True if the channel is confirmed, funding_locked messages have been exchanged, and the
+/// channel is not currently being shut down. `funding_locked` message exchange implies the
+/// required confirmation count has been reached (and we were connected to the peer at some
+/// point after the funding transaction received enough confirmations).
+#[no_mangle]
+pub extern "C" fn ChannelDetails_set_is_funding_locked(this_ptr: &mut ChannelDetails, mut val: bool) {
+ unsafe { &mut *this_ptr.inner }.is_funding_locked = val;
+}
/// True if the channel is (a) confirmed and funding_locked messages have been exchanged, (b)
-/// the peer is connected, and (c) no monitor update failure is pending resolution.
+/// the peer is connected, (c) no monitor update failure is pending resolution, and (d) the
+/// channel is not currently negotiating a shutdown.
+///
+/// This is a strict superset of `is_funding_locked`.
#[no_mangle]
-pub extern "C" fn ChannelDetails_get_is_live(this_ptr: &ChannelDetails) -> bool {
- let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.is_live;
+pub extern "C" fn ChannelDetails_get_is_usable(this_ptr: &ChannelDetails) -> bool {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.is_usable;
*inner_val
}
/// True if the channel is (a) confirmed and funding_locked messages have been exchanged, (b)
-/// the peer is connected, and (c) no monitor update failure is pending resolution.
+/// the peer is connected, (c) no monitor update failure is pending resolution, and (d) the
+/// channel is not currently negotiating a shutdown.
+///
+/// This is a strict superset of `is_funding_locked`.
+#[no_mangle]
+pub extern "C" fn ChannelDetails_set_is_usable(this_ptr: &mut ChannelDetails, mut val: bool) {
+ unsafe { &mut *this_ptr.inner }.is_usable = val;
+}
+/// True if this channel is (or will be) publicly-announced.
#[no_mangle]
-pub extern "C" fn ChannelDetails_set_is_live(this_ptr: &mut ChannelDetails, mut val: bool) {
- unsafe { &mut *this_ptr.inner }.is_live = val;
+pub extern "C" fn ChannelDetails_get_is_public(this_ptr: &ChannelDetails) -> bool {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.is_public;
+ *inner_val
+}
+/// True if this channel is (or will be) publicly-announced.
+#[no_mangle]
+pub extern "C" fn ChannelDetails_set_is_public(this_ptr: &mut ChannelDetails, mut val: bool) {
+ unsafe { &mut *this_ptr.inner }.is_public = val;
}
impl Clone for ChannelDetails {
fn clone(&self) -> Self {
/// Gets the list of usable channels, in random order. Useful as an argument to
/// get_route to ensure non-announced channels are used.
///
-/// These are guaranteed to have their is_live value set to true, see the documentation for
-/// ChannelDetails::is_live for more info on exactly what the criteria are.
+/// These are guaranteed to have their [`ChannelDetails::is_usable`] value set to true, see the
+/// documentation for [`ChannelDetails::is_usable`] for more info on exactly what the criteria
+/// are.
#[must_use]
#[no_mangle]
pub extern "C" fn ChannelManager_list_usable_channels(this_arg: &ChannelManager) -> crate::c_types::derived::CVec_ChannelDetailsZ {
/// Note that this includes RBF or similar transaction replacement strategies - lightning does
/// not currently support replacing a funding transaction on an existing channel. Instead,
/// create a new channel with a conflicting funding transaction.
+///
+/// [`Event::FundingGenerationReady`]: crate::util::events::Event::FundingGenerationReady
#[must_use]
#[no_mangle]
pub extern "C" fn ChannelManager_funding_transaction_generated(this_arg: &ChannelManager, temporary_channel_id: *const [u8; 32], mut funding_transaction: crate::c_types::Transaction) -> crate::c_types::derived::CResult_NoneAPIErrorZ {
local_ret
}
-/// Generates a signed node_announcement from the given arguments and creates a
-/// BroadcastNodeAnnouncement event. Note that such messages will be ignored unless peers have
-/// seen a channel_announcement from us (ie unless we have public channels open).
+/// Regenerates channel_announcements and generates a signed node_announcement from the given
+/// arguments, providing them in corresponding events via
+/// [`get_and_clear_pending_msg_events`], if at least one public channel has been confirmed
+/// on-chain. This effectively re-broadcasts all channel announcements and sends our node
+/// announcement to ensure that the lightning P2P network is aware of the channels we have and
+/// our network addresses.
///
-/// RGB is a node \"color\" and alias is a printable human-readable string to describe this node
-/// to humans. They carry no in-protocol meaning.
+/// `rgb` is a node \"color\" and `alias` is a printable human-readable string to describe this
+/// node to humans. They carry no in-protocol meaning.
///
-/// addresses represent the set (possibly empty) of socket addresses on which this node accepts
-/// incoming connections. These will be broadcast to the network, publicly tying these
-/// addresses together. If you wish to preserve user privacy, addresses should likely contain
-/// only Tor Onion addresses.
+/// `addresses` represent the set (possibly empty) of socket addresses on which this node
+/// accepts incoming connections. These will be included in the node_announcement, publicly
+/// tying these addresses together and to this node. If you wish to preserve user privacy,
+/// addresses should likely contain only Tor Onion addresses.
///
-/// Panics if addresses is absurdly large (more than 500).
+/// Panics if `addresses` is absurdly large (more than 500).
+///
+/// [`get_and_clear_pending_msg_events`]: MessageSendEventsProvider::get_and_clear_pending_msg_events
#[no_mangle]
pub extern "C" fn ChannelManager_broadcast_node_announcement(this_arg: &ChannelManager, mut rgb: crate::c_types::ThreeBytes, mut alias: crate::c_types::ThirtyTwoBytes, mut addresses: crate::c_types::derived::CVec_NetAddressZ) {
let mut local_addresses = Vec::new(); for mut item in addresses.into_rust().drain(..) { local_addresses.push( { item.into_native() }); };
/// `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for
/// in excess of the current time. This should roughly match the expiry time set in the invoice.
/// After this many seconds, we will remove the inbound payment, resulting in any attempts to
-/// pay the invoice failing. The BOLT spec suggests 7,200 secs as a default validity time for
+/// pay the invoice failing. The BOLT spec suggests 3,600 secs as a default validity time for
/// invoices when no timeout is set.
///
/// Note that we use block header time to time-out pending inbound payments (with some margin
crate::lightning::util::events::EventsProvider {
this_arg: unsafe { (*this_arg).inner as *mut c_void },
free: None,
- get_and_clear_pending_events: ChannelManager_EventsProvider_get_and_clear_pending_events,
+ process_pending_events: ChannelManager_EventsProvider_process_pending_events,
}
}
-#[must_use]
-extern "C" fn ChannelManager_EventsProvider_get_and_clear_pending_events(this_arg: *const c_void) -> crate::c_types::derived::CVec_EventZ {
- let mut ret = <nativeChannelManager as lightning::util::events::EventsProvider<>>::get_and_clear_pending_events(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, );
- let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::util::events::Event::native_into(item) }); };
- local_ret.into()
+extern "C" fn ChannelManager_EventsProvider_process_pending_events(this_arg: *const c_void, mut handler: crate::lightning::util::events::EventHandler) {
+ <nativeChannelManager as lightning::util::events::EventsProvider<>>::process_pending_events(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, handler)
}
impl From<nativeChannelManager> for crate::lightning::chain::Listen {
use bitcoin::hashes::Hash;
use crate::c_types::*;
+}
+/// Checks if two InitFeaturess 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.
+#[no_mangle]
+pub extern "C" fn InitFeatures_eq(a: &InitFeatures, b: &InitFeatures) -> bool {
+ if a.inner == b.inner { return true; }
+ if a.inner.is_null() || b.inner.is_null() { return false; }
+ if unsafe { &*a.inner } == unsafe { &*b.inner } { true } else { false }
+}
+/// Checks if two NodeFeaturess 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.
+#[no_mangle]
+pub extern "C" fn NodeFeatures_eq(a: &NodeFeatures, b: &NodeFeatures) -> bool {
+ if a.inner == b.inner { return true; }
+ if a.inner.is_null() || b.inner.is_null() { return false; }
+ if unsafe { &*a.inner } == unsafe { &*b.inner } { true } else { false }
+}
+/// Checks if two ChannelFeaturess 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.
+#[no_mangle]
+pub extern "C" fn ChannelFeatures_eq(a: &ChannelFeatures, b: &ChannelFeatures) -> bool {
+ if a.inner == b.inner { return true; }
+ if a.inner.is_null() || b.inner.is_null() { return false; }
+ if unsafe { &*a.inner } == unsafe { &*b.inner } { true } else { false }
+}
+/// Checks if two InvoiceFeaturess 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.
+#[no_mangle]
+pub extern "C" fn InvoiceFeatures_eq(a: &InvoiceFeatures, b: &InvoiceFeatures) -> bool {
+ if a.inner == b.inner { return true; }
+ if a.inner.is_null() || b.inner.is_null() { return false; }
+ if unsafe { &*a.inner } == unsafe { &*b.inner } { true } else { false }
}
impl Clone for InitFeatures {
fn clone(&self) -> Self {
InvoiceFeatures { inner: Box::into_raw(Box::new(ret)), is_owned: true }
}
+/// Returns whether the `payment_secret` feature is supported.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn InitFeatures_supports_payment_secret(this_arg: &InitFeatures) -> bool {
+ let mut ret = unsafe { &*this_arg.inner }.supports_payment_secret();
+ ret
+}
+
+/// Returns whether the `payment_secret` feature is supported.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn NodeFeatures_supports_payment_secret(this_arg: &NodeFeatures) -> bool {
+ let mut ret = unsafe { &*this_arg.inner }.supports_payment_secret();
+ ret
+}
+
+/// Returns whether the `payment_secret` feature is supported.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn InvoiceFeatures_supports_payment_secret(this_arg: &InvoiceFeatures) -> bool {
+ let mut ret = unsafe { &*this_arg.inner }.supports_payment_secret();
+ ret
+}
+
#[no_mangle]
/// Serialize the InitFeatures object into a byte array which can be read by InitFeatures_read
pub extern "C" fn InitFeatures_write(obj: &InitFeatures) -> crate::c_types::derived::CVec_u8Z {
pub mod peer_handler;
pub mod chan_utils;
pub mod features;
-mod onchaintx {
-
-use std::str::FromStr;
-use std::ffi::c_void;
-use bitcoin::hashes::Hash;
-use crate::c_types::*;
-
-}
mod peer_channel_encryptor {
use std::str::FromStr;
let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_res_0 = match o { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::NetAddress::native_into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { e }).into() }; local_res_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
local_res
}
+#[no_mangle]
+/// Read a NetAddress from a byte array, created by NetAddress_write
+pub extern "C" fn NetAddress_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NetAddressDecodeErrorZ {
+ let res = crate::c_types::deserialize_obj(ser);
+ let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::NetAddress::native_into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
+ local_res
+}
use lightning::ln::msgs::UnsignedNodeAnnouncement as nativeUnsignedNodeAnnouncementImport;
type nativeUnsignedNodeAnnouncement = nativeUnsignedNodeAnnouncementImport;
pub mod chain;
pub mod ln;
pub mod routing;
+mod prelude {
+
+use std::str::FromStr;
+use std::ffi::c_void;
+use bitcoin::hashes::Hash;
+use crate::c_types::*;
+
+}
proportional_millionths: proportional_millionths_arg,
})), is_owned: true }
}
+/// Checks if two RoutingFeess 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.
+#[no_mangle]
+pub extern "C" fn RoutingFees_eq(a: &RoutingFees, b: &RoutingFees) -> bool {
+ if a.inner == b.inner { return true; }
+ if a.inner.is_null() || b.inner.is_null() { return false; }
+ if unsafe { &*a.inner } == unsafe { &*b.inner } { true } else { false }
+}
impl Clone for RoutingFees {
fn clone(&self) -> Self {
Self {
orig.clone()
}
#[no_mangle]
-/// Read a RoutingFees from a byte array, created by RoutingFees_write
-pub extern "C" fn RoutingFees_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_RoutingFeesDecodeErrorZ {
- let res = crate::c_types::deserialize_obj(ser);
- let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::network_graph::RoutingFees { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
- local_res
-}
-#[no_mangle]
/// Serialize the RoutingFees object into a byte array which can be read by RoutingFees_read
pub extern "C" fn RoutingFees_write(obj: &RoutingFees) -> crate::c_types::derived::CVec_u8Z {
crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
pub(crate) extern "C" fn RoutingFees_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRoutingFees) })
}
+#[no_mangle]
+/// Read a RoutingFees from a byte array, created by RoutingFees_write
+pub extern "C" fn RoutingFees_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_RoutingFeesDecodeErrorZ {
+ let res = crate::c_types::deserialize_obj(ser);
+ let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::network_graph::RoutingFees { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
+ local_res
+}
use lightning::routing::network_graph::NodeAnnouncementInfo as nativeNodeAnnouncementInfoImport;
type nativeNodeAnnouncementInfo = nativeNodeAnnouncementInfoImport;
htlc_maximum_msat: local_htlc_maximum_msat_arg,
})), is_owned: true }
}
+/// Checks if two RouteHintHops 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.
+#[no_mangle]
+pub extern "C" fn RouteHintHop_eq(a: &RouteHintHop, b: &RouteHintHop) -> bool {
+ if a.inner == b.inner { return true; }
+ if a.inner.is_null() || b.inner.is_null() { return false; }
+ if unsafe { &*a.inner } == unsafe { &*b.inner } { true } else { false }
+}
impl Clone for RouteHintHop {
fn clone(&self) -> Self {
Self {
pub extern "C" fn ChannelHandshakeLimits_set_min_max_accepted_htlcs(this_ptr: &mut ChannelHandshakeLimits, mut val: u16) {
unsafe { &mut *this_ptr.inner }.min_max_accepted_htlcs = val;
}
-/// Outputs below a certain value will not be added to on-chain transactions. The dust value is
-/// required to always be higher than this value so this only applies to HTLC outputs (and
-/// potentially to-self outputs before any payments have been made).
-/// Thus, HTLCs below this amount plus HTLC transaction fees are not enforceable on-chain.
-/// This setting allows you to set a minimum dust limit for their commitment transactions,
-/// reflecting the reality that tiny outputs are not considered standard transactions and will
-/// not propagate through the Bitcoin network.
-///
-/// Default value: 546, the current dust limit on the Bitcoin network.
-#[no_mangle]
-pub extern "C" fn ChannelHandshakeLimits_get_min_dust_limit_satoshis(this_ptr: &ChannelHandshakeLimits) -> u64 {
- let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.min_dust_limit_satoshis;
- *inner_val
-}
-/// Outputs below a certain value will not be added to on-chain transactions. The dust value is
-/// required to always be higher than this value so this only applies to HTLC outputs (and
-/// potentially to-self outputs before any payments have been made).
-/// Thus, HTLCs below this amount plus HTLC transaction fees are not enforceable on-chain.
-/// This setting allows you to set a minimum dust limit for their commitment transactions,
-/// reflecting the reality that tiny outputs are not considered standard transactions and will
-/// not propagate through the Bitcoin network.
-///
-/// Default value: 546, the current dust limit on the Bitcoin network.
-#[no_mangle]
-pub extern "C" fn ChannelHandshakeLimits_set_min_dust_limit_satoshis(this_ptr: &mut ChannelHandshakeLimits, mut val: u64) {
- unsafe { &mut *this_ptr.inner }.min_dust_limit_satoshis = val;
-}
-/// Maximum allowed threshold above which outputs will not be generated in their commitment
-/// transactions.
-/// HTLCs below this amount plus HTLC transaction fees are not enforceable on-chain.
-///
-/// Default value: u64::max_value.
-#[no_mangle]
-pub extern "C" fn ChannelHandshakeLimits_get_max_dust_limit_satoshis(this_ptr: &ChannelHandshakeLimits) -> u64 {
- let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.max_dust_limit_satoshis;
- *inner_val
-}
-/// Maximum allowed threshold above which outputs will not be generated in their commitment
-/// transactions.
-/// HTLCs below this amount plus HTLC transaction fees are not enforceable on-chain.
-///
-/// Default value: u64::max_value.
-#[no_mangle]
-pub extern "C" fn ChannelHandshakeLimits_set_max_dust_limit_satoshis(this_ptr: &mut ChannelHandshakeLimits, mut val: u64) {
- unsafe { &mut *this_ptr.inner }.max_dust_limit_satoshis = val;
-}
/// Before a channel is usable the funding transaction will need to be confirmed by at least a
/// certain number of blocks, specified by the node which is not the funder (as the funder can
/// assume they aren't going to double-spend themselves).
/// Constructs a new ChannelHandshakeLimits given each field
#[must_use]
#[no_mangle]
-pub extern "C" fn ChannelHandshakeLimits_new(mut min_funding_satoshis_arg: u64, mut max_htlc_minimum_msat_arg: u64, mut min_max_htlc_value_in_flight_msat_arg: u64, mut max_channel_reserve_satoshis_arg: u64, mut min_max_accepted_htlcs_arg: u16, mut min_dust_limit_satoshis_arg: u64, mut max_dust_limit_satoshis_arg: u64, mut max_minimum_depth_arg: u32, mut force_announced_channel_preference_arg: bool, mut their_to_self_delay_arg: u16) -> ChannelHandshakeLimits {
+pub extern "C" fn ChannelHandshakeLimits_new(mut min_funding_satoshis_arg: u64, mut max_htlc_minimum_msat_arg: u64, mut min_max_htlc_value_in_flight_msat_arg: u64, mut max_channel_reserve_satoshis_arg: u64, mut min_max_accepted_htlcs_arg: u16, mut max_minimum_depth_arg: u32, mut force_announced_channel_preference_arg: bool, mut their_to_self_delay_arg: u16) -> ChannelHandshakeLimits {
ChannelHandshakeLimits { inner: Box::into_raw(Box::new(nativeChannelHandshakeLimits {
min_funding_satoshis: min_funding_satoshis_arg,
max_htlc_minimum_msat: max_htlc_minimum_msat_arg,
min_max_htlc_value_in_flight_msat: min_max_htlc_value_in_flight_msat_arg,
max_channel_reserve_satoshis: max_channel_reserve_satoshis_arg,
min_max_accepted_htlcs: min_max_accepted_htlcs_arg,
- min_dust_limit_satoshis: min_dust_limit_satoshis_arg,
- max_dust_limit_satoshis: max_dust_limit_satoshis_arg,
max_minimum_depth: max_minimum_depth_arg,
force_announced_channel_preference: force_announced_channel_preference_arg,
their_to_self_delay: their_to_self_delay_arg,
},
/// Indicates an outbound payment we made succeeded (ie it made it all the way to its target
/// and we got back the payment preimage for it).
- /// Note that duplicative PaymentSent Events may be generated - it is your responsibility to
- /// deduplicate them by payment_preimage (which MUST be unique)!
PaymentSent {
/// 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
},
/// Indicates an outbound payment we made failed. Probably some intermediary node dropped
/// something. You may wish to retry with a different route.
- /// Note that duplicative PaymentFailed Events may be generated - it is your responsibility to
- /// deduplicate them by payment_hash (which MUST be unique)!
PaymentFailed {
/// The hash which was given to ChannelManager::send_payment.
payment_hash: crate::c_types::ThirtyTwoBytes,
}
}
}
-/// A trait indicating an object may generate events
+/// A trait indicating an object may generate events.
+///
+/// Events are processed by passing an [`EventHandler`] to [`process_pending_events`].
+///
+/// # Requirements
+///
+/// See [`process_pending_events`] for requirements around event processing.
+///
+/// When using this trait, [`process_pending_events`] will call [`handle_event`] for each pending
+/// event since the last invocation. The handler must either act upon the event immediately
+/// or preserve it for later handling.
+///
+/// Note, handlers may call back into the provider and thus deadlocking must be avoided. Be sure to
+/// consult the provider's documentation on the implication of processing events and how a handler
+/// may safely use the provider (e.g., see [`ChannelManager::process_pending_events`] and
+/// [`ChainMonitor::process_pending_events`]).
+///
+/// (C-not implementable) As there is likely no reason for a user to implement this trait on their
+/// own type(s).
+///
+/// [`process_pending_events`]: Self::process_pending_events
+/// [`handle_event`]: EventHandler::handle_event
+/// [`ChannelManager::process_pending_events`]: crate::ln::channelmanager::ChannelManager#method.process_pending_events
+/// [`ChainMonitor::process_pending_events`]: crate::chain::chainmonitor::ChainMonitor#method.process_pending_events
#[repr(C)]
pub struct EventsProvider {
/// 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.
pub this_arg: *mut c_void,
- /// Gets the list of pending events which were generated by previous actions, clearing the list
- /// in the process.
- #[must_use]
- pub get_and_clear_pending_events: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_EventZ,
+ /// Processes any events generated since the last call using the given event handler.
+ ///
+ /// Subsequent calls must only process new events. However, handlers must be capable of handling
+ /// duplicate events across process restarts. This may occur if the provider was recovered from
+ /// an old state (i.e., it hadn't been successfully persisted after processing pending events).
+ pub process_pending_events: extern "C" fn (this_arg: *const c_void, handler: crate::lightning::util::events::EventHandler),
/// 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.
pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
}
use lightning::util::events::EventsProvider as rustEventsProvider;
-impl rustEventsProvider for EventsProvider {
- fn get_and_clear_pending_events(&self) -> Vec<lightning::util::events::Event> {
- let mut ret = (self.get_and_clear_pending_events)(self.this_arg);
- let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); };
- local_ret
+/// Calls the free function if one is set
+#[no_mangle]
+pub extern "C" fn EventsProvider_free(this_ptr: EventsProvider) { }
+impl Drop for EventsProvider {
+ fn drop(&mut self) {
+ if let Some(f) = self.free {
+ f(self.this_arg);
+ }
+ }
+}
+/// A trait implemented for objects handling events from [`EventsProvider`].
+#[repr(C)]
+pub struct EventHandler {
+ /// 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.
+ pub this_arg: *mut c_void,
+ /// Handles the given [`Event`].
+ ///
+ /// See [`EventsProvider`] for details that must be considered when implementing this method.
+ pub handle_event: extern "C" fn (this_arg: *const c_void, event: crate::lightning::util::events::Event),
+ /// 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.
+ pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
+}
+
+use lightning::util::events::EventHandler as rustEventHandler;
+impl rustEventHandler for EventHandler {
+ fn handle_event(&self, mut event: lightning::util::events::Event) {
+ (self.handle_event)(self.this_arg, crate::lightning::util::events::Event::native_into(event))
}
}
// We're essentially a pointer already, or at least a set of pointers, so allow us to be used
// directly as a Deref trait in higher-level structs:
-impl std::ops::Deref for EventsProvider {
+impl std::ops::Deref for EventHandler {
type Target = Self;
fn deref(&self) -> &Self {
self
}
/// Calls the free function if one is set
#[no_mangle]
-pub extern "C" fn EventsProvider_free(this_ptr: EventsProvider) { }
-impl Drop for EventsProvider {
+pub extern "C" fn EventHandler_free(this_ptr: EventHandler) { }
+impl Drop for EventHandler {
fn drop(&mut self) {
if let Some(f) = self.free {
f(self.this_arg);
pub extern "C" fn Level_clone(orig: &Level) -> Level {
orig.clone()
}
+/// Checks if two Levels contain equal inner contents.
+/// This ignores pointers and is_owned flags and looks at the values in fields.
+#[no_mangle]
+pub extern "C" fn Level_eq(a: &Level, b: &Level) -> bool {
+ if &a.to_native() == &b.to_native() { true } else { false }
+}
+/// Checks if two Levels contain equal inner contents.
+#[no_mangle]
+pub extern "C" fn Level_hash(o: &Level) -> u64 {
+ // Note that we'd love to use std::collections::hash_map::DefaultHasher but its not in core
+ #[allow(deprecated)]
+ let mut hasher = core::hash::SipHasher::new();
+ std::hash::Hash::hash(&o.to_native(), &mut hasher);
+ std::hash::Hasher::finish(&hasher)
+}
/// Returns the most verbose logging level.
#[must_use]
#[no_mangle]
ret
}
}
+/// Checks if two Invoices 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.
+#[no_mangle]
+pub extern "C" fn Invoice_eq(a: &Invoice, b: &Invoice) -> bool {
+ if a.inner == b.inner { return true; }
+ if a.inner.is_null() || b.inner.is_null() { return false; }
+ if unsafe { &*a.inner } == unsafe { &*b.inner } { true } else { false }
+}
impl Clone for Invoice {
fn clone(&self) -> Self {
Self {
ret
}
}
+/// Checks if two SignedRawInvoices 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.
+#[no_mangle]
+pub extern "C" fn SignedRawInvoice_eq(a: &SignedRawInvoice, b: &SignedRawInvoice) -> bool {
+ if a.inner == b.inner { return true; }
+ if a.inner.is_null() || b.inner.is_null() { return false; }
+ if unsafe { &*a.inner } == unsafe { &*b.inner } { true } else { false }
+}
impl Clone for SignedRawInvoice {
fn clone(&self) -> Self {
Self {
pub extern "C" fn RawInvoice_set_data(this_ptr: &mut RawInvoice, mut val: crate::lightning_invoice::RawDataPart) {
unsafe { &mut *this_ptr.inner }.data = *unsafe { Box::from_raw(val.take_inner()) };
}
+/// Checks if two RawInvoices 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.
+#[no_mangle]
+pub extern "C" fn RawInvoice_eq(a: &RawInvoice, b: &RawInvoice) -> bool {
+ if a.inner == b.inner { return true; }
+ if a.inner.is_null() || b.inner.is_null() { return false; }
+ if unsafe { &*a.inner } == unsafe { &*b.inner } { true } else { false }
+}
impl Clone for RawInvoice {
fn clone(&self) -> Self {
Self {
pub extern "C" fn RawDataPart_set_timestamp(this_ptr: &mut RawDataPart, mut val: crate::lightning_invoice::PositiveTimestamp) {
unsafe { &mut *this_ptr.inner }.timestamp = *unsafe { Box::from_raw(val.take_inner()) };
}
+/// Checks if two RawDataParts 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.
+#[no_mangle]
+pub extern "C" fn RawDataPart_eq(a: &RawDataPart, b: &RawDataPart) -> bool {
+ if a.inner == b.inner { return true; }
+ if a.inner.is_null() || b.inner.is_null() { return false; }
+ if unsafe { &*a.inner } == unsafe { &*b.inner } { true } else { false }
+}
impl Clone for RawDataPart {
fn clone(&self) -> Self {
Self {
ret
}
}
+/// Checks if two PositiveTimestamps 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.
+#[no_mangle]
+pub extern "C" fn PositiveTimestamp_eq(a: &PositiveTimestamp, b: &PositiveTimestamp) -> bool {
+ if a.inner == b.inner { return true; }
+ if a.inner.is_null() || b.inner.is_null() { return false; }
+ if unsafe { &*a.inner } == unsafe { &*b.inner } { true } else { false }
+}
impl Clone for PositiveTimestamp {
fn clone(&self) -> Self {
Self {
pub extern "C" fn SiPrefix_clone(orig: &SiPrefix) -> SiPrefix {
orig.clone()
}
+/// Checks if two SiPrefixs contain equal inner contents.
+/// This ignores pointers and is_owned flags and looks at the values in fields.
+#[no_mangle]
+pub extern "C" fn SiPrefix_eq(a: &SiPrefix, b: &SiPrefix) -> bool {
+ if &a.to_native() == &b.to_native() { true } else { false }
+}
/// Returns the multiplier to go from a BTC value to picoBTC implied by this SiPrefix.
/// This is effectively 10^12 * the prefix multiplier
#[must_use]
pub extern "C" fn Currency_clone(orig: &Currency) -> Currency {
orig.clone()
}
+/// Checks if two Currencys contain equal inner contents.
+/// This ignores pointers and is_owned flags and looks at the values in fields.
+#[no_mangle]
+pub extern "C" fn Currency_eq(a: &Currency, b: &Currency) -> bool {
+ if &a.to_native() == &b.to_native() { true } else { false }
+}
use lightning_invoice::Sha256 as nativeSha256Import;
type nativeSha256 = nativeSha256Import;
ret
}
}
+/// Checks if two Sha256s 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.
+#[no_mangle]
+pub extern "C" fn Sha256_eq(a: &Sha256, b: &Sha256) -> bool {
+ if a.inner == b.inner { return true; }
+ if a.inner.is_null() || b.inner.is_null() { return false; }
+ if unsafe { &*a.inner } == unsafe { &*b.inner } { true } else { false }
+}
impl Clone for Sha256 {
fn clone(&self) -> Self {
Self {
ret
}
}
+/// Checks if two Descriptions 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.
+#[no_mangle]
+pub extern "C" fn Description_eq(a: &Description, b: &Description) -> bool {
+ if a.inner == b.inner { return true; }
+ if a.inner.is_null() || b.inner.is_null() { return false; }
+ if unsafe { &*a.inner } == unsafe { &*b.inner } { true } else { false }
+}
impl Clone for Description {
fn clone(&self) -> Self {
Self {
ret
}
}
+/// Checks if two PayeePubKeys 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.
+#[no_mangle]
+pub extern "C" fn PayeePubKey_eq(a: &PayeePubKey, b: &PayeePubKey) -> bool {
+ if a.inner == b.inner { return true; }
+ if a.inner.is_null() || b.inner.is_null() { return false; }
+ if unsafe { &*a.inner } == unsafe { &*b.inner } { true } else { false }
+}
impl Clone for PayeePubKey {
fn clone(&self) -> Self {
Self {
ret
}
}
+/// Checks if two ExpiryTimes 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.
+#[no_mangle]
+pub extern "C" fn ExpiryTime_eq(a: &ExpiryTime, b: &ExpiryTime) -> bool {
+ if a.inner == b.inner { return true; }
+ if a.inner.is_null() || b.inner.is_null() { return false; }
+ if unsafe { &*a.inner } == unsafe { &*b.inner } { true } else { false }
+}
impl Clone for ExpiryTime {
fn clone(&self) -> Self {
Self {
ret
}
}
+/// Checks if two MinFinalCltvExpirys 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.
+#[no_mangle]
+pub extern "C" fn MinFinalCltvExpiry_eq(a: &MinFinalCltvExpiry, b: &MinFinalCltvExpiry) -> bool {
+ if a.inner == b.inner { return true; }
+ if a.inner.is_null() || b.inner.is_null() { return false; }
+ if unsafe { &*a.inner } == unsafe { &*b.inner } { true } else { false }
+}
impl Clone for MinFinalCltvExpiry {
fn clone(&self) -> Self {
Self {
pub extern "C" fn Fallback_clone(orig: &Fallback) -> Fallback {
orig.clone()
}
+/// Checks if two Fallbacks contain equal inner contents.
+/// This ignores pointers and is_owned flags and looks at the values in fields.
+#[no_mangle]
+pub extern "C" fn Fallback_eq(a: &Fallback, b: &Fallback) -> bool {
+ if &a.to_native() == &b.to_native() { true } else { false }
+}
use lightning_invoice::InvoiceSignature as nativeInvoiceSignatureImport;
type nativeInvoiceSignature = nativeInvoiceSignatureImport;
ret
}
}
+/// Checks if two InvoiceSignatures 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.
+#[no_mangle]
+pub extern "C" fn InvoiceSignature_eq(a: &InvoiceSignature, b: &InvoiceSignature) -> bool {
+ if a.inner == b.inner { return true; }
+ if a.inner.is_null() || b.inner.is_null() { return false; }
+ if unsafe { &*a.inner } == unsafe { &*b.inner } { true } else { false }
+}
impl Clone for InvoiceSignature {
fn clone(&self) -> Self {
Self {
ret
}
}
+/// Checks if two RouteHints 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.
+#[no_mangle]
+pub extern "C" fn RouteHint_eq(a: &RouteHint, b: &RouteHint) -> bool {
+ if a.inner == b.inner { return true; }
+ if a.inner.is_null() || b.inner.is_null() { return false; }
+ if unsafe { &*a.inner } == unsafe { &*b.inner } { true } else { false }
+}
impl Clone for RouteHint {
fn clone(&self) -> Self {
Self {
pub extern "C" fn CreationError_clone(orig: &CreationError) -> CreationError {
orig.clone()
}
+/// Checks if two CreationErrors contain equal inner contents.
+/// This ignores pointers and is_owned flags and looks at the values in fields.
+#[no_mangle]
+pub extern "C" fn CreationError_eq(a: &CreationError, b: &CreationError) -> bool {
+ if &a.to_native() == &b.to_native() { true } else { false }
+}
#[no_mangle]
/// Get the string representation of a CreationError object
pub extern "C" fn CreationError_to_str(o: &crate::lightning_invoice::CreationError) -> Str {
NoDescription,
/// The invoice contains multiple descriptions and/or description hashes which isn't allowed
MultipleDescriptions,
+ /// The invoice contains multiple payment secrets
+ MultiplePaymentSecrets,
+ /// The invoice's features are invalid
+ InvalidFeatures,
/// The recovery id doesn't fit the signature/pub key
InvalidRecoveryId,
/// The invoice's signature is invalid
SemanticError::MultiplePaymentHashes => nativeSemanticError::MultiplePaymentHashes,
SemanticError::NoDescription => nativeSemanticError::NoDescription,
SemanticError::MultipleDescriptions => nativeSemanticError::MultipleDescriptions,
+ SemanticError::MultiplePaymentSecrets => nativeSemanticError::MultiplePaymentSecrets,
+ SemanticError::InvalidFeatures => nativeSemanticError::InvalidFeatures,
SemanticError::InvalidRecoveryId => nativeSemanticError::InvalidRecoveryId,
SemanticError::InvalidSignature => nativeSemanticError::InvalidSignature,
}
SemanticError::MultiplePaymentHashes => nativeSemanticError::MultiplePaymentHashes,
SemanticError::NoDescription => nativeSemanticError::NoDescription,
SemanticError::MultipleDescriptions => nativeSemanticError::MultipleDescriptions,
+ SemanticError::MultiplePaymentSecrets => nativeSemanticError::MultiplePaymentSecrets,
+ SemanticError::InvalidFeatures => nativeSemanticError::InvalidFeatures,
SemanticError::InvalidRecoveryId => nativeSemanticError::InvalidRecoveryId,
SemanticError::InvalidSignature => nativeSemanticError::InvalidSignature,
}
nativeSemanticError::MultiplePaymentHashes => SemanticError::MultiplePaymentHashes,
nativeSemanticError::NoDescription => SemanticError::NoDescription,
nativeSemanticError::MultipleDescriptions => SemanticError::MultipleDescriptions,
+ nativeSemanticError::MultiplePaymentSecrets => SemanticError::MultiplePaymentSecrets,
+ nativeSemanticError::InvalidFeatures => SemanticError::InvalidFeatures,
nativeSemanticError::InvalidRecoveryId => SemanticError::InvalidRecoveryId,
nativeSemanticError::InvalidSignature => SemanticError::InvalidSignature,
}
nativeSemanticError::MultiplePaymentHashes => SemanticError::MultiplePaymentHashes,
nativeSemanticError::NoDescription => SemanticError::NoDescription,
nativeSemanticError::MultipleDescriptions => SemanticError::MultipleDescriptions,
+ nativeSemanticError::MultiplePaymentSecrets => SemanticError::MultiplePaymentSecrets,
+ nativeSemanticError::InvalidFeatures => SemanticError::InvalidFeatures,
nativeSemanticError::InvalidRecoveryId => SemanticError::InvalidRecoveryId,
nativeSemanticError::InvalidSignature => SemanticError::InvalidSignature,
}
pub extern "C" fn SemanticError_clone(orig: &SemanticError) -> SemanticError {
orig.clone()
}
+/// Checks if two SemanticErrors contain equal inner contents.
+/// This ignores pointers and is_owned flags and looks at the values in fields.
+#[no_mangle]
+pub extern "C" fn SemanticError_eq(a: &SemanticError, b: &SemanticError) -> bool {
+ if &a.to_native() == &b.to_native() { true } else { false }
+}
#[no_mangle]
/// Get the string representation of a SemanticError object
pub extern "C" fn SemanticError_to_str(o: &crate::lightning_invoice::SemanticError) -> Str {
pub extern "C" fn SignOrCreationError_clone(orig: &SignOrCreationError) -> SignOrCreationError {
orig.clone()
}
+/// Checks if two SignOrCreationErrors contain equal inner contents.
+/// This ignores pointers and is_owned flags and looks at the values in fields.
+#[no_mangle]
+pub extern "C" fn SignOrCreationError_eq(a: &SignOrCreationError, b: &SignOrCreationError) -> bool {
+ if &a.to_native() == &b.to_native() { true } else { false }
+}
#[no_mangle]
/// Get the string representation of a SignOrCreationError object
pub extern "C" fn SignOrCreationError_to_str(o: &crate::lightning_invoice::SignOrCreationError) -> Str {