From b2f0ccc7e0ef8b31567cb017d0b7cce9f7204803 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Thu, 18 Mar 2021 11:23:31 -0400 Subject: [PATCH] Regenerate auto-generated bindings with license info and new upstream --- lightning-c-bindings/include/lightning.h | 174 +++++++++--------- .../src/chain/chaininterface.rs | 8 + .../src/chain/chainmonitor.rs | 37 ++-- .../src/chain/channelmonitor.rs | 30 +-- .../src/chain/keysinterface.rs | 8 + lightning-c-bindings/src/chain/mod.rs | 31 ++-- lightning-c-bindings/src/chain/transaction.rs | 8 + lightning-c-bindings/src/lib.rs | 8 + lightning-c-bindings/src/ln/chan_utils.rs | 8 + lightning-c-bindings/src/ln/channelmanager.rs | 21 +++ lightning-c-bindings/src/ln/features.rs | 31 ++-- lightning-c-bindings/src/ln/mod.rs | 8 + lightning-c-bindings/src/ln/msgs.rs | 39 +++- lightning-c-bindings/src/ln/peer_handler.rs | 12 ++ lightning-c-bindings/src/routing/mod.rs | 8 + .../src/routing/network_graph.rs | 12 +- lightning-c-bindings/src/routing/router.rs | 8 + lightning-c-bindings/src/util/config.rs | 12 +- lightning-c-bindings/src/util/errors.rs | 8 + lightning-c-bindings/src/util/events.rs | 44 +++++ lightning-c-bindings/src/util/logger.rs | 8 + lightning-c-bindings/src/util/mod.rs | 8 + lightning-c-bindings/src/util/ser.rs | 8 + 23 files changed, 377 insertions(+), 162 deletions(-) diff --git a/lightning-c-bindings/include/lightning.h b/lightning-c-bindings/include/lightning.h index 5869546..c85ac58 100644 --- a/lightning-c-bindings/include/lightning.h +++ b/lightning-c-bindings/include/lightning.h @@ -11,8 +11,6 @@ /** * An error when accessing the chain via [`Access`]. - * - * [`Access`]: trait.Access.html */ typedef enum LDKAccessError { /** @@ -1060,6 +1058,32 @@ typedef struct MUST_USE_STRUCT LDKQueryShortChannelIds { bool is_owned; } LDKQueryShortChannelIds; + + +/** + * A reply_channel_range message is a reply to a query_channel_range + * message. Multiple reply_channel_range messages can be sent in reply + * to a single query_channel_range message. The query recipient makes a + * best effort to respond based on their local network view which may + * not be a perfect view of the network. The short_channel_ids in the + * reply are encoded. We only support encoding_type=0 uncompressed + * serialization and do not support encoding_type=1 zlib serialization. + */ +typedef struct MUST_USE_STRUCT LDKReplyChannelRange { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeReplyChannelRange *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKReplyChannelRange; + /** * An event generated by ChannelManager which indicates a message should be sent to a peer (or * broadcast to most peers). @@ -1150,6 +1174,11 @@ typedef enum LDKMessageSendEvent_Tag { * their short_channel_ids. */ LDKMessageSendEvent_SendShortIdsQuery, + /** + * Sends a reply to a channel range query. This may be one of several SendReplyChannelRange events + * emitted during processing of the query. + */ + LDKMessageSendEvent_SendReplyChannelRange, /** * Must be last for serialization purposes */ @@ -1342,6 +1371,17 @@ typedef struct LDKMessageSendEvent_LDKSendShortIdsQuery_Body { struct LDKQueryShortChannelIds msg; } LDKMessageSendEvent_LDKSendShortIdsQuery_Body; +typedef struct LDKMessageSendEvent_LDKSendReplyChannelRange_Body { + /** + * The node_id of this message recipient + */ + struct LDKPublicKey node_id; + /** + * The reply_channel_range which should be sent. + */ + struct LDKReplyChannelRange msg; +} LDKMessageSendEvent_LDKSendReplyChannelRange_Body; + typedef struct MUST_USE_STRUCT LDKMessageSendEvent { LDKMessageSendEvent_Tag tag; union { @@ -1363,6 +1403,7 @@ typedef struct MUST_USE_STRUCT LDKMessageSendEvent { LDKMessageSendEvent_LDKPaymentFailureNetworkUpdate_Body payment_failure_network_update; LDKMessageSendEvent_LDKSendChannelRangeQuery_Body send_channel_range_query; LDKMessageSendEvent_LDKSendShortIdsQuery_Body send_short_ids_query; + LDKMessageSendEvent_LDKSendReplyChannelRange_Body send_reply_channel_range; }; } LDKMessageSendEvent; @@ -1972,8 +2013,6 @@ typedef struct LDKCResult_NoneChannelMonitorUpdateErrZ { * Simple structure sent back by `chain::Watch` when an HTLC from a forward channel is detected on * chain. Used to update the corresponding HTLC in the backward channel. Failing to pass the * preimage claim backward will lead to loss of funds. - * - * [`chain::Watch`]: ../trait.Watch.html */ typedef struct MUST_USE_STRUCT LDKHTLCUpdate { /** @@ -3018,9 +3057,9 @@ typedef struct LDKCVec_ChannelMonitorZ { * funds in the channel. See [`ChannelMonitorUpdateErr`] for more details about how to handle * multiple instances. * - * [`ChannelMonitor`]: channelmonitor/struct.ChannelMonitor.html - * [`ChannelMonitorUpdateErr`]: channelmonitor/enum.ChannelMonitorUpdateErr.html - * [`PermanentFailure`]: channelmonitor/enum.ChannelMonitorUpdateErr.html#variant.PermanentFailure + * [`ChannelMonitor`]: channelmonitor::ChannelMonitor + * [`ChannelMonitorUpdateErr`]: channelmonitor::ChannelMonitorUpdateErr + * [`PermanentFailure`]: channelmonitor::ChannelMonitorUpdateErr::PermanentFailure */ typedef struct LDKWatch { /** @@ -3035,9 +3074,9 @@ typedef struct LDKWatch { * with any spends of outputs returned by [`get_outputs_to_watch`]. In practice, this means * calling [`block_connected`] and [`block_disconnected`] on the monitor. * - * [`get_outputs_to_watch`]: channelmonitor/struct.ChannelMonitor.html#method.get_outputs_to_watch - * [`block_connected`]: channelmonitor/struct.ChannelMonitor.html#method.block_connected - * [`block_disconnected`]: channelmonitor/struct.ChannelMonitor.html#method.block_disconnected + * [`get_outputs_to_watch`]: channelmonitor::ChannelMonitor::get_outputs_to_watch + * [`block_connected`]: channelmonitor::ChannelMonitor::block_connected + * [`block_disconnected`]: channelmonitor::ChannelMonitor::block_disconnected */ struct LDKCResult_NoneChannelMonitorUpdateErrZ (*watch_channel)(const void *this_arg, struct LDKOutPoint funding_txo, struct LDKChannelMonitor monitor); /** @@ -3046,8 +3085,8 @@ typedef struct LDKWatch { * Implementations must call [`update_monitor`] with the given update. See * [`ChannelMonitorUpdateErr`] for invariants around returning an error. * - * [`update_monitor`]: channelmonitor/struct.ChannelMonitor.html#method.update_monitor - * [`ChannelMonitorUpdateErr`]: channelmonitor/enum.ChannelMonitorUpdateErr.html + * [`update_monitor`]: channelmonitor::ChannelMonitor::update_monitor + * [`ChannelMonitorUpdateErr`]: channelmonitor::ChannelMonitorUpdateErr */ struct LDKCResult_NoneChannelMonitorUpdateErrZ (*update_channel)(const void *this_arg, struct LDKOutPoint funding_txo, struct LDKChannelMonitorUpdate update); /** @@ -4027,32 +4066,6 @@ typedef struct LDKCResult_QueryChannelRangeDecodeErrorZ { bool result_ok; } LDKCResult_QueryChannelRangeDecodeErrorZ; - - -/** - * A reply_channel_range message is a reply to a query_channel_range - * message. Multiple reply_channel_range messages can be sent in reply - * to a single query_channel_range message. The query recipient makes a - * best effort to respond based on their local network view which may - * not be a perfect view of the network. The short_channel_ids in the - * reply are encoded. We only support encoding_type=0 uncompressed - * serialization and do not support encoding_type=1 zlib serialization. - */ -typedef struct MUST_USE_STRUCT LDKReplyChannelRange { - /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. - */ - LDKnativeReplyChannelRange *inner; - /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. - */ - bool is_owned; -} LDKReplyChannelRange; - typedef union LDKCResult_ReplyChannelRangeDecodeErrorZPtr { struct LDKReplyChannelRange *result; struct LDKDecodeError *err; @@ -4279,11 +4292,10 @@ typedef struct LDKListen { * * Note that use as part of a [`Watch`] implementation involves reentrancy. Therefore, the `Filter` * should not block on I/O. Implementations should instead queue the newly monitored data to be - * processed later. Then, in order to block until the data has been processed, any `Watch` + * processed later. Then, in order to block until the data has been processed, any [`Watch`] * invocation that has called the `Filter` must return [`TemporaryFailure`]. * - * [`Watch`]: trait.Watch.html - * [`TemporaryFailure`]: channelmonitor/enum.ChannelMonitorUpdateErr.html#variant.TemporaryFailure + * [`TemporaryFailure`]: channelmonitor::ChannelMonitorUpdateErr::TemporaryFailure * [BIP 157]: https://github.com/bitcoin/bips/blob/master/bip-0157.mediawiki * [BIP 158]: https://github.com/bitcoin/bips/blob/master/bip-0158.mediawiki */ @@ -4336,11 +4348,8 @@ typedef struct LDKPersist { * stored channel data). Note that you **must** persist every new monitor to * disk. See the `Persist` trait documentation for more details. * - * See [`ChannelMonitor::serialize_for_disk`] for writing out a `ChannelMonitor`, + * See [`ChannelMonitor::write`] for writing out a `ChannelMonitor`, * and [`ChannelMonitorUpdateErr`] for requirements when returning errors. - * - * [`ChannelMonitor::serialize_for_disk`]: struct.ChannelMonitor.html#method.serialize_for_disk - * [`ChannelMonitorUpdateErr`]: enum.ChannelMonitorUpdateErr.html */ struct LDKCResult_NoneChannelMonitorUpdateErrZ (*persist_new_channel)(const void *this_arg, struct LDKOutPoint id, const struct LDKChannelMonitor *NONNULL_PTR data); /** @@ -4363,14 +4372,9 @@ typedef struct LDKPersist { * them in batches. The size of each monitor grows `O(number of state updates)` * whereas updates are small and `O(1)`. * - * See [`ChannelMonitor::serialize_for_disk`] for writing out a `ChannelMonitor`, + * See [`ChannelMonitor::write`] for writing out a `ChannelMonitor`, * [`ChannelMonitorUpdate::write`] for writing out an update, and * [`ChannelMonitorUpdateErr`] for requirements when returning errors. - * - * [`ChannelMonitor::update_monitor`]: struct.ChannelMonitor.html#impl-1 - * [`ChannelMonitor::serialize_for_disk`]: struct.ChannelMonitor.html#method.serialize_for_disk - * [`ChannelMonitorUpdate::write`]: struct.ChannelMonitorUpdate.html#method.write - * [`ChannelMonitorUpdateErr`]: enum.ChannelMonitorUpdateErr.html */ struct LDKCResult_NoneChannelMonitorUpdateErrZ (*update_persisted_channel)(const void *this_arg, struct LDKOutPoint id, const struct LDKChannelMonitorUpdate *NONNULL_PTR update, const struct LDKChannelMonitor *NONNULL_PTR data); /** @@ -4390,9 +4394,8 @@ typedef struct LDKPersist { * or used independently to monitor channels remotely. See the [module-level documentation] for * details. * - * [`chain::Watch`]: ../trait.Watch.html - * [`ChannelManager`]: ../../ln/channelmanager/struct.ChannelManager.html - * [module-level documentation]: index.html + * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager + * [module-level documentation]: crate::chain::chainmonitor */ typedef struct MUST_USE_STRUCT LDKChainMonitor { /** @@ -4550,6 +4553,10 @@ typedef struct LDKChannelMessageHandler { * Handle an incoming channel_reestablish message from the given peer. */ void (*handle_channel_reestablish)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKChannelReestablish *NONNULL_PTR msg); + /** + * Handle an incoming channel update from the given peer. + */ + void (*handle_channel_update)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKChannelUpdate *NONNULL_PTR msg); /** * Handle an incoming error message from the given peer. */ @@ -4950,6 +4957,8 @@ extern const uint64_t MIN_RELAY_FEE_SAT_PER_1000_WEIGHT; extern const uint64_t CLOSED_CHANNEL_UPDATE_ID; +extern const uint16_t BREAKDOWN_TIMEOUT; + extern const uintptr_t REVOKEABLE_REDEEMSCRIPT_MAX_LENGTH; void Transaction_free(struct LDKTransaction _res); @@ -5788,7 +5797,7 @@ void ChannelHandshakeConfig_set_minimum_depth(struct LDKChannelHandshakeConfig * * case of an honest unilateral channel close, which implicitly decrease the economic value of * our channel. * - * Default value: BREAKDOWN_TIMEOUT (currently 144), we enforce it as a minimum at channel + * Default value: [`BREAKDOWN_TIMEOUT`] (currently 144), we enforce it as a minimum at channel * opening so you can tweak config to ask for more security, not less. */ uint16_t ChannelHandshakeConfig_get_our_to_self_delay(const struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr); @@ -5804,7 +5813,7 @@ uint16_t ChannelHandshakeConfig_get_our_to_self_delay(const struct LDKChannelHan * case of an honest unilateral channel close, which implicitly decrease the economic value of * our channel. * - * Default value: BREAKDOWN_TIMEOUT (currently 144), we enforce it as a minimum at channel + * Default value: [`BREAKDOWN_TIMEOUT`] (currently 144), we enforce it as a minimum at channel * opening so you can tweak config to ask for more security, not less. */ void ChannelHandshakeConfig_set_our_to_self_delay(struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr, uint16_t val); @@ -6265,10 +6274,6 @@ void ChainMonitor_free(struct LDKChainMonitor this_obj); * calls must not exclude any transactions matching the new outputs nor any in-block * descendants of such transactions. It is not necessary to re-fetch the block to obtain * updated `txdata`. - * - * [`ChannelMonitor::block_connected`]: ../channelmonitor/struct.ChannelMonitor.html#method.block_connected - * [`chain::Watch::release_pending_monitor_events`]: ../trait.Watch.html#tymethod.release_pending_monitor_events - * [`chain::Filter`]: ../trait.Filter.html */ void ChainMonitor_block_connected(const struct LDKChainMonitor *NONNULL_PTR this_arg, const uint8_t (*header)[80], struct LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height); @@ -6276,8 +6281,6 @@ void ChainMonitor_block_connected(const struct LDKChainMonitor *NONNULL_PTR this * Dispatches to per-channel monitors, which are responsible for updating their on-chain view * of a channel based on the disconnected block. See [`ChannelMonitor::block_disconnected`] for * details. - * - * [`ChannelMonitor::block_disconnected`]: ../channelmonitor/struct.ChannelMonitor.html#method.block_disconnected */ void ChainMonitor_block_disconnected(const struct LDKChainMonitor *NONNULL_PTR this_arg, const uint8_t (*header)[80], uint32_t disconnected_height); @@ -6289,8 +6292,6 @@ void ChainMonitor_block_disconnected(const struct LDKChainMonitor *NONNULL_PTR t * pre-filter blocks or only fetch blocks matching a compact filter. Otherwise, clients may * always need to fetch full blocks absent another means for determining which blocks contain * transactions relevant to the watched channels. - * - * [`chain::Filter`]: ../trait.Filter.html */ MUST_USE_RES struct LDKChainMonitor ChainMonitor_new(struct LDKFilter *chain_source, struct LDKBroadcasterInterface broadcaster, struct LDKLogger logger, struct LDKFeeEstimator feeest, struct LDKPersist persister); @@ -6323,8 +6324,6 @@ void ChannelMonitorUpdate_free(struct LDKChannelMonitorUpdate this_obj); * The only instance where update_id values are not strictly increasing is the case where we * allow post-force-close updates with a special update ID of [`CLOSED_CHANNEL_UPDATE_ID`]. See * its docs for more details. - * - * [`CLOSED_CHANNEL_UPDATE_ID`]: constant.CLOSED_CHANNEL_UPDATE_ID.html */ uint64_t ChannelMonitorUpdate_get_update_id(const struct LDKChannelMonitorUpdate *NONNULL_PTR this_ptr); @@ -6340,8 +6339,6 @@ uint64_t ChannelMonitorUpdate_get_update_id(const struct LDKChannelMonitorUpdate * The only instance where update_id values are not strictly increasing is the case where we * allow post-force-close updates with a special update ID of [`CLOSED_CHANNEL_UPDATE_ID`]. See * its docs for more details. - * - * [`CLOSED_CHANNEL_UPDATE_ID`]: constant.CLOSED_CHANNEL_UPDATE_ID.html */ void ChannelMonitorUpdate_set_update_id(struct LDKChannelMonitorUpdate *NONNULL_PTR this_ptr, uint64_t val); @@ -6450,8 +6447,6 @@ void ChannelMonitor_load_outputs_to_watch(const struct LDKChannelMonitor *NONNUL /** * Get the list of HTLCs who's status has been updated on chain. This should be called by * ChannelManager via [`chain::Watch::release_pending_monitor_events`]. - * - * [`chain::Watch::release_pending_monitor_events`]: ../trait.Watch.html#tymethod.release_pending_monitor_events */ MUST_USE_RES struct LDKCVec_MonitorEventZ ChannelMonitor_get_and_clear_pending_monitor_events(const struct LDKChannelMonitor *NONNULL_PTR this_arg); @@ -8917,12 +8912,26 @@ uint8_t UnsignedChannelUpdate_get_flags(const struct LDKUnsignedChannelUpdate *N void UnsignedChannelUpdate_set_flags(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint8_t val); /** - * The number of blocks to subtract from incoming HTLC cltv_expiry values + * The number of blocks such that if: + * `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta` + * then we need to fail the HTLC backwards. When forwarding an HTLC, cltv_expiry_delta determines + * the outgoing HTLC's minimum cltv_expiry value -- so, if an incoming HTLC comes in with a + * cltv_expiry of 100000, and the node we're forwarding to has a cltv_expiry_delta value of 10, + * then we'll check that the outgoing HTLC's cltv_expiry value is at least 100010 before + * forwarding. Note that the HTLC sender is the one who originally sets this value when + * constructing the route. */ uint16_t UnsignedChannelUpdate_get_cltv_expiry_delta(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); /** - * The number of blocks to subtract from incoming HTLC cltv_expiry values + * The number of blocks such that if: + * `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta` + * then we need to fail the HTLC backwards. When forwarding an HTLC, cltv_expiry_delta determines + * the outgoing HTLC's minimum cltv_expiry value -- so, if an incoming HTLC comes in with a + * cltv_expiry of 100000, and the node we're forwarding to has a cltv_expiry_delta value of 10, + * then we'll check that the outgoing HTLC's cltv_expiry value is at least 100010 before + * forwarding. Note that the HTLC sender is the one who originally sets this value when + * constructing the route. */ void UnsignedChannelUpdate_set_cltv_expiry_delta(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint16_t val); @@ -9613,6 +9622,11 @@ struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ ReplyShortChannelIdsEnd_re */ struct LDKCVec_u8Z ReplyShortChannelIdsEnd_write(const struct LDKReplyShortChannelIdsEnd *NONNULL_PTR obj); +/** + *\n\t * Calculates the overflow safe ending block height for the query.\n\t * Overflow returns `0xffffffff`, otherwise returns `first_blocknum + number_of_blocks`\n\t + */ +MUST_USE_RES uint32_t QueryChannelRange_end_blocknum(const struct LDKQueryChannelRange *NONNULL_PTR this_arg); + /** * Read a QueryChannelRange from a byte array, created by QueryChannelRange_write */ @@ -10622,9 +10636,7 @@ void InvoiceFeatures_free(struct LDKInvoiceFeatures this_obj); MUST_USE_RES struct LDKInitFeatures InitFeatures_empty(void); /** - * Creates features known by the implementation as defined by [`T::KNOWN_FEATURE_FLAGS`]. - * - * [`T::KNOWN_FEATURE_FLAGS`]: sealed/trait.Context.html#associatedconstant.KNOWN_FEATURE_FLAGS + * Creates a Features with the bits set which are known by the implementation */ MUST_USE_RES struct LDKInitFeatures InitFeatures_known(void); @@ -10634,9 +10646,7 @@ MUST_USE_RES struct LDKInitFeatures InitFeatures_known(void); MUST_USE_RES struct LDKNodeFeatures NodeFeatures_empty(void); /** - * Creates features known by the implementation as defined by [`T::KNOWN_FEATURE_FLAGS`]. - * - * [`T::KNOWN_FEATURE_FLAGS`]: sealed/trait.Context.html#associatedconstant.KNOWN_FEATURE_FLAGS + * Creates a Features with the bits set which are known by the implementation */ MUST_USE_RES struct LDKNodeFeatures NodeFeatures_known(void); @@ -10646,9 +10656,7 @@ MUST_USE_RES struct LDKNodeFeatures NodeFeatures_known(void); MUST_USE_RES struct LDKChannelFeatures ChannelFeatures_empty(void); /** - * Creates features known by the implementation as defined by [`T::KNOWN_FEATURE_FLAGS`]. - * - * [`T::KNOWN_FEATURE_FLAGS`]: sealed/trait.Context.html#associatedconstant.KNOWN_FEATURE_FLAGS + * Creates a Features with the bits set which are known by the implementation */ MUST_USE_RES struct LDKChannelFeatures ChannelFeatures_known(void); @@ -10658,9 +10666,7 @@ MUST_USE_RES struct LDKChannelFeatures ChannelFeatures_known(void); MUST_USE_RES struct LDKInvoiceFeatures InvoiceFeatures_empty(void); /** - * Creates features known by the implementation as defined by [`T::KNOWN_FEATURE_FLAGS`]. - * - * [`T::KNOWN_FEATURE_FLAGS`]: sealed/trait.Context.html#associatedconstant.KNOWN_FEATURE_FLAGS + * Creates a Features with the bits set which are known by the implementation */ MUST_USE_RES struct LDKInvoiceFeatures InvoiceFeatures_known(void); diff --git a/lightning-c-bindings/src/chain/chaininterface.rs b/lightning-c-bindings/src/chain/chaininterface.rs index 032bd55..f14123d 100644 --- a/lightning-c-bindings/src/chain/chaininterface.rs +++ b/lightning-c-bindings/src/chain/chaininterface.rs @@ -1,3 +1,11 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + //! Traits and utility impls which allow other parts of rust-lightning to interact with the //! blockchain. //! diff --git a/lightning-c-bindings/src/chain/chainmonitor.rs b/lightning-c-bindings/src/chain/chainmonitor.rs index 3039ec6..55c18d3 100644 --- a/lightning-c-bindings/src/chain/chainmonitor.rs +++ b/lightning-c-bindings/src/chain/chainmonitor.rs @@ -1,24 +1,26 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + //! Logic to connect off-chain channel management with on-chain transaction monitoring. //! //! [`ChainMonitor`] is an implementation of [`chain::Watch`] used both to process blocks and to //! update [`ChannelMonitor`]s accordingly. If any on-chain events need further processing, it will //! make those available as [`MonitorEvent`]s to be consumed. //! -//! `ChainMonitor` is parameterized by an optional chain source, which must implement the +//! [`ChainMonitor`] is parameterized by an optional chain source, which must implement the //! [`chain::Filter`] trait. This provides a mechanism to signal new relevant outputs back to light //! clients, such that transactions spending those outputs are included in block data. //! -//! `ChainMonitor` may be used directly to monitor channels locally or as a part of a distributed -//! setup to monitor channels remotely. In the latter case, a custom `chain::Watch` implementation +//! [`ChainMonitor`] may be used directly to monitor channels locally or as a part of a distributed +//! setup to monitor channels remotely. In the latter case, a custom [`chain::Watch`] implementation //! would be responsible for routing each update to a remote server and for retrieving monitor -//! events. The remote server would make use of `ChainMonitor` for block processing and for -//! servicing `ChannelMonitor` updates from the client. -//! -//! [`ChainMonitor`]: struct.ChainMonitor.html -//! [`chain::Filter`]: ../trait.Filter.html -//! [`chain::Watch`]: ../trait.Watch.html -//! [`ChannelMonitor`]: ../channelmonitor/struct.ChannelMonitor.html -//! [`MonitorEvent`]: ../channelmonitor/enum.MonitorEvent.html +//! events. The remote server would make use of [`ChainMonitor`] for block processing and for +//! servicing [`ChannelMonitor`] updates from the client. use std::ffi::c_void; use bitcoin::hashes::Hash; @@ -35,9 +37,8 @@ type nativeChainMonitor = nativeChainMonitorImport ChainMonitor { diff --git a/lightning-c-bindings/src/chain/channelmonitor.rs b/lightning-c-bindings/src/chain/channelmonitor.rs index 67880d4..5e10158 100644 --- a/lightning-c-bindings/src/chain/channelmonitor.rs +++ b/lightning-c-bindings/src/chain/channelmonitor.rs @@ -1,3 +1,11 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + //! The logic to monitor for on-chain transactions and create the relevant claim responses lives //! here. //! @@ -10,8 +18,6 @@ //! ChannelMonitors should do so). Thus, if you're building rust-lightning into an HSM or other //! security-domain-separated system design, you should consider having multiple paths for //! ChannelMonitors to get out of the HSM and onto monitoring devices. -//! -//! [`chain::Watch`]: ../trait.Watch.html use std::ffi::c_void; use bitcoin::hashes::Hash; @@ -74,8 +80,6 @@ impl ChannelMonitorUpdate { /// The only instance where update_id values are not strictly increasing is the case where we /// allow post-force-close updates with a special update ID of [`CLOSED_CHANNEL_UPDATE_ID`]. See /// its docs for more details. -/// -/// [`CLOSED_CHANNEL_UPDATE_ID`]: constant.CLOSED_CHANNEL_UPDATE_ID.html #[no_mangle] pub extern "C" fn ChannelMonitorUpdate_get_update_id(this_ptr: &ChannelMonitorUpdate) -> u64 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.update_id; @@ -92,8 +96,6 @@ pub extern "C" fn ChannelMonitorUpdate_get_update_id(this_ptr: &ChannelMonitorUp /// The only instance where update_id values are not strictly increasing is the case where we /// allow post-force-close updates with a special update ID of [`CLOSED_CHANNEL_UPDATE_ID`]. See /// its docs for more details. -/// -/// [`CLOSED_CHANNEL_UPDATE_ID`]: constant.CLOSED_CHANNEL_UPDATE_ID.html #[no_mangle] pub extern "C" fn ChannelMonitorUpdate_set_update_id(this_ptr: &mut ChannelMonitorUpdate, mut val: u64) { unsafe { &mut *this_ptr.inner }.update_id = val; @@ -401,8 +403,6 @@ type nativeHTLCUpdate = nativeHTLCUpdateImport; /// Simple structure sent back by `chain::Watch` when an HTLC from a forward channel is detected on /// chain. Used to update the corresponding HTLC in the backward channel. Failing to pass the /// preimage claim backward will lead to loss of funds. -/// -/// [`chain::Watch`]: ../trait.Watch.html #[must_use] #[repr(C)] pub struct HTLCUpdate { @@ -597,8 +597,6 @@ pub extern "C" fn ChannelMonitor_load_outputs_to_watch(this_arg: &ChannelMonitor /// Get the list of HTLCs who's status has been updated on chain. This should be called by /// ChannelManager via [`chain::Watch::release_pending_monitor_events`]. -/// -/// [`chain::Watch::release_pending_monitor_events`]: ../trait.Watch.html#tymethod.release_pending_monitor_events #[must_use] #[no_mangle] pub extern "C" fn ChannelMonitor_get_and_clear_pending_monitor_events(this_arg: &ChannelMonitor) -> crate::c_types::derived::CVec_MonitorEventZ { @@ -687,11 +685,8 @@ pub struct Persist { /// stored channel data). Note that you **must** persist every new monitor to /// disk. See the `Persist` trait documentation for more details. /// - /// See [`ChannelMonitor::serialize_for_disk`] for writing out a `ChannelMonitor`, + /// See [`ChannelMonitor::write`] for writing out a `ChannelMonitor`, /// and [`ChannelMonitorUpdateErr`] for requirements when returning errors. - /// - /// [`ChannelMonitor::serialize_for_disk`]: struct.ChannelMonitor.html#method.serialize_for_disk - /// [`ChannelMonitorUpdateErr`]: enum.ChannelMonitorUpdateErr.html #[must_use] pub persist_new_channel: extern "C" fn (this_arg: *const c_void, id: crate::chain::transaction::OutPoint, data: &crate::chain::channelmonitor::ChannelMonitor) -> crate::c_types::derived::CResult_NoneChannelMonitorUpdateErrZ, /// Update one channel's data. The provided `ChannelMonitor` has already @@ -713,14 +708,9 @@ pub struct Persist { /// them in batches. The size of each monitor grows `O(number of state updates)` /// whereas updates are small and `O(1)`. /// - /// See [`ChannelMonitor::serialize_for_disk`] for writing out a `ChannelMonitor`, + /// See [`ChannelMonitor::write`] for writing out a `ChannelMonitor`, /// [`ChannelMonitorUpdate::write`] for writing out an update, and /// [`ChannelMonitorUpdateErr`] for requirements when returning errors. - /// - /// [`ChannelMonitor::update_monitor`]: struct.ChannelMonitor.html#impl-1 - /// [`ChannelMonitor::serialize_for_disk`]: struct.ChannelMonitor.html#method.serialize_for_disk - /// [`ChannelMonitorUpdate::write`]: struct.ChannelMonitorUpdate.html#method.write - /// [`ChannelMonitorUpdateErr`]: enum.ChannelMonitorUpdateErr.html #[must_use] pub update_persisted_channel: extern "C" fn (this_arg: *const c_void, id: crate::chain::transaction::OutPoint, update: &crate::chain::channelmonitor::ChannelMonitorUpdate, data: &crate::chain::channelmonitor::ChannelMonitor) -> crate::c_types::derived::CResult_NoneChannelMonitorUpdateErrZ, /// Frees any resources associated with this object given its this_arg pointer. diff --git a/lightning-c-bindings/src/chain/keysinterface.rs b/lightning-c-bindings/src/chain/keysinterface.rs index ae533b6..daa76b7 100644 --- a/lightning-c-bindings/src/chain/keysinterface.rs +++ b/lightning-c-bindings/src/chain/keysinterface.rs @@ -1,3 +1,11 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + //! keysinterface provides keys into rust-lightning and defines some useful enums which describe //! spendable on-chain outputs which the user owns and is responsible for using just as any other //! on-chain output which is theirs. diff --git a/lightning-c-bindings/src/chain/mod.rs b/lightning-c-bindings/src/chain/mod.rs index 1fe2510..bce2971 100644 --- a/lightning-c-bindings/src/chain/mod.rs +++ b/lightning-c-bindings/src/chain/mod.rs @@ -1,3 +1,11 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + //! Structs and traits which allow other parts of rust-lightning to interact with the blockchain. use std::ffi::c_void; @@ -10,8 +18,6 @@ pub mod channelmonitor; pub mod transaction; pub mod keysinterface; /// An error when accessing the chain via [`Access`]. -/// -/// [`Access`]: trait.Access.html #[must_use] #[derive(Clone)] #[repr(C)] @@ -171,9 +177,9 @@ impl Drop for Listen { /// funds in the channel. See [`ChannelMonitorUpdateErr`] for more details about how to handle /// multiple instances. /// -/// [`ChannelMonitor`]: channelmonitor/struct.ChannelMonitor.html -/// [`ChannelMonitorUpdateErr`]: channelmonitor/enum.ChannelMonitorUpdateErr.html -/// [`PermanentFailure`]: channelmonitor/enum.ChannelMonitorUpdateErr.html#variant.PermanentFailure +/// [`ChannelMonitor`]: channelmonitor::ChannelMonitor +/// [`ChannelMonitorUpdateErr`]: channelmonitor::ChannelMonitorUpdateErr +/// [`PermanentFailure`]: channelmonitor::ChannelMonitorUpdateErr::PermanentFailure #[repr(C)] pub struct Watch { /// An opaque pointer which is passed to your function implementations as an argument. @@ -185,9 +191,9 @@ pub struct Watch { /// with any spends of outputs returned by [`get_outputs_to_watch`]. In practice, this means /// calling [`block_connected`] and [`block_disconnected`] on the monitor. /// - /// [`get_outputs_to_watch`]: channelmonitor/struct.ChannelMonitor.html#method.get_outputs_to_watch - /// [`block_connected`]: channelmonitor/struct.ChannelMonitor.html#method.block_connected - /// [`block_disconnected`]: channelmonitor/struct.ChannelMonitor.html#method.block_disconnected + /// [`get_outputs_to_watch`]: channelmonitor::ChannelMonitor::get_outputs_to_watch + /// [`block_connected`]: channelmonitor::ChannelMonitor::block_connected + /// [`block_disconnected`]: channelmonitor::ChannelMonitor::block_disconnected #[must_use] pub watch_channel: extern "C" fn (this_arg: *const c_void, funding_txo: crate::chain::transaction::OutPoint, monitor: crate::chain::channelmonitor::ChannelMonitor) -> crate::c_types::derived::CResult_NoneChannelMonitorUpdateErrZ, /// Updates a channel identified by `funding_txo` by applying `update` to its monitor. @@ -195,8 +201,8 @@ pub struct Watch { /// Implementations must call [`update_monitor`] with the given update. See /// [`ChannelMonitorUpdateErr`] for invariants around returning an error. /// - /// [`update_monitor`]: channelmonitor/struct.ChannelMonitor.html#method.update_monitor - /// [`ChannelMonitorUpdateErr`]: channelmonitor/enum.ChannelMonitorUpdateErr.html + /// [`update_monitor`]: channelmonitor::ChannelMonitor::update_monitor + /// [`ChannelMonitorUpdateErr`]: channelmonitor::ChannelMonitorUpdateErr #[must_use] pub update_channel: extern "C" fn (this_arg: *const c_void, funding_txo: crate::chain::transaction::OutPoint, update: crate::chain::channelmonitor::ChannelMonitorUpdate) -> crate::c_types::derived::CResult_NoneChannelMonitorUpdateErrZ, /// Returns any monitor events since the last call. Subsequent calls must only return new @@ -261,11 +267,10 @@ impl Drop for Watch { /// /// Note that use as part of a [`Watch`] implementation involves reentrancy. Therefore, the `Filter` /// should not block on I/O. Implementations should instead queue the newly monitored data to be -/// processed later. Then, in order to block until the data has been processed, any `Watch` +/// processed later. Then, in order to block until the data has been processed, any [`Watch`] /// invocation that has called the `Filter` must return [`TemporaryFailure`]. /// -/// [`Watch`]: trait.Watch.html -/// [`TemporaryFailure`]: channelmonitor/enum.ChannelMonitorUpdateErr.html#variant.TemporaryFailure +/// [`TemporaryFailure`]: channelmonitor::ChannelMonitorUpdateErr::TemporaryFailure /// [BIP 157]: https://github.com/bitcoin/bips/blob/master/bip-0157.mediawiki /// [BIP 158]: https://github.com/bitcoin/bips/blob/master/bip-0158.mediawiki #[repr(C)] diff --git a/lightning-c-bindings/src/chain/transaction.rs b/lightning-c-bindings/src/chain/transaction.rs index 0079873..cf9fdee 100644 --- a/lightning-c-bindings/src/chain/transaction.rs +++ b/lightning-c-bindings/src/chain/transaction.rs @@ -1,3 +1,11 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + //! Types describing on-chain transactions. use std::ffi::c_void; diff --git a/lightning-c-bindings/src/lib.rs b/lightning-c-bindings/src/lib.rs index 044c328..848464e 100644 --- a/lightning-c-bindings/src/lib.rs +++ b/lightning-c-bindings/src/lib.rs @@ -1,3 +1,11 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + //!lightning //! Rust-Lightning, not Rusty's Lightning! //! diff --git a/lightning-c-bindings/src/ln/chan_utils.rs b/lightning-c-bindings/src/ln/chan_utils.rs index f2a2a5a..406c4d1 100644 --- a/lightning-c-bindings/src/ln/chan_utils.rs +++ b/lightning-c-bindings/src/ln/chan_utils.rs @@ -1,3 +1,11 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + //! Various utilities for building scripts and deriving keys related to channels. These are //! largely of interest for those implementing chain::keysinterface::Sign message signing by hand. diff --git a/lightning-c-bindings/src/ln/channelmanager.rs b/lightning-c-bindings/src/ln/channelmanager.rs index 502520a..a5551a6 100644 --- a/lightning-c-bindings/src/ln/channelmanager.rs +++ b/lightning-c-bindings/src/ln/channelmanager.rs @@ -1,3 +1,11 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + //! The top-level channel management and payment tracking stuff lives here. //! //! The ChannelManager is the main chunk of logic implementing the lightning protocol and is @@ -189,6 +197,15 @@ pub extern "C" fn ChainParameters_new(mut network_arg: crate::bitcoin::network:: latest_height: latest_height_arg, })), is_owned: true } } +/// The amount of time in blocks we require our counterparty wait to claim their money (ie time +/// between when we, or our watchtower, must check for them having broadcast a theft transaction). +/// +/// This can be increased (but not decreased) through [`ChannelHandshakeConfig::our_to_self_delay`] +/// +/// [`ChannelHandshakeConfig::our_to_self_delay`]: crate::util::config::ChannelHandshakeConfig::our_to_self_delay + +#[no_mangle] +pub static BREAKDOWN_TIMEOUT: u16 = lightning::ln::channelmanager::BREAKDOWN_TIMEOUT; use lightning::ln::channelmanager::ChannelDetails as nativeChannelDetailsImport; type nativeChannelDetails = nativeChannelDetailsImport; @@ -943,6 +960,7 @@ pub extern "C" fn ChannelManager_as_ChannelMessageHandler(this_arg: &ChannelMana peer_disconnected: ChannelManager_ChannelMessageHandler_peer_disconnected, peer_connected: ChannelManager_ChannelMessageHandler_peer_connected, handle_channel_reestablish: ChannelManager_ChannelMessageHandler_handle_channel_reestablish, + handle_channel_update: ChannelManager_ChannelMessageHandler_handle_channel_update, handle_error: ChannelManager_ChannelMessageHandler_handle_error, MessageSendEventsProvider: crate::util::events::MessageSendEventsProvider { this_arg: unsafe { (*this_arg).inner as *mut c_void }, @@ -997,6 +1015,9 @@ extern "C" fn ChannelManager_ChannelMessageHandler_handle_update_fee(this_arg: * extern "C" fn ChannelManager_ChannelMessageHandler_handle_announcement_signatures(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::AnnouncementSignatures) { >::handle_announcement_signatures(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), unsafe { &*msg.inner }) } +extern "C" fn ChannelManager_ChannelMessageHandler_handle_channel_update(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::ChannelUpdate) { + >::handle_channel_update(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), unsafe { &*msg.inner }) +} extern "C" fn ChannelManager_ChannelMessageHandler_handle_channel_reestablish(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::ChannelReestablish) { >::handle_channel_reestablish(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), unsafe { &*msg.inner }) } diff --git a/lightning-c-bindings/src/ln/features.rs b/lightning-c-bindings/src/ln/features.rs index 1866068..a58ae7a 100644 --- a/lightning-c-bindings/src/ln/features.rs +++ b/lightning-c-bindings/src/ln/features.rs @@ -1,10 +1,17 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + //! Feature flag definitions for the Lightning protocol according to [BOLT #9]. //! //! Lightning nodes advertise a supported set of operation through feature flags. Features are //! applicable for a specific context as indicated in some [messages]. [`Features`] encapsulates //! behavior for specifying and checking feature flags for a particular context. Each feature is -//! defined internally by a trait specifying the corresponding flags (i.e., even and odd bits). A -//! [`Context`] is used to parameterize [`Features`] and defines which features it can support. +//! defined internally by a trait specifying the corresponding flags (i.e., even and odd bits). //! //! Whether a feature is considered \"known\" or \"unknown\" is relative to the implementation, whereas //! the term \"supports\" is used in reference to a particular set of [`Features`]. That is, a node @@ -12,9 +19,7 @@ //! And the implementation can interpret a feature if the feature is known to it. //! //! [BOLT #9]: https://github.com/lightningnetwork/lightning-rfc/blob/master/09-features.md -//! [messages]: ../msgs/index.html -//! [`Features`]: struct.Features.html -//! [`Context`]: sealed/trait.Context.html +//! [messages]: crate::ln::msgs use std::ffi::c_void; use bitcoin::hashes::Hash; @@ -284,9 +289,7 @@ pub extern "C" fn InitFeatures_empty() -> InitFeatures { InitFeatures { inner: Box::into_raw(Box::new(ret)), is_owned: true } } -/// Creates features known by the implementation as defined by [`T::KNOWN_FEATURE_FLAGS`]. -/// -/// [`T::KNOWN_FEATURE_FLAGS`]: sealed/trait.Context.html#associatedconstant.KNOWN_FEATURE_FLAGS +/// Creates a Features with the bits set which are known by the implementation #[must_use] #[no_mangle] pub extern "C" fn InitFeatures_known() -> InitFeatures { @@ -302,9 +305,7 @@ pub extern "C" fn NodeFeatures_empty() -> NodeFeatures { NodeFeatures { inner: Box::into_raw(Box::new(ret)), is_owned: true } } -/// Creates features known by the implementation as defined by [`T::KNOWN_FEATURE_FLAGS`]. -/// -/// [`T::KNOWN_FEATURE_FLAGS`]: sealed/trait.Context.html#associatedconstant.KNOWN_FEATURE_FLAGS +/// Creates a Features with the bits set which are known by the implementation #[must_use] #[no_mangle] pub extern "C" fn NodeFeatures_known() -> NodeFeatures { @@ -320,9 +321,7 @@ pub extern "C" fn ChannelFeatures_empty() -> ChannelFeatures { ChannelFeatures { inner: Box::into_raw(Box::new(ret)), is_owned: true } } -/// Creates features known by the implementation as defined by [`T::KNOWN_FEATURE_FLAGS`]. -/// -/// [`T::KNOWN_FEATURE_FLAGS`]: sealed/trait.Context.html#associatedconstant.KNOWN_FEATURE_FLAGS +/// Creates a Features with the bits set which are known by the implementation #[must_use] #[no_mangle] pub extern "C" fn ChannelFeatures_known() -> ChannelFeatures { @@ -338,9 +337,7 @@ pub extern "C" fn InvoiceFeatures_empty() -> InvoiceFeatures { InvoiceFeatures { inner: Box::into_raw(Box::new(ret)), is_owned: true } } -/// Creates features known by the implementation as defined by [`T::KNOWN_FEATURE_FLAGS`]. -/// -/// [`T::KNOWN_FEATURE_FLAGS`]: sealed/trait.Context.html#associatedconstant.KNOWN_FEATURE_FLAGS +/// Creates a Features with the bits set which are known by the implementation #[must_use] #[no_mangle] pub extern "C" fn InvoiceFeatures_known() -> InvoiceFeatures { diff --git a/lightning-c-bindings/src/ln/mod.rs b/lightning-c-bindings/src/ln/mod.rs index b81204a..d6ca8b3 100644 --- a/lightning-c-bindings/src/ln/mod.rs +++ b/lightning-c-bindings/src/ln/mod.rs @@ -1,3 +1,11 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + //! High level lightning structs and impls live here. //! //! You probably want to create a channelmanager::ChannelManager, and a routing::NetGraphMsgHandler first. diff --git a/lightning-c-bindings/src/ln/msgs.rs b/lightning-c-bindings/src/ln/msgs.rs index 4eb5b9d..5f32cac 100644 --- a/lightning-c-bindings/src/ln/msgs.rs +++ b/lightning-c-bindings/src/ln/msgs.rs @@ -1,3 +1,11 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + //! Wire messages, traits representing wire message handlers, and a few error types live here. //! //! For a normal node you probably don't need to use anything here, however, if you wish to split a @@ -3264,13 +3272,27 @@ pub extern "C" fn UnsignedChannelUpdate_get_flags(this_ptr: &UnsignedChannelUpda pub extern "C" fn UnsignedChannelUpdate_set_flags(this_ptr: &mut UnsignedChannelUpdate, mut val: u8) { unsafe { &mut *this_ptr.inner }.flags = val; } -/// The number of blocks to subtract from incoming HTLC cltv_expiry values +/// The number of blocks such that if: +/// `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta` +/// then we need to fail the HTLC backwards. When forwarding an HTLC, cltv_expiry_delta determines +/// the outgoing HTLC's minimum cltv_expiry value -- so, if an incoming HTLC comes in with a +/// cltv_expiry of 100000, and the node we're forwarding to has a cltv_expiry_delta value of 10, +/// then we'll check that the outgoing HTLC's cltv_expiry value is at least 100010 before +/// forwarding. Note that the HTLC sender is the one who originally sets this value when +/// constructing the route. #[no_mangle] pub extern "C" fn UnsignedChannelUpdate_get_cltv_expiry_delta(this_ptr: &UnsignedChannelUpdate) -> u16 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.cltv_expiry_delta; (*inner_val) } -/// The number of blocks to subtract from incoming HTLC cltv_expiry values +/// The number of blocks such that if: +/// `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta` +/// then we need to fail the HTLC backwards. When forwarding an HTLC, cltv_expiry_delta determines +/// the outgoing HTLC's minimum cltv_expiry value -- so, if an incoming HTLC comes in with a +/// cltv_expiry of 100000, and the node we're forwarding to has a cltv_expiry_delta value of 10, +/// then we'll check that the outgoing HTLC's cltv_expiry value is at least 100010 before +/// forwarding. Note that the HTLC sender is the one who originally sets this value when +/// constructing the route. #[no_mangle] pub extern "C" fn UnsignedChannelUpdate_set_cltv_expiry_delta(this_ptr: &mut UnsignedChannelUpdate, mut val: u16) { unsafe { &mut *this_ptr.inner }.cltv_expiry_delta = val; @@ -4486,6 +4508,8 @@ pub struct ChannelMessageHandler { pub peer_connected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::Init), /// Handle an incoming channel_reestablish message from the given peer. pub handle_channel_reestablish: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::ChannelReestablish), + /// Handle an incoming channel update from the given peer. + pub handle_channel_update: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::ChannelUpdate), /// Handle an incoming error message from the given peer. pub handle_error: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::ErrorMessage), /// Implementation of MessageSendEventsProvider for this object. @@ -4558,6 +4582,9 @@ impl rustChannelMessageHandler for ChannelMessageHandler { fn handle_channel_reestablish(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::ChannelReestablish) { (self.handle_channel_reestablish)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::ln::msgs::ChannelReestablish { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false }) } + fn handle_channel_update(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::ChannelUpdate) { + (self.handle_channel_update)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::ln::msgs::ChannelUpdate { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false }) + } fn handle_error(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::ErrorMessage) { (self.handle_error)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::ln::msgs::ErrorMessage { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false }) } @@ -5177,6 +5204,14 @@ pub extern "C" fn ReplyShortChannelIdsEnd_write(obj: &ReplyShortChannelIdsEnd) - pub(crate) extern "C" fn ReplyShortChannelIdsEnd_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyShortChannelIdsEnd) }) } +///\n\t * Calculates the overflow safe ending block height for the query.\n\t * Overflow returns `0xffffffff`, otherwise returns `first_blocknum + number_of_blocks`\n\t +#[must_use] +#[no_mangle] +pub extern "C" fn QueryChannelRange_end_blocknum(this_arg: &QueryChannelRange) -> u32 { + let mut ret = unsafe { &*this_arg.inner }.end_blocknum(); + ret +} + #[no_mangle] /// Read a QueryChannelRange from a byte array, created by QueryChannelRange_write pub extern "C" fn QueryChannelRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_QueryChannelRangeDecodeErrorZ { diff --git a/lightning-c-bindings/src/ln/peer_handler.rs b/lightning-c-bindings/src/ln/peer_handler.rs index 9cf6baa..9f3f840 100644 --- a/lightning-c-bindings/src/ln/peer_handler.rs +++ b/lightning-c-bindings/src/ln/peer_handler.rs @@ -1,3 +1,11 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + //! Top level peer message handling and socket handling logic lives here. //! //! Instead of actually servicing sockets ourselves we require that you implement the @@ -312,6 +320,7 @@ pub extern "C" fn ErroringMessageHandler_as_ChannelMessageHandler(this_arg: &Err peer_disconnected: ErroringMessageHandler_ChannelMessageHandler_peer_disconnected, peer_connected: ErroringMessageHandler_ChannelMessageHandler_peer_connected, handle_channel_reestablish: ErroringMessageHandler_ChannelMessageHandler_handle_channel_reestablish, + handle_channel_update: ErroringMessageHandler_ChannelMessageHandler_handle_channel_update, handle_error: ErroringMessageHandler_ChannelMessageHandler_handle_error, MessageSendEventsProvider: crate::util::events::MessageSendEventsProvider { this_arg: unsafe { (*this_arg).inner as *mut c_void }, @@ -369,6 +378,9 @@ extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_announcement_s extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_channel_reestablish(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::ChannelReestablish) { >::handle_channel_reestablish(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), unsafe { &*msg.inner }) } +extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_channel_update(this_arg: *const c_void, mut _their_node_id: crate::c_types::PublicKey, _msg: &crate::ln::msgs::ChannelUpdate) { + >::handle_channel_update(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &_their_node_id.into_rust(), unsafe { &*_msg.inner }) +} extern "C" fn ErroringMessageHandler_ChannelMessageHandler_peer_disconnected(this_arg: *const c_void, mut _their_node_id: crate::c_types::PublicKey, mut _no_connection_possible: bool) { >::peer_disconnected(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &_their_node_id.into_rust(), _no_connection_possible) } diff --git a/lightning-c-bindings/src/routing/mod.rs b/lightning-c-bindings/src/routing/mod.rs index 4311ff3..a06e1d0 100644 --- a/lightning-c-bindings/src/routing/mod.rs +++ b/lightning-c-bindings/src/routing/mod.rs @@ -1,3 +1,11 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + //! Structs and impls for receiving messages about the network and storing the topology live here. use std::ffi::c_void; diff --git a/lightning-c-bindings/src/routing/network_graph.rs b/lightning-c-bindings/src/routing/network_graph.rs index f4eec9d..9ffeaf2 100644 --- a/lightning-c-bindings/src/routing/network_graph.rs +++ b/lightning-c-bindings/src/routing/network_graph.rs @@ -1,3 +1,11 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + //! The top-level network map tracking logic lives here. use std::ffi::c_void; @@ -301,8 +309,8 @@ extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_handle_reply_short_channe local_ret } #[must_use] -extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_handle_query_channel_range(this_arg: *const c_void, mut _their_node_id: crate::c_types::PublicKey, mut _msg: crate::ln::msgs::QueryChannelRange) -> crate::c_types::derived::CResult_NoneLightningErrorZ { - let mut ret = >::handle_query_channel_range(unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }, &_their_node_id.into_rust(), *unsafe { Box::from_raw(_msg.take_inner()) }); +extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_handle_query_channel_range(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, mut msg: crate::ln::msgs::QueryChannelRange) -> crate::c_types::derived::CResult_NoneLightningErrorZ { + let mut ret = >::handle_query_channel_range(unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }, &their_node_id.into_rust(), *unsafe { Box::from_raw(msg.take_inner()) }); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; local_ret } diff --git a/lightning-c-bindings/src/routing/router.rs b/lightning-c-bindings/src/routing/router.rs index 496781f..c07ab51 100644 --- a/lightning-c-bindings/src/routing/router.rs +++ b/lightning-c-bindings/src/routing/router.rs @@ -1,3 +1,11 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + //! The top-level routing/network map tracking logic lives here. //! //! You probably want to create a NetGraphMsgHandler and use that as your RoutingMessageHandler and then diff --git a/lightning-c-bindings/src/util/config.rs b/lightning-c-bindings/src/util/config.rs index a680d5c..d1d3f1b 100644 --- a/lightning-c-bindings/src/util/config.rs +++ b/lightning-c-bindings/src/util/config.rs @@ -1,3 +1,11 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + //! Various user-configurable channel limits and settings which ChannelManager //! applies for you. @@ -81,7 +89,7 @@ pub extern "C" fn ChannelHandshakeConfig_set_minimum_depth(this_ptr: &mut Channe /// case of an honest unilateral channel close, which implicitly decrease the economic value of /// our channel. /// -/// Default value: BREAKDOWN_TIMEOUT (currently 144), we enforce it as a minimum at channel +/// Default value: [`BREAKDOWN_TIMEOUT`] (currently 144), we enforce it as a minimum at channel /// opening so you can tweak config to ask for more security, not less. #[no_mangle] pub extern "C" fn ChannelHandshakeConfig_get_our_to_self_delay(this_ptr: &ChannelHandshakeConfig) -> u16 { @@ -98,7 +106,7 @@ pub extern "C" fn ChannelHandshakeConfig_get_our_to_self_delay(this_ptr: &Channe /// case of an honest unilateral channel close, which implicitly decrease the economic value of /// our channel. /// -/// Default value: BREAKDOWN_TIMEOUT (currently 144), we enforce it as a minimum at channel +/// Default value: [`BREAKDOWN_TIMEOUT`] (currently 144), we enforce it as a minimum at channel /// opening so you can tweak config to ask for more security, not less. #[no_mangle] pub extern "C" fn ChannelHandshakeConfig_set_our_to_self_delay(this_ptr: &mut ChannelHandshakeConfig, mut val: u16) { diff --git a/lightning-c-bindings/src/util/errors.rs b/lightning-c-bindings/src/util/errors.rs index d24df67..5261382 100644 --- a/lightning-c-bindings/src/util/errors.rs +++ b/lightning-c-bindings/src/util/errors.rs @@ -1,3 +1,11 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + //! Error types live here. use std::ffi::c_void; diff --git a/lightning-c-bindings/src/util/events.rs b/lightning-c-bindings/src/util/events.rs index 905360b..72d9de5 100644 --- a/lightning-c-bindings/src/util/events.rs +++ b/lightning-c-bindings/src/util/events.rs @@ -1,3 +1,11 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + //! Events are returned from various bits in the library which indicate some action must be taken //! by the client. //! @@ -491,6 +499,14 @@ pub enum MessageSendEvent { /// The query_short_channel_ids which should be sent. msg: crate::ln::msgs::QueryShortChannelIds, }, + /// Sends a reply to a channel range query. This may be one of several SendReplyChannelRange events + /// emitted during processing of the query. + SendReplyChannelRange { + /// The node_id of this message recipient + node_id: crate::c_types::PublicKey, + /// The reply_channel_range which should be sent. + msg: crate::ln::msgs::ReplyChannelRange, + }, } use lightning::util::events::MessageSendEvent as nativeMessageSendEvent; impl MessageSendEvent { @@ -635,6 +651,14 @@ impl MessageSendEvent { msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, } }, + MessageSendEvent::SendReplyChannelRange {ref node_id, ref msg, } => { + let mut node_id_nonref = (*node_id).clone(); + let mut msg_nonref = (*msg).clone(); + nativeMessageSendEvent::SendReplyChannelRange { + node_id: node_id_nonref.into_rust(), + msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, + } + }, } } #[allow(unused)] @@ -745,6 +769,12 @@ impl MessageSendEvent { msg: *unsafe { Box::from_raw(msg.take_inner()) }, } }, + MessageSendEvent::SendReplyChannelRange {mut node_id, mut msg, } => { + nativeMessageSendEvent::SendReplyChannelRange { + node_id: node_id.into_rust(), + msg: *unsafe { Box::from_raw(msg.take_inner()) }, + } + }, } } #[allow(unused)] @@ -888,6 +918,14 @@ impl MessageSendEvent { msg: crate::ln::msgs::QueryShortChannelIds { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true }, } }, + nativeMessageSendEvent::SendReplyChannelRange {ref node_id, ref msg, } => { + let mut node_id_nonref = (*node_id).clone(); + let mut msg_nonref = (*msg).clone(); + MessageSendEvent::SendReplyChannelRange { + node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), + msg: crate::ln::msgs::ReplyChannelRange { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true }, + } + }, } } #[allow(unused)] @@ -998,6 +1036,12 @@ impl MessageSendEvent { msg: crate::ln::msgs::QueryShortChannelIds { inner: Box::into_raw(Box::new(msg)), is_owned: true }, } }, + nativeMessageSendEvent::SendReplyChannelRange {mut node_id, mut msg, } => { + MessageSendEvent::SendReplyChannelRange { + node_id: crate::c_types::PublicKey::from_rust(&node_id), + msg: crate::ln::msgs::ReplyChannelRange { inner: Box::into_raw(Box::new(msg)), is_owned: true }, + } + }, } } } diff --git a/lightning-c-bindings/src/util/logger.rs b/lightning-c-bindings/src/util/logger.rs index 97874dd..e6b98de 100644 --- a/lightning-c-bindings/src/util/logger.rs +++ b/lightning-c-bindings/src/util/logger.rs @@ -1,3 +1,11 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + //! Log traits live here, which are called throughout the library to provide useful information for //! debugging purposes. //! diff --git a/lightning-c-bindings/src/util/mod.rs b/lightning-c-bindings/src/util/mod.rs index c35bf64..49003dc 100644 --- a/lightning-c-bindings/src/util/mod.rs +++ b/lightning-c-bindings/src/util/mod.rs @@ -1,3 +1,11 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + //! Some utility modules live here. See individual sub-modules for more info. use std::ffi::c_void; diff --git a/lightning-c-bindings/src/util/ser.rs b/lightning-c-bindings/src/util/ser.rs index b088e96..e0c561f 100644 --- a/lightning-c-bindings/src/util/ser.rs +++ b/lightning-c-bindings/src/util/ser.rs @@ -1,3 +1,11 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + //! A very simple serialization framework which is used to serialize/deserialize messages as well //! as ChannelsManagers and ChannelMonitors. -- 2.39.5