Merge pull request #68 from jkczyz/2022-03-ldk-0-0-106
authorMatt Corallo <649246+TheBlueMatt@users.noreply.github.com>
Mon, 4 Apr 2022 16:20:18 +0000 (16:20 +0000)
committerGitHub <noreply@github.com>
Mon, 4 Apr 2022 16:20:18 +0000 (16:20 +0000)
Update to 0.0.106

19 files changed:
.github/workflows/build.yml
ldk-net/ldk_net.c
lightning-c-bindings/.gitignore [new file with mode: 0644]
lightning-c-bindings/Cargo.toml
lightning-c-bindings/demo.cpp
lightning-c-bindings/include/lightning.h
lightning-c-bindings/include/lightningpp.hpp
lightning-c-bindings/src/c_types/derived.rs
lightning-c-bindings/src/lightning/ln/channelmanager.rs
lightning-c-bindings/src/lightning/ln/msgs.rs
lightning-c-bindings/src/lightning/ln/peer_handler.rs
lightning-c-bindings/src/lightning/routing/network_graph.rs
lightning-c-bindings/src/lightning/routing/router.rs
lightning-c-bindings/src/lightning/routing/scoring.rs
lightning-c-bindings/src/lightning/util/config.rs
lightning-c-bindings/src/lightning/util/events.rs
lightning-c-bindings/src/lightning_background_processor.rs
lightning-c-bindings/src/lightning_invoice/utils.rs
lightning-c-bindings/src/lightning_persister.rs

index 9387a7f4076504c8e33231b03da6f540b60b8458..7e7239837976c6e0ed08a9e3e1344376947062e9 100644 (file)
@@ -32,7 +32,7 @@ jobs:
         run: |
           git clone https://github.com/rust-bitcoin/rust-lightning
           cd rust-lightning
-          git checkout 0.0.105-bindings
+          git checkout 0.0.106-bindings
       - name: Rebuild bindings without std, and check the sample app builds + links
         run: ./genbindings.sh ./rust-lightning false
       - name: Rebuild bindings, and check the sample app builds + links
@@ -83,7 +83,7 @@ jobs:
         run: |
           git clone https://github.com/rust-bitcoin/rust-lightning
           cd rust-lightning
-          git checkout 0.0.105-bindings
+          git checkout 0.0.106-bindings
       - name: Rebuild bindings using Apple clang, and check the sample app builds + links
         run: ./genbindings.sh ./rust-lightning true
       - name: Rebuild bindings using upstream clang, and check the sample app builds + links
index f404ddd973d107477968011893a439e5c5c8e997..8bae7af192c1c08b0f41f1bbf1310718fb635c5b 100644 (file)
@@ -214,7 +214,10 @@ static void *sock_thread_fn(void* arg) {
                                                                if (newfd >= 0) {
                                                                        // Received a new connection, register it!
                                                                        LDKSocketDescriptor new_descriptor = get_descriptor(handler, newfd);
-                                                                       LDKCResult_NonePeerHandleErrorZ con_res = PeerManager_new_inbound_connection(&handler->ldk_peer_manager, new_descriptor);
+                                                                       LDKCOption_NetAddressZ remote_network_address = {
+                                                                               .tag = LDKCOption_NetAddressZ_None,
+                                                                       };
+                                                                       LDKCResult_NonePeerHandleErrorZ con_res = PeerManager_new_inbound_connection(&handler->ldk_peer_manager, new_descriptor, remote_network_address);
                                                                        if (con_res.result_ok) {
                                                                                if (register_socket(handler, newfd, 0))
                                                                                        shutdown(newfd, SHUT_RDWR);
@@ -378,7 +381,10 @@ int socket_connect(void* arg, LDKPublicKey pubkey, struct sockaddr *addr, size_t
        if (register_socket(handler, fd, 0)) return -4;
 
        LDKSocketDescriptor descriptor = get_descriptor(handler, fd);
-       LDKCResult_CVec_u8ZPeerHandleErrorZ con_res = PeerManager_new_outbound_connection(&handler->ldk_peer_manager, pubkey, descriptor);
+       LDKCOption_NetAddressZ remote_network_address = {
+               .tag = LDKCOption_NetAddressZ_None,
+       };
+       LDKCResult_CVec_u8ZPeerHandleErrorZ con_res = PeerManager_new_outbound_connection(&handler->ldk_peer_manager, pubkey, descriptor, remote_network_address);
        if (con_res.result_ok) {
                ssize_t write_count = send(fd, con_res.contents.result->data, con_res.contents.result->datalen, MSG_NOSIGNAL);
                if (write_count != con_res.contents.result->datalen)
diff --git a/lightning-c-bindings/.gitignore b/lightning-c-bindings/.gitignore
new file mode 100644 (file)
index 0000000..493e9ec
--- /dev/null
@@ -0,0 +1,7 @@
+Cargo.lock
+a.out
+a.out.*
+include/ldk_ver.h
+ldk_net.o
+src/version.rs
+target
index 1dc07eaa4c06302b403fcdf66b491050170178f1..3c77e22f7eb43908532bc98169153eafb5d86720 100644 (file)
@@ -22,10 +22,10 @@ std = ["bitcoin/std", "lightning/std", "lightning-invoice/std"]
 bitcoin = { version = "0.27", default-features = false }
 secp256k1 = { version = "0.20.3", features = ["global-context-less-secure"] }
 # Note that the following line is matched by genbindings to update the path
-lightning = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "0.0.105-bindings", default-features = false }
-lightning-persister = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "0.0.105-bindings", default-features = false }
-lightning-invoice = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "0.0.105-bindings", default-features = false }
-lightning-background-processor = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "0.0.105-bindings", default-features = false }
+lightning = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "0.0.106-bindings", default-features = false }
+lightning-persister = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "0.0.106-bindings", default-features = false }
+lightning-invoice = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "0.0.106-bindings", default-features = false }
+lightning-background-processor = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "0.0.106-bindings", default-features = false }
 
 core2 = { version = "0.3.0", optional = true, default-features = false }
 
index 08bf66edfb72fefb669fc53dc452ef0de269774e..ec7a0d104e2a2dcb6ac5fd2ca70a40fc12d4f81a 100644 (file)
@@ -331,9 +331,12 @@ public:
                t2 = std::thread(&sock_read_data_thread, pipefds_1_to_2[0], &sock2, &net2);
 
                // Note that we have to bind the result to a C++ class to make sure it gets free'd
-               LDK::CResult_CVec_u8ZPeerHandleErrorZ con_res = PeerManager_new_outbound_connection(&net1, ChannelManager_get_our_node_id(&cm2), sock1);
+               LDKCOption_NetAddressZ remote_network_address = {
+                       .tag = LDKCOption_NetAddressZ_None,
+               };
+               LDK::CResult_CVec_u8ZPeerHandleErrorZ con_res = PeerManager_new_outbound_connection(&net1, ChannelManager_get_our_node_id(&cm2), sock1, remote_network_address);
                assert(con_res->result_ok);
-               LDK::CResult_NonePeerHandleErrorZ con_res2 = PeerManager_new_inbound_connection(&net2, sock2);
+               LDK::CResult_NonePeerHandleErrorZ con_res2 = PeerManager_new_inbound_connection(&net2, sock2, remote_network_address);
                assert(con_res2->result_ok);
 
                auto writelen = write(pipefds_1_to_2[1], con_res->contents.result->data, con_res->contents.result->datalen);
@@ -428,12 +431,13 @@ uint64_t get_chan_score(const void *this_arg, uint64_t scid, uint64_t htlc_amt,
 struct CustomRouteFinderParams {
        LDKLogger *logger;
        LDKNetworkGraph *graph_ref;
+       LDKThirtyTwoBytes random_seed_bytes;
 };
 struct LDKCResult_RouteLightningErrorZ custom_find_route(const void *this_arg, struct LDKPublicKey payer, const struct LDKRouteParameters *NONNULL_PTR route_params, const uint8_t (*payment_hash)[32], struct LDKCVec_ChannelDetailsZ *first_hops, const struct LDKScore *NONNULL_PTR scorer) {
        const struct CustomRouteFinderParams *params = (struct CustomRouteFinderParams *)this_arg;
        assert(first_hops->datalen == 1);
        assert(ChannelDetails_get_is_usable(&first_hops->data[0]));
-       return find_route(payer, route_params, params->graph_ref, first_hops, *params->logger, scorer);
+       return find_route(payer, route_params, params->graph_ref, first_hops, *params->logger, scorer, &params->random_seed_bytes.data);
 }
 
 int main() {
@@ -702,7 +706,8 @@ int main() {
                                                .inner = NULL, .is_owned = false
                                        }, Invoice_route_hints(invoice->contents.result), COption_u64Z_none(), 0xffffffff),
                                5000, Invoice_min_final_cltv_expiry(invoice->contents.result));
-                       LDK::CResult_RouteLightningErrorZ route = find_route(ChannelManager_get_our_node_id(&cm1), &route_params, &net_graph2, &outbound_channels, logger1, &chan_scorer);
+                       random_bytes = keys_source1->get_secure_random_bytes(keys_source1->this_arg);
+                       LDK::CResult_RouteLightningErrorZ route = find_route(ChannelManager_get_our_node_id(&cm1), &route_params, &net_graph2, &outbound_channels, logger1, &chan_scorer, &random_bytes.data);
                        assert(route->result_ok);
                        LDK::CVec_CVec_RouteHopZZ paths = Route_get_paths(route->contents.result);
                        assert(paths->datalen == 1);
@@ -858,6 +863,7 @@ int main() {
        struct CustomRouteFinderParams router_params = {
                .logger = &logger1,
                .graph_ref = &net_graph1,
+               .random_seed_bytes = keys_source1->get_secure_random_bytes(keys_source1->this_arg),
        };
        LDKRouter sending_router = {
                .this_arg = &router_params,
index 99a23a0dd007f95b321003fe87eabb88f5ec57aa..ac086be8eb562b667066621c342136cae53ae403 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef LDK_C_BINDINGS_H
 #define LDK_C_BINDINGS_H
 
-/* Generated with cbindgen:0.20.0 */
+/* Generated with cbindgen:0.17.0 */
 
 /* Warning, this file is autogenerated by cbindgen. Don't modify this manually. */
 
@@ -2768,6 +2768,35 @@ typedef struct MUST_USE_STRUCT LDKPaymentPurpose {
    };
 } LDKPaymentPurpose;
 
+
+
+/**
+ * Features used within the channel_type field in an OpenChannel message.
+ *
+ * A channel is always of some known \"type\", describing the transaction formats used and the exact
+ * semantics of our interaction with our peer.
+ *
+ * Note that because a channel is a specific type which is proposed by the opener and accepted by
+ * the counterparty, only required features are allowed here.
+ *
+ * This is serialized differently from other feature types - it is not prefixed by a length, and
+ * thus must only appear inside a TLV where its length is known in advance.
+ */
+typedef struct MUST_USE_STRUCT LDKChannelTypeFeatures {
+   /**
+    * 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.
+    */
+   LDKnativeChannelTypeFeatures *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;
+} LDKChannelTypeFeatures;
+
 /**
  * An Event which you should probably take some action in response to.
  *
@@ -3112,11 +3141,15 @@ typedef struct LDKEvent_LDKChannelClosed_Body {
     */
    struct LDKThirtyTwoBytes channel_id;
    /**
-    * The `user_channel_id` value passed in to [`ChannelManager::create_channel`], or 0 for
-    * an inbound channel. This will always be zero for objects serialized with LDK versions
-    * prior to 0.0.102.
+    * The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound
+    * channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if
+    * [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise
+    * `user_channel_id` will be 0 for an inbound channel.
+    * This will always be zero for objects serialized with LDK versions prior to 0.0.102.
     *
     * [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
+    * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
+    * [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
     */
    uint64_t user_channel_id;
    /**
@@ -3185,6 +3218,18 @@ typedef struct LDKEvent_LDKOpenChannelRequest_Body {
     * Our starting balance in the channel if the request is accepted, in milli-satoshi.
     */
    uint64_t push_msat;
+   /**
+    * The features that this channel will operate with. If you reject the channel, a
+    * well-behaved counterparty may automatically re-attempt the channel with a new set of
+    * feature flags.
+    *
+    * Note that if [`ChannelTypeFeatures::supports_scid_privacy`] returns true on this type,
+    * the resulting [`ChannelManager`] will not be readable by versions of LDK prior to
+    * 0.0.106.
+    *
+    * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
+    */
+   struct LDKChannelTypeFeatures channel_type;
 } LDKEvent_LDKOpenChannelRequest_Body;
 
 typedef struct MUST_USE_STRUCT LDKEvent {
@@ -3720,6 +3765,28 @@ typedef struct MUST_USE_STRUCT LDKReplyChannelRange {
    bool is_owned;
 } LDKReplyChannelRange;
 
+
+
+/**
+ * A gossip_timestamp_filter message is used by a node to request
+ * gossip relay for messages in the requested time range when the
+ * gossip_queries feature has been negotiated.
+ */
+typedef struct MUST_USE_STRUCT LDKGossipTimestampFilter {
+   /**
+    * 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.
+    */
+   LDKnativeGossipTimestampFilter *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;
+} LDKGossipTimestampFilter;
+
 /**
  * An event generated by ChannelManager which indicates a message should be sent to a peer (or
  * broadcast to most peers).
@@ -3816,6 +3883,11 @@ typedef enum LDKMessageSendEvent_Tag {
     * emitted during processing of the query.
     */
    LDKMessageSendEvent_SendReplyChannelRange,
+   /**
+    * Sends a timestamp filter for inbound gossip. This should be sent on each new connection to
+    * enable receiving gossip messages from the peer.
+    */
+   LDKMessageSendEvent_SendGossipTimestampFilter,
    /**
     * Must be last for serialization purposes
     */
@@ -4023,6 +4095,17 @@ typedef struct LDKMessageSendEvent_LDKSendReplyChannelRange_Body {
    struct LDKReplyChannelRange msg;
 } LDKMessageSendEvent_LDKSendReplyChannelRange_Body;
 
+typedef struct LDKMessageSendEvent_LDKSendGossipTimestampFilter_Body {
+   /**
+    * The node_id of this message recipient
+    */
+   struct LDKPublicKey node_id;
+   /**
+    * The gossip_timestamp_filter which should be sent.
+    */
+   struct LDKGossipTimestampFilter msg;
+} LDKMessageSendEvent_LDKSendGossipTimestampFilter_Body;
+
 typedef struct MUST_USE_STRUCT LDKMessageSendEvent {
    LDKMessageSendEvent_Tag tag;
    union {
@@ -4045,6 +4128,7 @@ typedef struct MUST_USE_STRUCT LDKMessageSendEvent {
       LDKMessageSendEvent_LDKSendChannelRangeQuery_Body send_channel_range_query;
       LDKMessageSendEvent_LDKSendShortIdsQuery_Body send_short_ids_query;
       LDKMessageSendEvent_LDKSendReplyChannelRange_Body send_reply_channel_range;
+      LDKMessageSendEvent_LDKSendGossipTimestampFilter_Body send_gossip_timestamp_filter;
    };
 } LDKMessageSendEvent;
 
@@ -4237,59 +4321,6 @@ typedef struct LDKCResult_ScorerDecodeErrorZ {
 
 
 
-/**
- * Parameters for configuring [`ProbabilisticScorer`].
- */
-typedef struct MUST_USE_STRUCT LDKProbabilisticScoringParameters {
-   /**
-    * 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.
-    */
-   LDKnativeProbabilisticScoringParameters *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;
-} LDKProbabilisticScoringParameters;
-
-/**
- * The contents of CResult_ProbabilisticScoringParametersDecodeErrorZ
- */
-typedef union LDKCResult_ProbabilisticScoringParametersDecodeErrorZPtr {
-   /**
-    * A pointer to the contents in the success state.
-    * Reading from this pointer when `result_ok` is not set is undefined.
-    */
-   struct LDKProbabilisticScoringParameters *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_ProbabilisticScoringParametersDecodeErrorZPtr;
-
-/**
- * A CResult_ProbabilisticScoringParametersDecodeErrorZ represents the result of a fallible operation,
- * containing a crate::lightning::routing::scoring::ProbabilisticScoringParameters 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_ProbabilisticScoringParametersDecodeErrorZ {
-   /**
-    * The contents of this CResult_ProbabilisticScoringParametersDecodeErrorZ, accessible via either
-    * `err` or `result` depending on the state of `result_ok`.
-    */
-   union LDKCResult_ProbabilisticScoringParametersDecodeErrorZPtr contents;
-   /**
-    * Whether this CResult_ProbabilisticScoringParametersDecodeErrorZ represents a success state.
-    */
-   bool result_ok;
-} LDKCResult_ProbabilisticScoringParametersDecodeErrorZ;
-
-
-
 /**
  * Represents the network as nodes and channels between them
  */
@@ -4594,35 +4625,6 @@ typedef struct LDKCResult_InvoiceFeaturesDecodeErrorZ {
    bool result_ok;
 } LDKCResult_InvoiceFeaturesDecodeErrorZ;
 
-
-
-/**
- * Features used within the channel_type field in an OpenChannel message.
- *
- * A channel is always of some known \"type\", describing the transaction formats used and the exact
- * semantics of our interaction with our peer.
- *
- * Note that because a channel is a specific type which is proposed by the opener and accepted by
- * the counterparty, only required features are allowed here.
- *
- * This is serialized differently from other feature types - it is not prefixed by a length, and
- * thus must only appear inside a TLV where its length is known in advance.
- */
-typedef struct MUST_USE_STRUCT LDKChannelTypeFeatures {
-   /**
-    * 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.
-    */
-   LDKnativeChannelTypeFeatures *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;
-} LDKChannelTypeFeatures;
-
 /**
  * The contents of CResult_ChannelTypeFeaturesDecodeErrorZ
  */
@@ -8273,6 +8275,33 @@ typedef struct LDKCVec_PublicKeyZ {
    uintptr_t datalen;
 } LDKCVec_PublicKeyZ;
 
+/**
+ * An enum which can either contain a crate::lightning::ln::msgs::NetAddress or not
+ */
+typedef enum LDKCOption_NetAddressZ_Tag {
+   /**
+    * When we're in this state, this COption_NetAddressZ contains a crate::lightning::ln::msgs::NetAddress
+    */
+   LDKCOption_NetAddressZ_Some,
+   /**
+    * When we're in this state, this COption_NetAddressZ contains nothing
+    */
+   LDKCOption_NetAddressZ_None,
+   /**
+    * Must be last for serialization purposes
+    */
+   LDKCOption_NetAddressZ_Sentinel,
+} LDKCOption_NetAddressZ_Tag;
+
+typedef struct LDKCOption_NetAddressZ {
+   LDKCOption_NetAddressZ_Tag tag;
+   union {
+      struct {
+         struct LDKNetAddress some;
+      };
+   };
+} LDKCOption_NetAddressZ;
+
 
 
 /**
@@ -10291,28 +10320,6 @@ typedef struct LDKCResult_ReplyChannelRangeDecodeErrorZ {
    bool result_ok;
 } LDKCResult_ReplyChannelRangeDecodeErrorZ;
 
-
-
-/**
- * A gossip_timestamp_filter message is used by a node to request
- * gossip relay for messages in the requested time range when the
- * gossip_queries feature has been negotiated.
- */
-typedef struct MUST_USE_STRUCT LDKGossipTimestampFilter {
-   /**
-    * 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.
-    */
-   LDKnativeGossipTimestampFilter *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;
-} LDKGossipTimestampFilter;
-
 /**
  * The contents of CResult_GossipTimestampFilterDecodeErrorZ
  */
@@ -11383,7 +11390,7 @@ typedef struct LDKRoutingMessageHandler {
     * perform routing table synchronization using a strategy defined by the
     * implementor.
     */
-   void (*sync_routing_table)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKInit *NONNULL_PTR init);
+   void (*peer_connected)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKInit *NONNULL_PTR init);
    /**
     * Handles the reply of a query we initiated to learn about channels
     * for a given range of blocks. We can expect to receive one or more
@@ -11892,6 +11899,29 @@ typedef struct MUST_USE_STRUCT LDKMultiThreadedLockableScore {
 
 
 
+/**
+ * Parameters for configuring [`ProbabilisticScorer`].
+ *
+ * Used to configure base, liquidity, and amount penalties, the sum of which comprises the channel
+ * penalty (i.e., the amount in msats willing to be paid to avoid routing through the channel).
+ */
+typedef struct MUST_USE_STRUCT LDKProbabilisticScoringParameters {
+   /**
+    * 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.
+    */
+   LDKnativeProbabilisticScoringParameters *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;
+} LDKProbabilisticScoringParameters;
+
+
+
 /**
  * FilesystemPersister persists channel data on disk, where each channel's
  * data is stored in a file named after its funding outpoint.
@@ -11966,11 +11996,9 @@ typedef struct MUST_USE_STRUCT LDKBackgroundProcessor {
 } LDKBackgroundProcessor;
 
 /**
- * Trait which handles persisting a [`ChannelManager`] to disk.
- *
- * [`ChannelManager`]: lightning::ln::channelmanager::ChannelManager
+ * Trait that handles persisting a [`ChannelManager`] and [`NetworkGraph`] to disk.
  */
-typedef struct LDKChannelManagerPersister {
+typedef struct LDKPersister {
    /**
     * 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.
@@ -11978,17 +12006,19 @@ typedef struct LDKChannelManagerPersister {
    void *this_arg;
    /**
     * Persist the given [`ChannelManager`] to disk, returning an error if persistence failed
-    * (which will cause the [`BackgroundProcessor`] which called this method to exit.
-    *
-    * [`ChannelManager`]: lightning::ln::channelmanager::ChannelManager
+    * (which will cause the [`BackgroundProcessor`] which called this method to exit).
     */
    struct LDKCResult_NoneErrorZ (*persist_manager)(const void *this_arg, const struct LDKChannelManager *NONNULL_PTR channel_manager);
+   /**
+    * Persist the given [`NetworkGraph`] to disk, returning an error if persistence failed.
+    */
+   struct LDKCResult_NoneErrorZ (*persist_graph)(const void *this_arg, const struct LDKNetworkGraph *NONNULL_PTR network_graph);
    /**
     * 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);
-} LDKChannelManagerPersister;
+} LDKPersister;
 
 
 
@@ -13327,6 +13357,12 @@ bool CResult_FixedPenaltyScorerDecodeErrorZ_is_ok(const struct LDKCResult_FixedP
  */
 void CResult_FixedPenaltyScorerDecodeErrorZ_free(struct LDKCResult_FixedPenaltyScorerDecodeErrorZ _res);
 
+/**
+ * Creates a new CResult_FixedPenaltyScorerDecodeErrorZ which has the same data as `orig`
+ * but with all dynamically-allocated buffers duplicated in new buffers.
+ */
+struct LDKCResult_FixedPenaltyScorerDecodeErrorZ CResult_FixedPenaltyScorerDecodeErrorZ_clone(const struct LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR orig);
+
 /**
  * Creates a new CResult_ScoringParametersDecodeErrorZ in the success state.
  */
@@ -13347,6 +13383,12 @@ bool CResult_ScoringParametersDecodeErrorZ_is_ok(const struct LDKCResult_Scoring
  */
 void CResult_ScoringParametersDecodeErrorZ_free(struct LDKCResult_ScoringParametersDecodeErrorZ _res);
 
+/**
+ * Creates a new CResult_ScoringParametersDecodeErrorZ which has the same data as `orig`
+ * but with all dynamically-allocated buffers duplicated in new buffers.
+ */
+struct LDKCResult_ScoringParametersDecodeErrorZ CResult_ScoringParametersDecodeErrorZ_clone(const struct LDKCResult_ScoringParametersDecodeErrorZ *NONNULL_PTR orig);
+
 /**
  * Creates a new CResult_ScorerDecodeErrorZ in the success state.
  */
@@ -13367,32 +13409,6 @@ bool CResult_ScorerDecodeErrorZ_is_ok(const struct LDKCResult_ScorerDecodeErrorZ
  */
 void CResult_ScorerDecodeErrorZ_free(struct LDKCResult_ScorerDecodeErrorZ _res);
 
-/**
- * Creates a new CResult_ProbabilisticScoringParametersDecodeErrorZ in the success state.
- */
-struct LDKCResult_ProbabilisticScoringParametersDecodeErrorZ CResult_ProbabilisticScoringParametersDecodeErrorZ_ok(struct LDKProbabilisticScoringParameters o);
-
-/**
- * Creates a new CResult_ProbabilisticScoringParametersDecodeErrorZ in the error state.
- */
-struct LDKCResult_ProbabilisticScoringParametersDecodeErrorZ CResult_ProbabilisticScoringParametersDecodeErrorZ_err(struct LDKDecodeError e);
-
-/**
- * Checks if the given object is currently in the success state
- */
-bool CResult_ProbabilisticScoringParametersDecodeErrorZ_is_ok(const struct LDKCResult_ProbabilisticScoringParametersDecodeErrorZ *NONNULL_PTR o);
-
-/**
- * Frees any resources used by the CResult_ProbabilisticScoringParametersDecodeErrorZ.
- */
-void CResult_ProbabilisticScoringParametersDecodeErrorZ_free(struct LDKCResult_ProbabilisticScoringParametersDecodeErrorZ _res);
-
-/**
- * Creates a new CResult_ProbabilisticScoringParametersDecodeErrorZ which has the same data as `orig`
- * but with all dynamically-allocated buffers duplicated in new buffers.
- */
-struct LDKCResult_ProbabilisticScoringParametersDecodeErrorZ CResult_ProbabilisticScoringParametersDecodeErrorZ_clone(const struct LDKCResult_ProbabilisticScoringParametersDecodeErrorZ *NONNULL_PTR orig);
-
 /**
  * Creates a new CResult_ProbabilisticScorerDecodeErrorZ in the success state.
  */
@@ -14343,6 +14359,12 @@ bool CResult_PhantomRouteHintsDecodeErrorZ_is_ok(const struct LDKCResult_Phantom
  */
 void CResult_PhantomRouteHintsDecodeErrorZ_free(struct LDKCResult_PhantomRouteHintsDecodeErrorZ _res);
 
+/**
+ * Creates a new CResult_PhantomRouteHintsDecodeErrorZ which has the same data as `orig`
+ * but with all dynamically-allocated buffers duplicated in new buffers.
+ */
+struct LDKCResult_PhantomRouteHintsDecodeErrorZ CResult_PhantomRouteHintsDecodeErrorZ_clone(const struct LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR orig);
+
 /**
  * Frees the buffer pointed to by `data` if `datalen` is non-0.
  */
@@ -15098,6 +15120,27 @@ void CVec_NodeAnnouncementZ_free(struct LDKCVec_NodeAnnouncementZ _res);
  */
 void CVec_PublicKeyZ_free(struct LDKCVec_PublicKeyZ _res);
 
+/**
+ * Constructs a new COption_NetAddressZ containing a crate::lightning::ln::msgs::NetAddress
+ */
+struct LDKCOption_NetAddressZ COption_NetAddressZ_some(struct LDKNetAddress o);
+
+/**
+ * Constructs a new COption_NetAddressZ containing nothing
+ */
+struct LDKCOption_NetAddressZ COption_NetAddressZ_none(void);
+
+/**
+ * Frees any resources associated with the crate::lightning::ln::msgs::NetAddress, if we are in the Some state
+ */
+void COption_NetAddressZ_free(struct LDKCOption_NetAddressZ _res);
+
+/**
+ * Creates a new COption_NetAddressZ which has the same data as `orig`
+ * but with all dynamically-allocated buffers duplicated in new buffers.
+ */
+struct LDKCOption_NetAddressZ COption_NetAddressZ_clone(const struct LDKCOption_NetAddressZ *NONNULL_PTR orig);
+
 /**
  * Creates a new CResult_CVec_u8ZPeerHandleErrorZ in the success state.
  */
@@ -16548,7 +16591,7 @@ struct LDKEvent Event_payment_path_successful(struct LDKThirtyTwoBytes payment_i
 /**
  * Utility method to constructs a new OpenChannelRequest-variant Event
  */
-struct LDKEvent Event_open_channel_request(struct LDKThirtyTwoBytes temporary_channel_id, struct LDKPublicKey counterparty_node_id, uint64_t funding_satoshis, uint64_t push_msat);
+struct LDKEvent Event_open_channel_request(struct LDKThirtyTwoBytes temporary_channel_id, struct LDKPublicKey counterparty_node_id, uint64_t funding_satoshis, uint64_t push_msat, struct LDKChannelTypeFeatures channel_type);
 
 /**
  * Serialize the Event object into a byte array which can be read by Event_read
@@ -16665,6 +16708,11 @@ struct LDKMessageSendEvent MessageSendEvent_send_short_ids_query(struct LDKPubli
  */
 struct LDKMessageSendEvent MessageSendEvent_send_reply_channel_range(struct LDKPublicKey node_id, struct LDKReplyChannelRange msg);
 
+/**
+ * Utility method to constructs a new SendGossipTimestampFilter-variant MessageSendEvent
+ */
+struct LDKMessageSendEvent MessageSendEvent_send_gossip_timestamp_filter(struct LDKPublicKey node_id, struct LDKGossipTimestampFilter msg);
+
 /**
  * Calls the free function if one is set
  */
@@ -16942,10 +16990,60 @@ uint64_t ChannelHandshakeConfig_get_our_htlc_minimum_msat(const struct LDKChanne
  */
 void ChannelHandshakeConfig_set_our_htlc_minimum_msat(struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr, uint64_t val);
 
+/**
+ * If set, we attempt to negotiate the `scid_privacy` (referred to as `scid_alias` in the
+ * BOLTs) option for outbound private channels. This provides better privacy by not including
+ * our real on-chain channel UTXO in each invoice and requiring that our counterparty only
+ * relay HTLCs to us using the channel's SCID alias.
+ *
+ * If this option is set, channels may be created that will not be readable by LDK versions
+ * prior to 0.0.106, causing [`ChannelManager`]'s read method to return a
+ * [`DecodeError:InvalidValue`].
+ *
+ * Note that setting this to true does *not* prevent us from opening channels with
+ * counterparties that do not support the `scid_alias` option; we will simply fall back to a
+ * private channel without that option.
+ *
+ * Ignored if the channel is negotiated to be announced, see
+ * [`ChannelConfig::announced_channel`] and
+ * [`ChannelHandshakeLimits::force_announced_channel_preference`] for more.
+ *
+ * Default value: false. This value is likely to change to true in the future.
+ *
+ * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
+ * [`DecodeError:InvalidValue`]: crate::ln::msgs::DecodeError::InvalidValue
+ */
+bool ChannelHandshakeConfig_get_negotiate_scid_privacy(const struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr);
+
+/**
+ * If set, we attempt to negotiate the `scid_privacy` (referred to as `scid_alias` in the
+ * BOLTs) option for outbound private channels. This provides better privacy by not including
+ * our real on-chain channel UTXO in each invoice and requiring that our counterparty only
+ * relay HTLCs to us using the channel's SCID alias.
+ *
+ * If this option is set, channels may be created that will not be readable by LDK versions
+ * prior to 0.0.106, causing [`ChannelManager`]'s read method to return a
+ * [`DecodeError:InvalidValue`].
+ *
+ * Note that setting this to true does *not* prevent us from opening channels with
+ * counterparties that do not support the `scid_alias` option; we will simply fall back to a
+ * private channel without that option.
+ *
+ * Ignored if the channel is negotiated to be announced, see
+ * [`ChannelConfig::announced_channel`] and
+ * [`ChannelHandshakeLimits::force_announced_channel_preference`] for more.
+ *
+ * Default value: false. This value is likely to change to true in the future.
+ *
+ * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
+ * [`DecodeError:InvalidValue`]: crate::ln::msgs::DecodeError::InvalidValue
+ */
+void ChannelHandshakeConfig_set_negotiate_scid_privacy(struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr, bool val);
+
 /**
  * Constructs a new ChannelHandshakeConfig given each field
  */
-MUST_USE_RES struct LDKChannelHandshakeConfig ChannelHandshakeConfig_new(uint32_t minimum_depth_arg, uint16_t our_to_self_delay_arg, uint64_t our_htlc_minimum_msat_arg);
+MUST_USE_RES struct LDKChannelHandshakeConfig ChannelHandshakeConfig_new(uint32_t minimum_depth_arg, uint16_t our_to_self_delay_arg, uint64_t our_htlc_minimum_msat_arg, bool negotiate_scid_privacy_arg);
 
 /**
  * Creates a copy of the ChannelHandshakeConfig
@@ -18915,18 +19013,74 @@ struct LDKOutPoint ChannelDetails_get_funding_txo(const struct LDKChannelDetails
  */
 void ChannelDetails_set_funding_txo(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKOutPoint val);
 
+/**
+ * The features which this channel operates with. See individual features for more info.
+ *
+ * `None` until negotiation completes and the channel type is finalized.
+ *
+ * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
+ */
+struct LDKChannelTypeFeatures ChannelDetails_get_channel_type(const struct LDKChannelDetails *NONNULL_PTR this_ptr);
+
+/**
+ * The features which this channel operates with. See individual features for more info.
+ *
+ * `None` until negotiation completes and the channel type is finalized.
+ *
+ * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
+ */
+void ChannelDetails_set_channel_type(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKChannelTypeFeatures 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.
+ *
+ * Note that if [`inbound_scid_alias`] is set, it must be used for invoices and inbound
+ * payments instead of this. See [`get_inbound_payment_scid`].
+ *
+ * [`inbound_scid_alias`]: Self::inbound_scid_alias
+ * [`get_inbound_payment_scid`]: Self::get_inbound_payment_scid
  */
 struct LDKCOption_u64Z ChannelDetails_get_short_channel_id(const struct LDKChannelDetails *NONNULL_PTR this_ptr);
 
 /**
  * The position of the funding transaction in the chain. None if the funding transaction has
  * not yet been confirmed and the channel fully opened.
+ *
+ * Note that if [`inbound_scid_alias`] is set, it must be used for invoices and inbound
+ * payments instead of this. See [`get_inbound_payment_scid`].
+ *
+ * [`inbound_scid_alias`]: Self::inbound_scid_alias
+ * [`get_inbound_payment_scid`]: Self::get_inbound_payment_scid
  */
 void ChannelDetails_set_short_channel_id(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val);
 
+/**
+ * An optional [`short_channel_id`] alias for this channel, randomly generated by our
+ * counterparty and usable in place of [`short_channel_id`] in invoice route hints. Our
+ * counterparty will recognize the alias provided here in place of the [`short_channel_id`]
+ * when they see a payment to be routed to us.
+ *
+ * Our counterparty may choose to rotate this value at any time, though will always recognize
+ * previous values for inbound payment forwarding.
+ *
+ * [`short_channel_id`]: Self::short_channel_id
+ */
+struct LDKCOption_u64Z ChannelDetails_get_inbound_scid_alias(const struct LDKChannelDetails *NONNULL_PTR this_ptr);
+
+/**
+ * An optional [`short_channel_id`] alias for this channel, randomly generated by our
+ * counterparty and usable in place of [`short_channel_id`] in invoice route hints. Our
+ * counterparty will recognize the alias provided here in place of the [`short_channel_id`]
+ * when they see a payment to be routed to us.
+ *
+ * Our counterparty may choose to rotate this value at any time, though will always recognize
+ * previous values for inbound payment forwarding.
+ *
+ * [`short_channel_id`]: Self::short_channel_id
+ */
+void ChannelDetails_set_inbound_scid_alias(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val);
+
 /**
  * The value, in satoshis, of this channel as appears in the funding output
  */
@@ -19168,13 +19322,23 @@ void ChannelDetails_set_is_public(struct LDKChannelDetails *NONNULL_PTR this_ptr
 /**
  * Constructs a new ChannelDetails given each field
  */
-MUST_USE_RES struct LDKChannelDetails ChannelDetails_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKChannelCounterparty counterparty_arg, struct LDKOutPoint funding_txo_arg, struct LDKCOption_u64Z short_channel_id_arg, uint64_t channel_value_satoshis_arg, struct LDKCOption_u64Z unspendable_punishment_reserve_arg, uint64_t user_channel_id_arg, uint64_t balance_msat_arg, uint64_t outbound_capacity_msat_arg, uint64_t inbound_capacity_msat_arg, struct LDKCOption_u32Z confirmations_required_arg, struct LDKCOption_u16Z force_close_spend_delay_arg, bool is_outbound_arg, bool is_funding_locked_arg, bool is_usable_arg, bool is_public_arg);
+MUST_USE_RES struct LDKChannelDetails ChannelDetails_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKChannelCounterparty counterparty_arg, struct LDKOutPoint funding_txo_arg, struct LDKChannelTypeFeatures channel_type_arg, struct LDKCOption_u64Z short_channel_id_arg, struct LDKCOption_u64Z inbound_scid_alias_arg, uint64_t channel_value_satoshis_arg, struct LDKCOption_u64Z unspendable_punishment_reserve_arg, uint64_t user_channel_id_arg, uint64_t balance_msat_arg, uint64_t outbound_capacity_msat_arg, uint64_t inbound_capacity_msat_arg, struct LDKCOption_u32Z confirmations_required_arg, struct LDKCOption_u16Z force_close_spend_delay_arg, bool is_outbound_arg, bool is_funding_locked_arg, bool is_usable_arg, bool is_public_arg);
 
 /**
  * Creates a copy of the ChannelDetails
  */
 struct LDKChannelDetails ChannelDetails_clone(const struct LDKChannelDetails *NONNULL_PTR orig);
 
+/**
+ * Gets the current SCID which should be used to identify this channel for inbound payments.
+ * This should be used for providing invoice hints or in any other context where our
+ * counterparty will forward a payment to us.
+ *
+ * This is either the [`ChannelDetails::inbound_scid_alias`], if set, or the
+ * [`ChannelDetails::short_channel_id`]. See those for more information.
+ */
+MUST_USE_RES struct LDKCOption_u64Z ChannelDetails_get_inbound_payment_scid(const struct LDKChannelDetails *NONNULL_PTR this_arg);
+
 /**
  * Frees any resources used by the PaymentSendFailure
  */
@@ -19247,6 +19411,11 @@ void PhantomRouteHints_set_real_node_pubkey(struct LDKPhantomRouteHints *NONNULL
  */
 MUST_USE_RES struct LDKPhantomRouteHints PhantomRouteHints_new(struct LDKCVec_ChannelDetailsZ channels_arg, uint64_t phantom_scid_arg, struct LDKPublicKey real_node_pubkey_arg);
 
+/**
+ * Creates a copy of the PhantomRouteHints
+ */
+struct LDKPhantomRouteHints PhantomRouteHints_clone(const struct LDKPhantomRouteHints *NONNULL_PTR orig);
+
 /**
  * Constructs a new ChannelManager to hold several channels and route between them.
  *
@@ -19578,9 +19747,14 @@ MUST_USE_RES struct LDKPublicKey ChannelManager_get_our_node_id(const struct LDK
  *
  * The `temporary_channel_id` parameter indicates which inbound channel should be accepted.
  *
- * [`Event::OpenChannelRequest`]: crate::util::events::Event::OpenChannelRequest
+ * For inbound channels, the `user_channel_id` parameter will be provided back in
+ * [`Event::ChannelClosed::user_channel_id`] to allow tracking of which events correspond
+ * with which `accept_inbound_channel` call.
+ *
+ * [`Event::OpenChannelRequest`]: events::Event::OpenChannelRequest
+ * [`Event::ChannelClosed::user_channel_id`]: events::Event::ChannelClosed::user_channel_id
  */
-MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_accept_inbound_channel(const struct LDKChannelManager *NONNULL_PTR this_arg, const uint8_t (*temporary_channel_id)[32]);
+MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_accept_inbound_channel(const struct LDKChannelManager *NONNULL_PTR this_arg, const uint8_t (*temporary_channel_id)[32], uint64_t user_channel_id);
 
 /**
  * Gets a payment secret and payment hash for use in an invoice given to a third party wishing
@@ -19616,6 +19790,8 @@ MUST_USE_RES struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ ChannelMan
  * Legacy version of [`create_inbound_payment`]. Use this method if you wish to share
  * serialized state with LDK node(s) running 0.0.103 and earlier.
  *
+ * May panic if `invoice_expiry_delta_secs` is greater than one year.
+ *
  * # Note
  * This method is deprecated and will be removed soon.
  *
@@ -19652,8 +19828,6 @@ MUST_USE_RES struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ Channe
  * If you need exact expiry semantics, you should enforce them upon receipt of
  * [`PaymentReceived`].
  *
- * May panic if `invoice_expiry_delta_secs` is greater than one year.
- *
  * Note that invoices generated for inbound payments should have their `min_final_cltv_expiry`
  * set to at least [`MIN_FINAL_CLTV_EXPIRY`].
  *
@@ -19676,6 +19850,8 @@ MUST_USE_RES struct LDKCResult_PaymentSecretNoneZ ChannelManager_create_inbound_
  * Legacy version of [`create_inbound_payment_for_hash`]. Use this method if you wish to share
  * serialized state with LDK node(s) running 0.0.103 and earlier.
  *
+ * May panic if `invoice_expiry_delta_secs` is greater than one year.
+ *
  * # Note
  * This method is deprecated and will be removed soon.
  *
@@ -19930,10 +20106,26 @@ struct LDKInitFeatures Init_get_features(const struct LDKInit *NONNULL_PTR this_
  */
 void Init_set_features(struct LDKInit *NONNULL_PTR this_ptr, struct LDKInitFeatures val);
 
+/**
+ * The receipient's network address. This adds the option to report a remote IP address
+ * back to a connecting peer using the init message. A node can decide to use that information
+ * to discover a potential update to its public IPv4 address (NAT) and use
+ * that for a node_announcement update message containing the new address.
+ */
+struct LDKCOption_NetAddressZ Init_get_remote_network_address(const struct LDKInit *NONNULL_PTR this_ptr);
+
+/**
+ * The receipient's network address. This adds the option to report a remote IP address
+ * back to a connecting peer using the init message. A node can decide to use that information
+ * to discover a potential update to its public IPv4 address (NAT) and use
+ * that for a node_announcement update message containing the new address.
+ */
+void Init_set_remote_network_address(struct LDKInit *NONNULL_PTR this_ptr, struct LDKCOption_NetAddressZ val);
+
 /**
  * Constructs a new Init given each field
  */
-MUST_USE_RES struct LDKInit Init_new(struct LDKInitFeatures features_arg);
+MUST_USE_RES struct LDKInit Init_new(struct LDKInitFeatures features_arg, struct LDKCOption_NetAddressZ remote_network_address_arg);
 
 /**
  * Creates a copy of the Init
@@ -20591,10 +20783,22 @@ struct LDKPublicKey FundingLocked_get_next_per_commitment_point(const struct LDK
  */
 void FundingLocked_set_next_per_commitment_point(struct LDKFundingLocked *NONNULL_PTR this_ptr, struct LDKPublicKey val);
 
+/**
+ * If set, provides a short_channel_id alias for this channel. The sender will accept payments
+ * to be forwarded over this SCID and forward them to this messages' recipient.
+ */
+struct LDKCOption_u64Z FundingLocked_get_short_channel_id_alias(const struct LDKFundingLocked *NONNULL_PTR this_ptr);
+
+/**
+ * If set, provides a short_channel_id alias for this channel. The sender will accept payments
+ * to be forwarded over this SCID and forward them to this messages' recipient.
+ */
+void FundingLocked_set_short_channel_id_alias(struct LDKFundingLocked *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val);
+
 /**
  * Constructs a new FundingLocked given each field
  */
-MUST_USE_RES struct LDKFundingLocked FundingLocked_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKPublicKey next_per_commitment_point_arg);
+MUST_USE_RES struct LDKFundingLocked FundingLocked_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKPublicKey next_per_commitment_point_arg, struct LDKCOption_u64Z short_channel_id_alias_arg);
 
 /**
  * Creates a copy of the FundingLocked
@@ -22473,7 +22677,13 @@ MUST_USE_RES struct LDKPeerManager PeerManager_new(struct LDKMessageHandler mess
 MUST_USE_RES struct LDKCVec_PublicKeyZ PeerManager_get_peer_node_ids(const struct LDKPeerManager *NONNULL_PTR this_arg);
 
 /**
- * Indicates a new outbound connection has been established to a node with the given node_id.
+ * Indicates a new outbound connection has been established to a node with the given node_id
+ * and an optional remote network address.
+ *
+ * The remote network address adds the option to report a remote IP address back to a connecting
+ * peer using the init message.
+ * The user should pass the remote network address of the host they are connected to.
+ *
  * Note that if an Err is returned here you MUST NOT call socket_disconnected for the new
  * descriptor but must disconnect the connection immediately.
  *
@@ -22484,10 +22694,15 @@ MUST_USE_RES struct LDKCVec_PublicKeyZ PeerManager_get_peer_node_ids(const struc
  *
  * [`socket_disconnected()`]: PeerManager::socket_disconnected
  */
-MUST_USE_RES struct LDKCResult_CVec_u8ZPeerHandleErrorZ PeerManager_new_outbound_connection(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKPublicKey their_node_id, struct LDKSocketDescriptor descriptor);
+MUST_USE_RES struct LDKCResult_CVec_u8ZPeerHandleErrorZ PeerManager_new_outbound_connection(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKPublicKey their_node_id, struct LDKSocketDescriptor descriptor, struct LDKCOption_NetAddressZ remote_network_address);
 
 /**
- * Indicates a new inbound connection has been established.
+ * Indicates a new inbound connection has been established to a node with an optional remote
+ * network address.
+ *
+ * The remote network address adds the option to report a remote IP address back to a connecting
+ * peer using the init message.
+ * The user should pass the remote network address of the host they are connected to.
  *
  * May refuse the connection by returning an Err, but will never write bytes to the remote end
  * (outbound connector always speaks first). Note that if an Err is returned here you MUST NOT
@@ -22499,7 +22714,7 @@ MUST_USE_RES struct LDKCResult_CVec_u8ZPeerHandleErrorZ PeerManager_new_outbound
  *
  * [`socket_disconnected()`]: PeerManager::socket_disconnected
  */
-MUST_USE_RES struct LDKCResult_NonePeerHandleErrorZ PeerManager_new_inbound_connection(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKSocketDescriptor descriptor);
+MUST_USE_RES struct LDKCResult_NonePeerHandleErrorZ PeerManager_new_inbound_connection(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKSocketDescriptor descriptor, struct LDKCOption_NetAddressZ remote_network_address);
 
 /**
  * Indicates that there is room to write data to the given socket descriptor.
@@ -22581,9 +22796,9 @@ void PeerManager_disconnect_all_peers(const struct LDKPeerManager *NONNULL_PTR t
  * Send pings to each peer and disconnect those which did not respond to the last round of
  * pings.
  *
- * This may be called on any timescale you want, however, roughly once every five to ten
- * seconds is preferred. The call rate determines both how often we send a ping to our peers
- * and how much time they have to respond before we disconnect them.
+ * This may be called on any timescale you want, however, roughly once every ten seconds is
+ * preferred. The call rate determines both how often we send a ping to our peers and how much
+ * time they have to respond before we disconnect them.
  *
  * May call [`send_data`] on all [`SocketDescriptor`]s. Thus, be very careful with reentrancy
  * issues!
@@ -25125,7 +25340,7 @@ struct LDKCResult_RouteHintHopDecodeErrorZ RouteHintHop_read(struct LDKu8slice s
  *
  * Note that first_hops (or a relevant inner pointer) may be NULL or all-0s to represent None
  */
-struct LDKCResult_RouteLightningErrorZ find_route(struct LDKPublicKey our_node_pubkey, const struct LDKRouteParameters *NONNULL_PTR route_params, const struct LDKNetworkGraph *NONNULL_PTR network, struct LDKCVec_ChannelDetailsZ *first_hops, struct LDKLogger logger, const struct LDKScore *NONNULL_PTR scorer);
+struct LDKCResult_RouteLightningErrorZ find_route(struct LDKPublicKey our_node_pubkey, const struct LDKRouteParameters *NONNULL_PTR route_params, const struct LDKNetworkGraph *NONNULL_PTR network, struct LDKCVec_ChannelDetailsZ *first_hops, struct LDKLogger logger, const struct LDKScore *NONNULL_PTR scorer, const uint8_t (*random_seed_bytes)[32]);
 
 /**
  * Calls the free function if one is set
@@ -25153,14 +25368,9 @@ MUST_USE_RES struct LDKMultiThreadedLockableScore MultiThreadedLockableScore_new
 void FixedPenaltyScorer_free(struct LDKFixedPenaltyScorer this_obj);
 
 /**
- * Serialize the FixedPenaltyScorer object into a byte array which can be read by FixedPenaltyScorer_read
+ * Creates a copy of the FixedPenaltyScorer
  */
-struct LDKCVec_u8Z FixedPenaltyScorer_write(const struct LDKFixedPenaltyScorer *NONNULL_PTR obj);
-
-/**
- * Read a FixedPenaltyScorer from a byte array, created by FixedPenaltyScorer_write
- */
-struct LDKCResult_FixedPenaltyScorerDecodeErrorZ FixedPenaltyScorer_read(struct LDKu8slice ser);
+struct LDKFixedPenaltyScorer FixedPenaltyScorer_clone(const struct LDKFixedPenaltyScorer *NONNULL_PTR orig);
 
 /**
  * Creates a new scorer using `penalty_msat`.
@@ -25173,6 +25383,16 @@ MUST_USE_RES struct LDKFixedPenaltyScorer FixedPenaltyScorer_with_penalty(uint64
  */
 struct LDKScore FixedPenaltyScorer_as_Score(const struct LDKFixedPenaltyScorer *NONNULL_PTR this_arg);
 
+/**
+ * Serialize the FixedPenaltyScorer object into a byte array which can be read by FixedPenaltyScorer_read
+ */
+struct LDKCVec_u8Z FixedPenaltyScorer_write(const struct LDKFixedPenaltyScorer *NONNULL_PTR obj);
+
+/**
+ * Read a FixedPenaltyScorer from a byte array, created by FixedPenaltyScorer_write
+ */
+struct LDKCResult_FixedPenaltyScorerDecodeErrorZ FixedPenaltyScorer_read(struct LDKu8slice ser, uint64_t arg);
+
 /**
  * Frees any resources used by the Scorer, if is_owned is set and inner is non-NULL.
  */
@@ -25302,6 +25522,11 @@ void ScoringParameters_set_failure_penalty_half_life(struct LDKScoringParameters
  */
 MUST_USE_RES struct LDKScoringParameters ScoringParameters_new(uint64_t base_penalty_msat_arg, uint64_t failure_penalty_msat_arg, uint16_t overuse_penalty_start_1024th_arg, uint64_t overuse_penalty_msat_per_1024th_arg, uint64_t failure_penalty_half_life_arg);
 
+/**
+ * Creates a copy of the ScoringParameters
+ */
+struct LDKScoringParameters ScoringParameters_clone(const struct LDKScoringParameters *NONNULL_PTR orig);
+
 /**
  * Serialize the ScoringParameters object into a byte array which can be read by ScoringParameters_read
  */
@@ -25354,34 +25579,48 @@ void ProbabilisticScorer_free(struct LDKProbabilisticScorer this_obj);
 void ProbabilisticScoringParameters_free(struct LDKProbabilisticScoringParameters this_obj);
 
 /**
- * A multiplier used to determine the amount in msats willing to be paid to avoid routing
- * through a channel, as per multiplying by the negative `log10` of the channel's success
- * probability for a payment.
+ * A fixed penalty in msats to apply to each channel.
  *
- * The success probability is determined by the effective channel capacity, the payment amount,
- * and knowledge learned from prior successful and unsuccessful payments. The lower bound of
- * the success probability is 0.01, effectively limiting the penalty to the range
- * `0..=2*liquidity_penalty_multiplier_msat`. The knowledge learned is decayed over time based
- * on [`liquidity_offset_half_life`].
+ * Default value: 500 msat
+ */
+uint64_t ProbabilisticScoringParameters_get_base_penalty_msat(const struct LDKProbabilisticScoringParameters *NONNULL_PTR this_ptr);
+
+/**
+ * A fixed penalty in msats to apply to each channel.
  *
- * Default value: 10,000 msat
+ * Default value: 500 msat
+ */
+void ProbabilisticScoringParameters_set_base_penalty_msat(struct LDKProbabilisticScoringParameters *NONNULL_PTR this_ptr, uint64_t val);
+
+/**
+ * A multiplier used in conjunction with the negative `log10` of the channel's success
+ * probability for a payment to determine the liquidity penalty.
+ *
+ * The penalty is based in part on the knowledge learned from prior successful and unsuccessful
+ * payments. This knowledge is decayed over time based on [`liquidity_offset_half_life`]. The
+ * penalty is effectively limited to `2 * liquidity_penalty_multiplier_msat` (corresponding to
+ * lower bounding the success probability to `0.01`) when the amount falls within the
+ * uncertainty bounds of the channel liquidity balance. Amounts above the upper bound will
+ * result in a `u64::max_value` penalty, however.
+ *
+ * Default value: 40,000 msat
  *
  * [`liquidity_offset_half_life`]: Self::liquidity_offset_half_life
  */
 uint64_t ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat(const struct LDKProbabilisticScoringParameters *NONNULL_PTR this_ptr);
 
 /**
- * A multiplier used to determine the amount in msats willing to be paid to avoid routing
- * through a channel, as per multiplying by the negative `log10` of the channel's success
- * probability for a payment.
+ * A multiplier used in conjunction with the negative `log10` of the channel's success
+ * probability for a payment to determine the liquidity penalty.
  *
- * The success probability is determined by the effective channel capacity, the payment amount,
- * and knowledge learned from prior successful and unsuccessful payments. The lower bound of
- * the success probability is 0.01, effectively limiting the penalty to the range
- * `0..=2*liquidity_penalty_multiplier_msat`. The knowledge learned is decayed over time based
- * on [`liquidity_offset_half_life`].
+ * The penalty is based in part on the knowledge learned from prior successful and unsuccessful
+ * payments. This knowledge is decayed over time based on [`liquidity_offset_half_life`]. The
+ * penalty is effectively limited to `2 * liquidity_penalty_multiplier_msat` (corresponding to
+ * lower bounding the success probability to `0.01`) when the amount falls within the
+ * uncertainty bounds of the channel liquidity balance. Amounts above the upper bound will
+ * result in a `u64::max_value` penalty, however.
  *
- * Default value: 10,000 msat
+ * Default value: 40,000 msat
  *
  * [`liquidity_offset_half_life`]: Self::liquidity_offset_half_life
  */
@@ -25422,24 +25661,56 @@ uint64_t ProbabilisticScoringParameters_get_liquidity_offset_half_life(const str
 void ProbabilisticScoringParameters_set_liquidity_offset_half_life(struct LDKProbabilisticScoringParameters *NONNULL_PTR this_ptr, uint64_t val);
 
 /**
- * Constructs a new ProbabilisticScoringParameters given each field
+ * A multiplier used in conjunction with a payment amount and the negative `log10` of the
+ * channel's success probability for the payment to determine the amount penalty.
+ *
+ * The purpose of the amount penalty is to avoid having fees dominate the channel cost (i.e.,
+ * fees plus penalty) for large payments. The penalty is computed as the product of this
+ * multiplier and `2^20`ths of the payment amount, weighted by the negative `log10` of the
+ * success probability.
+ *
+ * `-log10(success_probability) * amount_penalty_multiplier_msat * amount_msat / 2^20`
+ *
+ * In practice, this means for 0.1 success probability (`-log10(0.1) == 1`) each `2^20`th of
+ * the amount will result in a penalty of the multiplier. And, as the success probability
+ * decreases, the negative `log10` weighting will increase dramatically. For higher success
+ * probabilities, the multiplier will have a decreasing effect as the negative `log10` will
+ * fall below `1`.
+ *
+ * Default value: 256 msat
  */
-MUST_USE_RES struct LDKProbabilisticScoringParameters ProbabilisticScoringParameters_new(uint64_t liquidity_penalty_multiplier_msat_arg, uint64_t liquidity_offset_half_life_arg);
+uint64_t ProbabilisticScoringParameters_get_amount_penalty_multiplier_msat(const struct LDKProbabilisticScoringParameters *NONNULL_PTR this_ptr);
 
 /**
- * Creates a copy of the ProbabilisticScoringParameters
+ * A multiplier used in conjunction with a payment amount and the negative `log10` of the
+ * channel's success probability for the payment to determine the amount penalty.
+ *
+ * The purpose of the amount penalty is to avoid having fees dominate the channel cost (i.e.,
+ * fees plus penalty) for large payments. The penalty is computed as the product of this
+ * multiplier and `2^20`ths of the payment amount, weighted by the negative `log10` of the
+ * success probability.
+ *
+ * `-log10(success_probability) * amount_penalty_multiplier_msat * amount_msat / 2^20`
+ *
+ * In practice, this means for 0.1 success probability (`-log10(0.1) == 1`) each `2^20`th of
+ * the amount will result in a penalty of the multiplier. And, as the success probability
+ * decreases, the negative `log10` weighting will increase dramatically. For higher success
+ * probabilities, the multiplier will have a decreasing effect as the negative `log10` will
+ * fall below `1`.
+ *
+ * Default value: 256 msat
  */
-struct LDKProbabilisticScoringParameters ProbabilisticScoringParameters_clone(const struct LDKProbabilisticScoringParameters *NONNULL_PTR orig);
+void ProbabilisticScoringParameters_set_amount_penalty_multiplier_msat(struct LDKProbabilisticScoringParameters *NONNULL_PTR this_ptr, uint64_t val);
 
 /**
- * Serialize the ProbabilisticScoringParameters object into a byte array which can be read by ProbabilisticScoringParameters_read
+ * Constructs a new ProbabilisticScoringParameters given each field
  */
-struct LDKCVec_u8Z ProbabilisticScoringParameters_write(const struct LDKProbabilisticScoringParameters *NONNULL_PTR obj);
+MUST_USE_RES struct LDKProbabilisticScoringParameters ProbabilisticScoringParameters_new(uint64_t base_penalty_msat_arg, uint64_t liquidity_penalty_multiplier_msat_arg, uint64_t liquidity_offset_half_life_arg, uint64_t amount_penalty_multiplier_msat_arg);
 
 /**
- * Read a ProbabilisticScoringParameters from a byte array, created by ProbabilisticScoringParameters_write
+ * Creates a copy of the ProbabilisticScoringParameters
  */
-struct LDKCResult_ProbabilisticScoringParametersDecodeErrorZ ProbabilisticScoringParameters_read(struct LDKu8slice ser);
+struct LDKProbabilisticScoringParameters ProbabilisticScoringParameters_clone(const struct LDKProbabilisticScoringParameters *NONNULL_PTR orig);
 
 /**
  * Creates a new scorer using the given scoring parameters for sending payments from a node
@@ -25490,6 +25761,12 @@ MUST_USE_RES struct LDKStr FilesystemPersister_get_data_dir(const struct LDKFile
  */
 MUST_USE_RES struct LDKCResult_NoneErrorZ FilesystemPersister_persist_manager(struct LDKStr data_dir, const struct LDKChannelManager *NONNULL_PTR manager);
 
+/**
+ * Write the provided `NetworkGraph` to the path provided at `FilesystemPersister`
+ * initialization, within a file called \"network_graph\"
+ */
+MUST_USE_RES struct LDKCResult_NoneErrorZ FilesystemPersister_persist_network_graph(struct LDKStr data_dir, const struct LDKNetworkGraph *NONNULL_PTR network_graph);
+
 /**
  * Read `ChannelMonitor`s from disk.
  */
@@ -25509,24 +25786,28 @@ void BackgroundProcessor_free(struct LDKBackgroundProcessor this_obj);
 /**
  * Calls the free function if one is set
  */
-void ChannelManagerPersister_free(struct LDKChannelManagerPersister this_ptr);
+void Persister_free(struct LDKPersister this_ptr);
 
 /**
  * Start a background thread that takes care of responsibilities enumerated in the [top-level
  * documentation].
  *
  * The thread runs indefinitely unless the object is dropped, [`stop`] is called, or
- * `persist_manager` returns an error. In case of an error, the error is retrieved by calling
+ * [`Persister::persist_manager`] returns an error. In case of an error, the error is retrieved by calling
  * either [`join`] or [`stop`].
  *
  * # Data Persistence
  *
- * `persist_manager` is responsible for writing out the [`ChannelManager`] to disk, and/or
+ * [`Persister::persist_manager`] is responsible for writing out the [`ChannelManager`] to disk, and/or
  * uploading to one or more backup services. See [`ChannelManager::write`] for writing out a
  * [`ChannelManager`]. See [`FilesystemPersister::persist_manager`] for Rust-Lightning's
  * provided implementation.
  *
- * Typically, users should either implement [`ChannelManagerPersister`] to never return an
+ * [`Persister::persist_graph`] is responsible for writing out the [`NetworkGraph`] to disk. See
+ * [`NetworkGraph::write`] for writing out a [`NetworkGraph`]. See [`FilesystemPersister::persist_network_graph`]
+ * for Rust-Lightning's provided implementation.
+ *
+ * Typically, users should either implement [`Persister::persist_manager`] to never return an
  * error or call [`join`] and handle any error that may arise. For the latter case,
  * `BackgroundProcessor` must be restarted by calling `start` again after handling the error.
  *
@@ -25543,11 +25824,13 @@ void ChannelManagerPersister_free(struct LDKChannelManagerPersister this_ptr);
  * [`ChannelManager`]: lightning::ln::channelmanager::ChannelManager
  * [`ChannelManager::write`]: lightning::ln::channelmanager::ChannelManager#impl-Writeable
  * [`FilesystemPersister::persist_manager`]: lightning_persister::FilesystemPersister::persist_manager
+ * [`FilesystemPersister::persist_network_graph`]: lightning_persister::FilesystemPersister::persist_network_graph
  * [`NetworkGraph`]: lightning::routing::network_graph::NetworkGraph
+ * [`NetworkGraph::write`]: lightning::routing::network_graph::NetworkGraph#impl-Writeable
  *
  * Note that net_graph_msg_handler (or a relevant inner pointer) may be NULL or all-0s to represent None
  */
-MUST_USE_RES struct LDKBackgroundProcessor BackgroundProcessor_start(struct LDKChannelManagerPersister persister, struct LDKEventHandler event_handler, const struct LDKChainMonitor *NONNULL_PTR chain_monitor, const struct LDKChannelManager *NONNULL_PTR channel_manager, struct LDKNetGraphMsgHandler net_graph_msg_handler, const struct LDKPeerManager *NONNULL_PTR peer_manager, struct LDKLogger logger);
+MUST_USE_RES struct LDKBackgroundProcessor BackgroundProcessor_start(struct LDKPersister persister, struct LDKEventHandler event_handler, const struct LDKChainMonitor *NONNULL_PTR chain_monitor, const struct LDKChannelManager *NONNULL_PTR channel_manager, struct LDKNetGraphMsgHandler net_graph_msg_handler, const struct LDKPeerManager *NONNULL_PTR peer_manager, struct LDKLogger logger);
 
 /**
  * Join `BackgroundProcessor`'s thread, returning any error that occurred while persisting
@@ -26537,6 +26820,36 @@ struct LDKEventHandler InvoicePayer_as_EventHandler(const struct LDKInvoicePayer
  */
 struct LDKCResult_InvoiceSignOrCreationErrorZ create_phantom_invoice(struct LDKCOption_u64Z amt_msat, struct LDKStr description, struct LDKThirtyTwoBytes payment_hash, struct LDKThirtyTwoBytes payment_secret, struct LDKCVec_PhantomRouteHintsZ phantom_route_hints, struct LDKKeysInterface keys_manager, enum LDKCurrency network);
 
+/**
+ * Utility to create an invoice that can be paid to one of multiple nodes, or a \"phantom invoice.\"
+ * See [`PhantomKeysManager`] for more information on phantom node payments.
+ *
+ * `phantom_route_hints` parameter:
+ * * Contains channel info for all nodes participating in the phantom invoice
+ * * Entries are retrieved from a call to [`ChannelManager::get_phantom_route_hints`] on each
+ *   participating node
+ * * It is fine to cache `phantom_route_hints` and reuse it across invoices, as long as the data is
+ *   updated when a channel becomes disabled or closes
+ * * Note that if too many channels are included in [`PhantomRouteHints::channels`], the invoice
+ *   may be too long for QR code scanning. To fix this, `PhantomRouteHints::channels` may be pared
+ *   down
+ *
+ * `description_hash` is a SHA-256 hash of the description text
+ *
+ * `payment_hash` and `payment_secret` come from [`ChannelManager::create_inbound_payment`] or
+ * [`ChannelManager::create_inbound_payment_for_hash`]. These values can be retrieved from any
+ * participating node.
+ *
+ * Note that the provided `keys_manager`'s `KeysInterface` implementation must support phantom
+ * invoices in its `sign_invoice` implementation ([`PhantomKeysManager`] satisfies this
+ * requirement).
+ *
+ * [`PhantomKeysManager`]: lightning::chain::keysinterface::PhantomKeysManager
+ * [`ChannelManager::get_phantom_route_hints`]: lightning::ln::channelmanager::ChannelManager::get_phantom_route_hints
+ * [`PhantomRouteHints::channels`]: lightning::ln::channelmanager::PhantomRouteHints::channels
+ */
+struct LDKCResult_InvoiceSignOrCreationErrorZ create_phantom_invoice_with_description_hash(struct LDKCOption_u64Z amt_msat, struct LDKSha256 description_hash, struct LDKThirtyTwoBytes payment_hash, struct LDKThirtyTwoBytes payment_secret, struct LDKCVec_PhantomRouteHintsZ phantom_route_hints, struct LDKKeysInterface keys_manager, enum LDKCurrency network);
+
 /**
  * Utility to construct an invoice. Generally, unless you want to do something like a custom
  * cltv_expiry, this is what you should be using to create an invoice. The reason being, this
@@ -26546,6 +26859,23 @@ struct LDKCResult_InvoiceSignOrCreationErrorZ create_phantom_invoice(struct LDKC
  */
 struct LDKCResult_InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager(const struct LDKChannelManager *NONNULL_PTR channelmanager, struct LDKKeysInterface keys_manager, enum LDKCurrency network, struct LDKCOption_u64Z amt_msat, struct LDKStr description);
 
+/**
+ * Utility to construct an invoice. Generally, unless you want to do something like a custom
+ * cltv_expiry, this is what you should be using to create an invoice. The reason being, this
+ * method stores the invoice's payment secret and preimage in `ChannelManager`, so (a) the user
+ * doesn't have to store preimage/payment secret information and (b) `ChannelManager` can verify
+ * that the payment secret is valid when the invoice is paid.
+ * Use this variant if you want to pass the `description_hash` to the invoice.
+ */
+struct LDKCResult_InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager_with_description_hash(const struct LDKChannelManager *NONNULL_PTR channelmanager, struct LDKKeysInterface keys_manager, enum LDKCurrency network, struct LDKCOption_u64Z amt_msat, struct LDKSha256 description_hash);
+
+/**
+ * See [`create_invoice_from_channelmanager_with_description_hash`]
+ * This version can be used in a `no_std` environment, where [`std::time::SystemTime`] is not
+ * available and the current time is supplied by the caller.
+ */
+struct LDKCResult_InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager_with_description_hash_and_duration_since_epoch(const struct LDKChannelManager *NONNULL_PTR channelmanager, struct LDKKeysInterface keys_manager, enum LDKCurrency network, struct LDKCOption_u64Z amt_msat, struct LDKSha256 description_hash, uint64_t duration_since_epoch);
+
 /**
  * See [`create_invoice_from_channelmanager`]
  * This version can be used in a `no_std` environment, where [`std::time::SystemTime`] is not
@@ -26559,9 +26889,10 @@ struct LDKCResult_InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager
 void DefaultRouter_free(struct LDKDefaultRouter this_obj);
 
 /**
- * Creates a new router using the given [`NetworkGraph`] and  [`Logger`].
+ * Creates a new router using the given [`NetworkGraph`], a [`Logger`], and a randomness source
+ * `random_seed_bytes`.
  */
-MUST_USE_RES struct LDKDefaultRouter DefaultRouter_new(const struct LDKNetworkGraph *NONNULL_PTR network_graph, struct LDKLogger logger);
+MUST_USE_RES struct LDKDefaultRouter DefaultRouter_new(const struct LDKNetworkGraph *NONNULL_PTR network_graph, struct LDKLogger logger, struct LDKThirtyTwoBytes random_seed_bytes);
 
 /**
  * Constructs a new Router which calls the relevant methods on this_arg.
index 58970ce0c709b4f5b91a67dd269ca6cf66f88366..9f863756198c970c093017a4a94552bca50d740e 100644 (file)
@@ -18,7 +18,7 @@ class TrustedCommitmentTransaction;
 class ShutdownScript;
 class InvalidShutdownScript;
 class BackgroundProcessor;
-class ChannelManagerPersister;
+class Persister;
 class RouteHop;
 class Route;
 class RouteParameters;
@@ -278,6 +278,7 @@ class CResult_OutPointDecodeErrorZ;
 class CVec_ChannelDetailsZ;
 class CResult_SignDecodeErrorZ;
 class CVec_MessageSendEventZ;
+class COption_NetAddressZ;
 class C2Tuple_OutPointScriptZ;
 class CResult_RouteHintHopDecodeErrorZ;
 class CResult_C2Tuple_SignatureSignatureZNoneZ;
@@ -378,7 +379,6 @@ class CResult_RouteDecodeErrorZ;
 class CResult_BuiltCommitmentTransactionDecodeErrorZ;
 class COption_NoneZ;
 class CVec_TxOutZ;
-class CResult_ProbabilisticScoringParametersDecodeErrorZ;
 class CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ;
 class CResult_ChannelUpdateInfoDecodeErrorZ;
 class CVec_UpdateFailHTLCZ;
@@ -639,27 +639,29 @@ public:
        const LDKBackgroundProcessor* operator &() const { return &self; }
        const LDKBackgroundProcessor* operator ->() const { return &self; }
 };
-class ChannelManagerPersister {
+class Persister {
 private:
-       LDKChannelManagerPersister self;
+       LDKPersister self;
 public:
-       ChannelManagerPersister(const ChannelManagerPersister&) = delete;
-       ChannelManagerPersister(ChannelManagerPersister&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelManagerPersister)); }
-       ChannelManagerPersister(LDKChannelManagerPersister&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelManagerPersister)); }
-       operator LDKChannelManagerPersister() && { LDKChannelManagerPersister res = self; memset(&self, 0, sizeof(LDKChannelManagerPersister)); return res; }
-       ~ChannelManagerPersister() { ChannelManagerPersister_free(self); }
-       ChannelManagerPersister& operator=(ChannelManagerPersister&& o) { ChannelManagerPersister_free(self); self = o.self; memset(&o, 0, sizeof(ChannelManagerPersister)); return *this; }
-       LDKChannelManagerPersister* operator &() { return &self; }
-       LDKChannelManagerPersister* operator ->() { return &self; }
-       const LDKChannelManagerPersister* operator &() const { return &self; }
-       const LDKChannelManagerPersister* operator ->() const { return &self; }
+       Persister(const Persister&) = delete;
+       Persister(Persister&& o) : self(o.self) { memset(&o, 0, sizeof(Persister)); }
+       Persister(LDKPersister&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKPersister)); }
+       operator LDKPersister() && { LDKPersister res = self; memset(&self, 0, sizeof(LDKPersister)); return res; }
+       ~Persister() { Persister_free(self); }
+       Persister& operator=(Persister&& o) { Persister_free(self); self = o.self; memset(&o, 0, sizeof(Persister)); return *this; }
+       LDKPersister* operator &() { return &self; }
+       LDKPersister* operator ->() { return &self; }
+       const LDKPersister* operator &() const { return &self; }
+       const LDKPersister* operator ->() const { return &self; }
        /**
         *  Persist the given [`ChannelManager`] to disk, returning an error if persistence failed
-        *  (which will cause the [`BackgroundProcessor`] which called this method to exit.
-        * 
-        *  [`ChannelManager`]: lightning::ln::channelmanager::ChannelManager
+        *  (which will cause the [`BackgroundProcessor`] which called this method to exit).
         */
        inline LDK::CResult_NoneErrorZ persist_manager(const struct LDKChannelManager *NONNULL_PTR channel_manager);
+       /**
+        *  Persist the given [`NetworkGraph`] to disk, returning an error if persistence failed.
+        */
+       inline LDK::CResult_NoneErrorZ persist_graph(const struct LDKNetworkGraph *NONNULL_PTR network_graph);
 };
 class RouteHop {
 private:
@@ -3566,7 +3568,7 @@ public:
         *  perform routing table synchronization using a strategy defined by the
         *  implementor.
         */
-       inline void sync_routing_table(struct LDKPublicKey their_node_id, const struct LDKInit *NONNULL_PTR init);
+       inline void peer_connected(struct LDKPublicKey their_node_id, const struct LDKInit *NONNULL_PTR init);
        /**
         *  Handles the reply of a query we initiated to learn about channels
         *  for a given range of blocks. We can expect to receive one or more
@@ -5240,6 +5242,21 @@ public:
        const LDKCVec_MessageSendEventZ* operator &() const { return &self; }
        const LDKCVec_MessageSendEventZ* operator ->() const { return &self; }
 };
+class COption_NetAddressZ {
+private:
+       LDKCOption_NetAddressZ self;
+public:
+       COption_NetAddressZ(const COption_NetAddressZ&) = delete;
+       COption_NetAddressZ(COption_NetAddressZ&& o) : self(o.self) { memset(&o, 0, sizeof(COption_NetAddressZ)); }
+       COption_NetAddressZ(LDKCOption_NetAddressZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCOption_NetAddressZ)); }
+       operator LDKCOption_NetAddressZ() && { LDKCOption_NetAddressZ res = self; memset(&self, 0, sizeof(LDKCOption_NetAddressZ)); return res; }
+       ~COption_NetAddressZ() { COption_NetAddressZ_free(self); }
+       COption_NetAddressZ& operator=(COption_NetAddressZ&& o) { COption_NetAddressZ_free(self); self = o.self; memset(&o, 0, sizeof(COption_NetAddressZ)); return *this; }
+       LDKCOption_NetAddressZ* operator &() { return &self; }
+       LDKCOption_NetAddressZ* operator ->() { return &self; }
+       const LDKCOption_NetAddressZ* operator &() const { return &self; }
+       const LDKCOption_NetAddressZ* operator ->() const { return &self; }
+};
 class C2Tuple_OutPointScriptZ {
 private:
        LDKC2Tuple_OutPointScriptZ self;
@@ -6740,21 +6757,6 @@ public:
        const LDKCVec_TxOutZ* operator &() const { return &self; }
        const LDKCVec_TxOutZ* operator ->() const { return &self; }
 };
-class CResult_ProbabilisticScoringParametersDecodeErrorZ {
-private:
-       LDKCResult_ProbabilisticScoringParametersDecodeErrorZ self;
-public:
-       CResult_ProbabilisticScoringParametersDecodeErrorZ(const CResult_ProbabilisticScoringParametersDecodeErrorZ&) = delete;
-       CResult_ProbabilisticScoringParametersDecodeErrorZ(CResult_ProbabilisticScoringParametersDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_ProbabilisticScoringParametersDecodeErrorZ)); }
-       CResult_ProbabilisticScoringParametersDecodeErrorZ(LDKCResult_ProbabilisticScoringParametersDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_ProbabilisticScoringParametersDecodeErrorZ)); }
-       operator LDKCResult_ProbabilisticScoringParametersDecodeErrorZ() && { LDKCResult_ProbabilisticScoringParametersDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_ProbabilisticScoringParametersDecodeErrorZ)); return res; }
-       ~CResult_ProbabilisticScoringParametersDecodeErrorZ() { CResult_ProbabilisticScoringParametersDecodeErrorZ_free(self); }
-       CResult_ProbabilisticScoringParametersDecodeErrorZ& operator=(CResult_ProbabilisticScoringParametersDecodeErrorZ&& o) { CResult_ProbabilisticScoringParametersDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_ProbabilisticScoringParametersDecodeErrorZ)); return *this; }
-       LDKCResult_ProbabilisticScoringParametersDecodeErrorZ* operator &() { return &self; }
-       LDKCResult_ProbabilisticScoringParametersDecodeErrorZ* operator ->() { return &self; }
-       const LDKCResult_ProbabilisticScoringParametersDecodeErrorZ* operator &() const { return &self; }
-       const LDKCResult_ProbabilisticScoringParametersDecodeErrorZ* operator ->() const { return &self; }
-};
 class CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ {
 private:
        LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ self;
@@ -6816,10 +6818,14 @@ public:
        const LDKCResult_FundingLockedDecodeErrorZ* operator ->() const { return &self; }
 };
 
-inline LDK::CResult_NoneErrorZ ChannelManagerPersister::persist_manager(const struct LDKChannelManager *NONNULL_PTR channel_manager) {
+inline LDK::CResult_NoneErrorZ Persister::persist_manager(const struct LDKChannelManager *NONNULL_PTR channel_manager) {
        LDK::CResult_NoneErrorZ ret = (self.persist_manager)(self.this_arg, channel_manager);
        return ret;
 }
+inline LDK::CResult_NoneErrorZ Persister::persist_graph(const struct LDKNetworkGraph *NONNULL_PTR network_graph) {
+       LDK::CResult_NoneErrorZ ret = (self.persist_graph)(self.this_arg, network_graph);
+       return ret;
+}
 inline void BroadcasterInterface::broadcast_transaction(struct LDKTransaction tx) {
        (self.broadcast_transaction)(self.this_arg, tx);
 }
@@ -7118,8 +7124,8 @@ inline LDK::CVec_NodeAnnouncementZ RoutingMessageHandler::get_next_node_announce
        LDK::CVec_NodeAnnouncementZ ret = (self.get_next_node_announcements)(self.this_arg, starting_point, batch_amount);
        return ret;
 }
-inline void RoutingMessageHandler::sync_routing_table(struct LDKPublicKey their_node_id, const struct LDKInit *NONNULL_PTR init) {
-       (self.sync_routing_table)(self.this_arg, their_node_id, init);
+inline void RoutingMessageHandler::peer_connected(struct LDKPublicKey their_node_id, const struct LDKInit *NONNULL_PTR init) {
+       (self.peer_connected)(self.this_arg, their_node_id, init);
 }
 inline LDK::CResult_NoneLightningErrorZ RoutingMessageHandler::handle_reply_channel_range(struct LDKPublicKey their_node_id, struct LDKReplyChannelRange msg) {
        LDK::CResult_NoneLightningErrorZ ret = (self.handle_reply_channel_range)(self.this_arg, their_node_id, msg);
index d8fd1ac654afa92f209e9b4013a6d1e5ffea29a6..0f7cf38f9358cae11dfd6414fa20458c4e2fbb99 100644 (file)
@@ -3703,6 +3703,23 @@ impl From<crate::c_types::CResultTempl<crate::lightning::routing::scoring::Fixed
                }
        }
 }
+impl Clone for CResult_FixedPenaltyScorerDecodeErrorZ {
+       fn clone(&self) -> Self {
+               if self.result_ok {
+                       Self { result_ok: true, contents: CResult_FixedPenaltyScorerDecodeErrorZPtr {
+                               result: Box::into_raw(Box::new(<crate::lightning::routing::scoring::FixedPenaltyScorer>::clone(unsafe { &*self.contents.result })))
+                       } }
+               } else {
+                       Self { result_ok: false, contents: CResult_FixedPenaltyScorerDecodeErrorZPtr {
+                               err: Box::into_raw(Box::new(<crate::lightning::ln::msgs::DecodeError>::clone(unsafe { &*self.contents.err })))
+                       } }
+               }
+       }
+}
+#[no_mangle]
+/// Creates a new CResult_FixedPenaltyScorerDecodeErrorZ which has the same data as `orig`
+/// but with all dynamically-allocated buffers duplicated in new buffers.
+pub extern "C" fn CResult_FixedPenaltyScorerDecodeErrorZ_clone(orig: &CResult_FixedPenaltyScorerDecodeErrorZ) -> CResult_FixedPenaltyScorerDecodeErrorZ { Clone::clone(&orig) }
 #[repr(C)]
 /// The contents of CResult_ScoringParametersDecodeErrorZ
 pub union CResult_ScoringParametersDecodeErrorZPtr {
@@ -3782,6 +3799,23 @@ impl From<crate::c_types::CResultTempl<crate::lightning::routing::scoring::Scori
                }
        }
 }
+impl Clone for CResult_ScoringParametersDecodeErrorZ {
+       fn clone(&self) -> Self {
+               if self.result_ok {
+                       Self { result_ok: true, contents: CResult_ScoringParametersDecodeErrorZPtr {
+                               result: Box::into_raw(Box::new(<crate::lightning::routing::scoring::ScoringParameters>::clone(unsafe { &*self.contents.result })))
+                       } }
+               } else {
+                       Self { result_ok: false, contents: CResult_ScoringParametersDecodeErrorZPtr {
+                               err: Box::into_raw(Box::new(<crate::lightning::ln::msgs::DecodeError>::clone(unsafe { &*self.contents.err })))
+                       } }
+               }
+       }
+}
+#[no_mangle]
+/// Creates a new CResult_ScoringParametersDecodeErrorZ which has the same data as `orig`
+/// but with all dynamically-allocated buffers duplicated in new buffers.
+pub extern "C" fn CResult_ScoringParametersDecodeErrorZ_clone(orig: &CResult_ScoringParametersDecodeErrorZ) -> CResult_ScoringParametersDecodeErrorZ { Clone::clone(&orig) }
 #[repr(C)]
 /// The contents of CResult_ScorerDecodeErrorZ
 pub union CResult_ScorerDecodeErrorZPtr {
@@ -3862,102 +3896,6 @@ impl From<crate::c_types::CResultTempl<crate::lightning::routing::scoring::Score
        }
 }
 #[repr(C)]
-/// The contents of CResult_ProbabilisticScoringParametersDecodeErrorZ
-pub union CResult_ProbabilisticScoringParametersDecodeErrorZPtr {
-       /// 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::routing::scoring::ProbabilisticScoringParameters,
-       /// 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_ProbabilisticScoringParametersDecodeErrorZ represents the result of a fallible operation,
-/// containing a crate::lightning::routing::scoring::ProbabilisticScoringParameters 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_ProbabilisticScoringParametersDecodeErrorZ {
-       /// The contents of this CResult_ProbabilisticScoringParametersDecodeErrorZ, accessible via either
-       /// `err` or `result` depending on the state of `result_ok`.
-       pub contents: CResult_ProbabilisticScoringParametersDecodeErrorZPtr,
-       /// Whether this CResult_ProbabilisticScoringParametersDecodeErrorZ represents a success state.
-       pub result_ok: bool,
-}
-#[no_mangle]
-/// Creates a new CResult_ProbabilisticScoringParametersDecodeErrorZ in the success state.
-pub extern "C" fn CResult_ProbabilisticScoringParametersDecodeErrorZ_ok(o: crate::lightning::routing::scoring::ProbabilisticScoringParameters) -> CResult_ProbabilisticScoringParametersDecodeErrorZ {
-       CResult_ProbabilisticScoringParametersDecodeErrorZ {
-               contents: CResult_ProbabilisticScoringParametersDecodeErrorZPtr {
-                       result: Box::into_raw(Box::new(o)),
-               },
-               result_ok: true,
-       }
-}
-#[no_mangle]
-/// Creates a new CResult_ProbabilisticScoringParametersDecodeErrorZ in the error state.
-pub extern "C" fn CResult_ProbabilisticScoringParametersDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ProbabilisticScoringParametersDecodeErrorZ {
-       CResult_ProbabilisticScoringParametersDecodeErrorZ {
-               contents: CResult_ProbabilisticScoringParametersDecodeErrorZPtr {
-                       err: Box::into_raw(Box::new(e)),
-               },
-               result_ok: false,
-       }
-}
-/// Checks if the given object is currently in the success state
-#[no_mangle]
-pub extern "C" fn CResult_ProbabilisticScoringParametersDecodeErrorZ_is_ok(o: &CResult_ProbabilisticScoringParametersDecodeErrorZ) -> bool {
-       o.result_ok
-}
-#[no_mangle]
-/// Frees any resources used by the CResult_ProbabilisticScoringParametersDecodeErrorZ.
-pub extern "C" fn CResult_ProbabilisticScoringParametersDecodeErrorZ_free(_res: CResult_ProbabilisticScoringParametersDecodeErrorZ) { }
-impl Drop for CResult_ProbabilisticScoringParametersDecodeErrorZ {
-       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::routing::scoring::ProbabilisticScoringParameters, crate::lightning::ln::msgs::DecodeError>> for CResult_ProbabilisticScoringParametersDecodeErrorZ {
-       fn from(mut o: crate::c_types::CResultTempl<crate::lightning::routing::scoring::ProbabilisticScoringParameters, crate::lightning::ln::msgs::DecodeError>) -> Self {
-               let contents = if o.result_ok {
-                       let result = unsafe { o.contents.result };
-                       unsafe { o.contents.result = core::ptr::null_mut() };
-                       CResult_ProbabilisticScoringParametersDecodeErrorZPtr { result }
-               } else {
-                       let err = unsafe { o.contents.err };
-                       unsafe { o.contents.err = core::ptr::null_mut(); }
-                       CResult_ProbabilisticScoringParametersDecodeErrorZPtr { err }
-               };
-               Self {
-                       contents,
-                       result_ok: o.result_ok,
-               }
-       }
-}
-impl Clone for CResult_ProbabilisticScoringParametersDecodeErrorZ {
-       fn clone(&self) -> Self {
-               if self.result_ok {
-                       Self { result_ok: true, contents: CResult_ProbabilisticScoringParametersDecodeErrorZPtr {
-                               result: Box::into_raw(Box::new(<crate::lightning::routing::scoring::ProbabilisticScoringParameters>::clone(unsafe { &*self.contents.result })))
-                       } }
-               } else {
-                       Self { result_ok: false, contents: CResult_ProbabilisticScoringParametersDecodeErrorZPtr {
-                               err: Box::into_raw(Box::new(<crate::lightning::ln::msgs::DecodeError>::clone(unsafe { &*self.contents.err })))
-                       } }
-               }
-       }
-}
-#[no_mangle]
-/// Creates a new CResult_ProbabilisticScoringParametersDecodeErrorZ which has the same data as `orig`
-/// but with all dynamically-allocated buffers duplicated in new buffers.
-pub extern "C" fn CResult_ProbabilisticScoringParametersDecodeErrorZ_clone(orig: &CResult_ProbabilisticScoringParametersDecodeErrorZ) -> CResult_ProbabilisticScoringParametersDecodeErrorZ { Clone::clone(&orig) }
-#[repr(C)]
 /// The contents of CResult_ProbabilisticScorerDecodeErrorZ
 pub union CResult_ProbabilisticScorerDecodeErrorZPtr {
        /// A pointer to the contents in the success state.
@@ -7586,6 +7524,23 @@ impl From<crate::c_types::CResultTempl<crate::lightning::ln::channelmanager::Pha
                }
        }
 }
+impl Clone for CResult_PhantomRouteHintsDecodeErrorZ {
+       fn clone(&self) -> Self {
+               if self.result_ok {
+                       Self { result_ok: true, contents: CResult_PhantomRouteHintsDecodeErrorZPtr {
+                               result: Box::into_raw(Box::new(<crate::lightning::ln::channelmanager::PhantomRouteHints>::clone(unsafe { &*self.contents.result })))
+                       } }
+               } else {
+                       Self { result_ok: false, contents: CResult_PhantomRouteHintsDecodeErrorZPtr {
+                               err: Box::into_raw(Box::new(<crate::lightning::ln::msgs::DecodeError>::clone(unsafe { &*self.contents.err })))
+                       } }
+               }
+       }
+}
+#[no_mangle]
+/// Creates a new CResult_PhantomRouteHintsDecodeErrorZ which has the same data as `orig`
+/// but with all dynamically-allocated buffers duplicated in new buffers.
+pub extern "C" fn CResult_PhantomRouteHintsDecodeErrorZ_clone(orig: &CResult_PhantomRouteHintsDecodeErrorZ) -> CResult_PhantomRouteHintsDecodeErrorZ { Clone::clone(&orig) }
 #[repr(C)]
 /// A dynamically-allocated array of crate::lightning::chain::channelmonitor::ChannelMonitors of arbitrary size.
 /// This corresponds to std::vector in C++
@@ -10528,6 +10483,43 @@ impl Clone for CVec_PublicKeyZ {
        }
 }
 #[repr(C)]
+#[derive(Clone)]
+/// An enum which can either contain a crate::lightning::ln::msgs::NetAddress or not
+pub enum COption_NetAddressZ {
+       /// When we're in this state, this COption_NetAddressZ contains a crate::lightning::ln::msgs::NetAddress
+       Some(crate::lightning::ln::msgs::NetAddress),
+       /// When we're in this state, this COption_NetAddressZ contains nothing
+       None
+}
+impl COption_NetAddressZ {
+       #[allow(unused)] pub(crate) fn is_some(&self) -> bool {
+               if let Self::None = self { false } else { true }
+       }
+       #[allow(unused)] pub(crate) fn is_none(&self) -> bool {
+               !self.is_some()
+       }
+       #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::ln::msgs::NetAddress {
+               if let Self::Some(v) = self { v } else { unreachable!() }
+       }
+}
+#[no_mangle]
+/// Constructs a new COption_NetAddressZ containing a crate::lightning::ln::msgs::NetAddress
+pub extern "C" fn COption_NetAddressZ_some(o: crate::lightning::ln::msgs::NetAddress) -> COption_NetAddressZ {
+       COption_NetAddressZ::Some(o)
+}
+#[no_mangle]
+/// Constructs a new COption_NetAddressZ containing nothing
+pub extern "C" fn COption_NetAddressZ_none() -> COption_NetAddressZ {
+       COption_NetAddressZ::None
+}
+#[no_mangle]
+/// Frees any resources associated with the crate::lightning::ln::msgs::NetAddress, if we are in the Some state
+pub extern "C" fn COption_NetAddressZ_free(_res: COption_NetAddressZ) { }
+#[no_mangle]
+/// Creates a new COption_NetAddressZ which has the same data as `orig`
+/// but with all dynamically-allocated buffers duplicated in new buffers.
+pub extern "C" fn COption_NetAddressZ_clone(orig: &COption_NetAddressZ) -> COption_NetAddressZ { Clone::clone(&orig) }
+#[repr(C)]
 /// The contents of CResult_CVec_u8ZPeerHandleErrorZ
 pub union CResult_CVec_u8ZPeerHandleErrorZPtr {
        /// A pointer to the contents in the success state.
@@ -15180,6 +15172,14 @@ impl Drop for CVec_PhantomRouteHintsZ {
                unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) };
        }
 }
+impl Clone for CVec_PhantomRouteHintsZ {
+       fn clone(&self) -> Self {
+               let mut res = Vec::new();
+               if self.datalen == 0 { return Self::from(res); }
+               res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) });
+               Self::from(res)
+       }
+}
 #[repr(C)]
 /// The contents of CResult_InvoiceSignOrCreationErrorZ
 pub union CResult_InvoiceSignOrCreationErrorZPtr {
index a7ff44bda55eb13dd979e126185084e97774ec9c..2b91ced5d4596b9e84b55599087b27578ec02708 100644 (file)
@@ -627,8 +627,35 @@ pub extern "C" fn ChannelDetails_set_funding_txo(this_ptr: &mut ChannelDetails,
        let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
        unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_txo = local_val;
 }
+/// The features which this channel operates with. See individual features for more info.
+///
+/// `None` until negotiation completes and the channel type is finalized.
+///
+/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
+#[no_mangle]
+pub extern "C" fn ChannelDetails_get_channel_type(this_ptr: &ChannelDetails) -> crate::lightning::ln::features::ChannelTypeFeatures {
+       let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_type;
+       let mut local_inner_val = crate::lightning::ln::features::ChannelTypeFeatures { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::features::ChannelTypeFeatures<>) as *mut _ }, is_owned: false };
+       local_inner_val
+}
+/// The features which this channel operates with. See individual features for more info.
+///
+/// `None` until negotiation completes and the channel type is finalized.
+///
+/// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
+#[no_mangle]
+pub extern "C" fn ChannelDetails_set_channel_type(this_ptr: &mut ChannelDetails, mut val: crate::lightning::ln::features::ChannelTypeFeatures) {
+       let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
+       unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type = 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.
+///
+/// Note that if [`inbound_scid_alias`] is set, it must be used for invoices and inbound
+/// payments instead of this. See [`get_inbound_payment_scid`].
+///
+/// [`inbound_scid_alias`]: Self::inbound_scid_alias
+/// [`get_inbound_payment_scid`]: Self::get_inbound_payment_scid
 #[no_mangle]
 pub extern "C" fn ChannelDetails_get_short_channel_id(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u64Z {
        let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
@@ -637,11 +664,46 @@ pub extern "C" fn ChannelDetails_get_short_channel_id(this_ptr: &ChannelDetails)
 }
 /// The position of the funding transaction in the chain. None if the funding transaction has
 /// not yet been confirmed and the channel fully opened.
+///
+/// Note that if [`inbound_scid_alias`] is set, it must be used for invoices and inbound
+/// payments instead of this. See [`get_inbound_payment_scid`].
+///
+/// [`inbound_scid_alias`]: Self::inbound_scid_alias
+/// [`get_inbound_payment_scid`]: Self::get_inbound_payment_scid
 #[no_mangle]
 pub extern "C" fn ChannelDetails_set_short_channel_id(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u64Z) {
        let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
        unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = local_val;
 }
+/// An optional [`short_channel_id`] alias for this channel, randomly generated by our
+/// counterparty and usable in place of [`short_channel_id`] in invoice route hints. Our
+/// counterparty will recognize the alias provided here in place of the [`short_channel_id`]
+/// when they see a payment to be routed to us.
+///
+/// Our counterparty may choose to rotate this value at any time, though will always recognize
+/// previous values for inbound payment forwarding.
+///
+/// [`short_channel_id`]: Self::short_channel_id
+#[no_mangle]
+pub extern "C" fn ChannelDetails_get_inbound_scid_alias(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u64Z {
+       let mut inner_val = &mut this_ptr.get_native_mut_ref().inbound_scid_alias;
+       let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { inner_val.unwrap() }) };
+       local_inner_val
+}
+/// An optional [`short_channel_id`] alias for this channel, randomly generated by our
+/// counterparty and usable in place of [`short_channel_id`] in invoice route hints. Our
+/// counterparty will recognize the alias provided here in place of the [`short_channel_id`]
+/// when they see a payment to be routed to us.
+///
+/// Our counterparty may choose to rotate this value at any time, though will always recognize
+/// previous values for inbound payment forwarding.
+///
+/// [`short_channel_id`]: Self::short_channel_id
+#[no_mangle]
+pub extern "C" fn ChannelDetails_set_inbound_scid_alias(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u64Z) {
+       let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
+       unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.inbound_scid_alias = local_val;
+}
 /// The value, in satoshis, of this channel as appears in the funding output
 #[no_mangle]
 pub extern "C" fn ChannelDetails_get_channel_value_satoshis(this_ptr: &ChannelDetails) -> u64 {
@@ -901,9 +963,11 @@ pub extern "C" fn ChannelDetails_set_is_public(this_ptr: &mut ChannelDetails, mu
 /// Constructs a new ChannelDetails given each field
 #[must_use]
 #[no_mangle]
-pub extern "C" fn ChannelDetails_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut counterparty_arg: crate::lightning::ln::channelmanager::ChannelCounterparty, mut funding_txo_arg: crate::lightning::chain::transaction::OutPoint, mut short_channel_id_arg: crate::c_types::derived::COption_u64Z, mut channel_value_satoshis_arg: u64, mut unspendable_punishment_reserve_arg: crate::c_types::derived::COption_u64Z, mut user_channel_id_arg: u64, mut balance_msat_arg: u64, mut outbound_capacity_msat_arg: u64, mut inbound_capacity_msat_arg: u64, mut confirmations_required_arg: crate::c_types::derived::COption_u32Z, mut force_close_spend_delay_arg: crate::c_types::derived::COption_u16Z, mut is_outbound_arg: bool, mut is_funding_locked_arg: bool, mut is_usable_arg: bool, mut is_public_arg: bool) -> ChannelDetails {
+pub extern "C" fn ChannelDetails_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut counterparty_arg: crate::lightning::ln::channelmanager::ChannelCounterparty, mut funding_txo_arg: crate::lightning::chain::transaction::OutPoint, mut channel_type_arg: crate::lightning::ln::features::ChannelTypeFeatures, mut short_channel_id_arg: crate::c_types::derived::COption_u64Z, mut inbound_scid_alias_arg: crate::c_types::derived::COption_u64Z, mut channel_value_satoshis_arg: u64, mut unspendable_punishment_reserve_arg: crate::c_types::derived::COption_u64Z, mut user_channel_id_arg: u64, mut balance_msat_arg: u64, mut outbound_capacity_msat_arg: u64, mut inbound_capacity_msat_arg: u64, mut confirmations_required_arg: crate::c_types::derived::COption_u32Z, mut force_close_spend_delay_arg: crate::c_types::derived::COption_u16Z, mut is_outbound_arg: bool, mut is_funding_locked_arg: bool, mut is_usable_arg: bool, mut is_public_arg: bool) -> ChannelDetails {
        let mut local_funding_txo_arg = if funding_txo_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(funding_txo_arg.take_inner()) } }) };
+       let mut local_channel_type_arg = if channel_type_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(channel_type_arg.take_inner()) } }) };
        let mut local_short_channel_id_arg = if short_channel_id_arg.is_some() { Some( { short_channel_id_arg.take() }) } else { None };
+       let mut local_inbound_scid_alias_arg = if inbound_scid_alias_arg.is_some() { Some( { inbound_scid_alias_arg.take() }) } else { None };
        let mut local_unspendable_punishment_reserve_arg = if unspendable_punishment_reserve_arg.is_some() { Some( { unspendable_punishment_reserve_arg.take() }) } else { None };
        let mut local_confirmations_required_arg = if confirmations_required_arg.is_some() { Some( { confirmations_required_arg.take() }) } else { None };
        let mut local_force_close_spend_delay_arg = if force_close_spend_delay_arg.is_some() { Some( { force_close_spend_delay_arg.take() }) } else { None };
@@ -911,7 +975,9 @@ pub extern "C" fn ChannelDetails_new(mut channel_id_arg: crate::c_types::ThirtyT
                channel_id: channel_id_arg.data,
                counterparty: *unsafe { Box::from_raw(counterparty_arg.take_inner()) },
                funding_txo: local_funding_txo_arg,
+               channel_type: local_channel_type_arg,
                short_channel_id: local_short_channel_id_arg,
+               inbound_scid_alias: local_inbound_scid_alias_arg,
                channel_value_satoshis: channel_value_satoshis_arg,
                unspendable_punishment_reserve: local_unspendable_punishment_reserve_arg,
                user_channel_id: user_channel_id_arg,
@@ -945,6 +1011,20 @@ pub(crate) extern "C" fn ChannelDetails_clone_void(this_ptr: *const c_void) -> *
 pub extern "C" fn ChannelDetails_clone(orig: &ChannelDetails) -> ChannelDetails {
        orig.clone()
 }
+/// Gets the current SCID which should be used to identify this channel for inbound payments.
+/// This should be used for providing invoice hints or in any other context where our
+/// counterparty will forward a payment to us.
+///
+/// This is either the [`ChannelDetails::inbound_scid_alias`], if set, or the
+/// [`ChannelDetails::short_channel_id`]. See those for more information.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChannelDetails_get_inbound_payment_scid(this_arg: &ChannelDetails) -> crate::c_types::derived::COption_u64Z {
+       let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_inbound_payment_scid();
+       let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { ret.unwrap() }) };
+       local_ret
+}
+
 /// If a payment fails to send, it can be in one of several states. This enum is returned as the
 /// Err() type describing which state the payment is in, see the description of individual enum
 /// states for more.
@@ -1265,6 +1345,25 @@ pub extern "C" fn PhantomRouteHints_new(mut channels_arg: crate::c_types::derive
                real_node_pubkey: real_node_pubkey_arg.into_rust(),
        }), is_owned: true }
 }
+impl Clone for PhantomRouteHints {
+       fn clone(&self) -> Self {
+               Self {
+                       inner: if <*mut nativePhantomRouteHints>::is_null(self.inner) { core::ptr::null_mut() } else {
+                               ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
+                       is_owned: true,
+               }
+       }
+}
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn PhantomRouteHints_clone_void(this_ptr: *const c_void) -> *mut c_void {
+       Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativePhantomRouteHints)).clone() })) as *mut c_void
+}
+#[no_mangle]
+/// Creates a copy of the PhantomRouteHints
+pub extern "C" fn PhantomRouteHints_clone(orig: &PhantomRouteHints) -> PhantomRouteHints {
+       orig.clone()
+}
 /// Constructs a new ChannelManager to hold several channels and route between them.
 ///
 /// This is the main \"logic hub\" for all channel-related actions, and implements
@@ -1659,11 +1758,16 @@ pub extern "C" fn ChannelManager_get_our_node_id(this_arg: &ChannelManager) -> c
 ///
 /// The `temporary_channel_id` parameter indicates which inbound channel should be accepted.
 ///
-/// [`Event::OpenChannelRequest`]: crate::util::events::Event::OpenChannelRequest
+/// For inbound channels, the `user_channel_id` parameter will be provided back in
+/// [`Event::ChannelClosed::user_channel_id`] to allow tracking of which events correspond
+/// with which `accept_inbound_channel` call.
+///
+/// [`Event::OpenChannelRequest`]: events::Event::OpenChannelRequest
+/// [`Event::ChannelClosed::user_channel_id`]: events::Event::ChannelClosed::user_channel_id
 #[must_use]
 #[no_mangle]
-pub extern "C" fn ChannelManager_accept_inbound_channel(this_arg: &ChannelManager, temporary_channel_id: *const [u8; 32]) -> crate::c_types::derived::CResult_NoneAPIErrorZ {
-       let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.accept_inbound_channel(unsafe { &*temporary_channel_id});
+pub extern "C" fn ChannelManager_accept_inbound_channel(this_arg: &ChannelManager, temporary_channel_id: *const [u8; 32], mut user_channel_id: u64) -> crate::c_types::derived::CResult_NoneAPIErrorZ {
+       let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.accept_inbound_channel(unsafe { &*temporary_channel_id}, user_channel_id);
        let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() };
        local_ret
 }
@@ -1706,6 +1810,8 @@ pub extern "C" fn ChannelManager_create_inbound_payment(this_arg: &ChannelManage
 /// Legacy version of [`create_inbound_payment`]. Use this method if you wish to share
 /// serialized state with LDK node(s) running 0.0.103 and earlier.
 ///
+/// May panic if `invoice_expiry_delta_secs` is greater than one year.
+///
 /// # Note
 /// This method is deprecated and will be removed soon.
 ///
@@ -1747,8 +1853,6 @@ pub extern "C" fn ChannelManager_create_inbound_payment_legacy(this_arg: &Channe
 /// If you need exact expiry semantics, you should enforce them upon receipt of
 /// [`PaymentReceived`].
 ///
-/// May panic if `invoice_expiry_delta_secs` is greater than one year.
-///
 /// Note that invoices generated for inbound payments should have their `min_final_cltv_expiry`
 /// set to at least [`MIN_FINAL_CLTV_EXPIRY`].
 ///
@@ -1776,6 +1880,8 @@ pub extern "C" fn ChannelManager_create_inbound_payment_for_hash(this_arg: &Chan
 /// Legacy version of [`create_inbound_payment_for_hash`]. Use this method if you wish to share
 /// serialized state with LDK node(s) running 0.0.103 and earlier.
 ///
+/// May panic if `invoice_expiry_delta_secs` is greater than one year.
+///
 /// # Note
 /// This method is deprecated and will be removed soon.
 ///
index 1976040fd7da7d464a15f39b7e28e7ed8c02795c..32b5f87da0a301de2ae3d38cf95b68a5ddbbc527 100644 (file)
@@ -163,12 +163,33 @@ pub extern "C" fn Init_get_features(this_ptr: &Init) -> crate::lightning::ln::fe
 pub extern "C" fn Init_set_features(this_ptr: &mut Init, mut val: crate::lightning::ln::features::InitFeatures) {
        unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
 }
+/// The receipient's network address. This adds the option to report a remote IP address
+/// back to a connecting peer using the init message. A node can decide to use that information
+/// to discover a potential update to its public IPv4 address (NAT) and use
+/// that for a node_announcement update message containing the new address.
+#[no_mangle]
+pub extern "C" fn Init_get_remote_network_address(this_ptr: &Init) -> crate::c_types::derived::COption_NetAddressZ {
+       let mut inner_val = &mut this_ptr.get_native_mut_ref().remote_network_address;
+       let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_NetAddressZ::None } else { crate::c_types::derived::COption_NetAddressZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option<Enum> is otherwise un-expressable. */ { crate::lightning::ln::msgs::NetAddress::native_into(inner_val.clone().unwrap()) }) };
+       local_inner_val
+}
+/// The receipient's network address. This adds the option to report a remote IP address
+/// back to a connecting peer using the init message. A node can decide to use that information
+/// to discover a potential update to its public IPv4 address (NAT) and use
+/// that for a node_announcement update message containing the new address.
+#[no_mangle]
+pub extern "C" fn Init_set_remote_network_address(this_ptr: &mut Init, mut val: crate::c_types::derived::COption_NetAddressZ) {
+       let mut local_val = { /* val*/ let val_opt = val; { } if val_opt.is_none() { None } else { Some({ val_opt.take().into_native() }) } };
+       unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.remote_network_address = local_val;
+}
 /// Constructs a new Init given each field
 #[must_use]
 #[no_mangle]
-pub extern "C" fn Init_new(mut features_arg: crate::lightning::ln::features::InitFeatures) -> Init {
+pub extern "C" fn Init_new(mut features_arg: crate::lightning::ln::features::InitFeatures, mut remote_network_address_arg: crate::c_types::derived::COption_NetAddressZ) -> Init {
+       let mut local_remote_network_address_arg = { /* remote_network_address_arg*/ let remote_network_address_arg_opt = remote_network_address_arg; { } if remote_network_address_arg_opt.is_none() { None } else { Some({ remote_network_address_arg_opt.take().into_native() }) } };
        Init { inner: ObjOps::heap_alloc(nativeInit {
                features: *unsafe { Box::from_raw(features_arg.take_inner()) },
+               remote_network_address: local_remote_network_address_arg,
        }), is_owned: true }
 }
 impl Clone for Init {
@@ -1445,13 +1466,30 @@ pub extern "C" fn FundingLocked_get_next_per_commitment_point(this_ptr: &Funding
 pub extern "C" fn FundingLocked_set_next_per_commitment_point(this_ptr: &mut FundingLocked, mut val: crate::c_types::PublicKey) {
        unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_per_commitment_point = val.into_rust();
 }
+/// If set, provides a short_channel_id alias for this channel. The sender will accept payments
+/// to be forwarded over this SCID and forward them to this messages' recipient.
+#[no_mangle]
+pub extern "C" fn FundingLocked_get_short_channel_id_alias(this_ptr: &FundingLocked) -> crate::c_types::derived::COption_u64Z {
+       let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id_alias;
+       let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { inner_val.unwrap() }) };
+       local_inner_val
+}
+/// If set, provides a short_channel_id alias for this channel. The sender will accept payments
+/// to be forwarded over this SCID and forward them to this messages' recipient.
+#[no_mangle]
+pub extern "C" fn FundingLocked_set_short_channel_id_alias(this_ptr: &mut FundingLocked, mut val: crate::c_types::derived::COption_u64Z) {
+       let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
+       unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id_alias = local_val;
+}
 /// Constructs a new FundingLocked given each field
 #[must_use]
 #[no_mangle]
-pub extern "C" fn FundingLocked_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut next_per_commitment_point_arg: crate::c_types::PublicKey) -> FundingLocked {
+pub extern "C" fn FundingLocked_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut next_per_commitment_point_arg: crate::c_types::PublicKey, mut short_channel_id_alias_arg: crate::c_types::derived::COption_u64Z) -> FundingLocked {
+       let mut local_short_channel_id_alias_arg = if short_channel_id_alias_arg.is_some() { Some( { short_channel_id_alias_arg.take() }) } else { None };
        FundingLocked { inner: ObjOps::heap_alloc(nativeFundingLocked {
                channel_id: channel_id_arg.data,
                next_per_commitment_point: next_per_commitment_point_arg.into_rust(),
+               short_channel_id_alias: local_short_channel_id_alias_arg,
        }), is_owned: true }
 }
 impl Clone for FundingLocked {
@@ -5206,7 +5244,7 @@ pub struct RoutingMessageHandler {
        /// Called when a connection is established with a peer. This can be used to
        /// perform routing table synchronization using a strategy defined by the
        /// implementor.
-       pub sync_routing_table: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, init: &crate::lightning::ln::msgs::Init),
+       pub peer_connected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, init: &crate::lightning::ln::msgs::Init),
        /// Handles the reply of a query we initiated to learn about channels
        /// for a given range of blocks. We can expect to receive one or more
        /// replies to a single query.
@@ -5243,7 +5281,7 @@ pub(crate) extern "C" fn RoutingMessageHandler_clone_fields(orig: &RoutingMessag
                handle_channel_update: Clone::clone(&orig.handle_channel_update),
                get_next_channel_announcements: Clone::clone(&orig.get_next_channel_announcements),
                get_next_node_announcements: Clone::clone(&orig.get_next_node_announcements),
-               sync_routing_table: Clone::clone(&orig.sync_routing_table),
+               peer_connected: Clone::clone(&orig.peer_connected),
                handle_reply_channel_range: Clone::clone(&orig.handle_reply_channel_range),
                handle_reply_short_channel_ids_end: Clone::clone(&orig.handle_reply_short_channel_ids_end),
                handle_query_channel_range: Clone::clone(&orig.handle_query_channel_range),
@@ -5288,8 +5326,8 @@ impl rustRoutingMessageHandler for RoutingMessageHandler {
                let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
                local_ret
        }
-       fn sync_routing_table(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut init: &lightning::ln::msgs::Init) {
-               (self.sync_routing_table)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::Init { inner: unsafe { ObjOps::nonnull_ptr_to_inner((init as *const lightning::ln::msgs::Init<>) as *mut _) }, is_owned: false })
+       fn peer_connected(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut init: &lightning::ln::msgs::Init) {
+               (self.peer_connected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::Init { inner: unsafe { ObjOps::nonnull_ptr_to_inner((init as *const lightning::ln::msgs::Init<>) as *mut _) }, is_owned: false })
        }
        fn handle_reply_channel_range(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: lightning::ln::msgs::ReplyChannelRange) -> Result<(), lightning::ln::msgs::LightningError> {
                let mut ret = (self.handle_reply_channel_range)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), crate::lightning::ln::msgs::ReplyChannelRange { inner: ObjOps::heap_alloc(msg), is_owned: true });
index 9d712c84d6ffe8ca0b2b1f917e35da2153f2ee42..bf6bd145f4a51973b7b76358d2d62888e2c6a6ea 100644 (file)
@@ -206,7 +206,7 @@ pub extern "C" fn IgnoringMessageHandler_as_RoutingMessageHandler(this_arg: &Ign
                handle_channel_update: IgnoringMessageHandler_RoutingMessageHandler_handle_channel_update,
                get_next_channel_announcements: IgnoringMessageHandler_RoutingMessageHandler_get_next_channel_announcements,
                get_next_node_announcements: IgnoringMessageHandler_RoutingMessageHandler_get_next_node_announcements,
-               sync_routing_table: IgnoringMessageHandler_RoutingMessageHandler_sync_routing_table,
+               peer_connected: IgnoringMessageHandler_RoutingMessageHandler_peer_connected,
                handle_reply_channel_range: IgnoringMessageHandler_RoutingMessageHandler_handle_reply_channel_range,
                handle_reply_short_channel_ids_end: IgnoringMessageHandler_RoutingMessageHandler_handle_reply_short_channel_ids_end,
                handle_query_channel_range: IgnoringMessageHandler_RoutingMessageHandler_handle_query_channel_range,
@@ -250,8 +250,8 @@ extern "C" fn IgnoringMessageHandler_RoutingMessageHandler_get_next_node_announc
        let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::ln::msgs::NodeAnnouncement { inner: ObjOps::heap_alloc(item), is_owned: true } }); };
        local_ret.into()
 }
-extern "C" fn IgnoringMessageHandler_RoutingMessageHandler_sync_routing_table(this_arg: *const c_void, mut _their_node_id: crate::c_types::PublicKey, _init: &crate::lightning::ln::msgs::Init) {
-       <nativeIgnoringMessageHandler as lightning::ln::msgs::RoutingMessageHandler<>>::sync_routing_table(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, &_their_node_id.into_rust(), _init.get_native_ref())
+extern "C" fn IgnoringMessageHandler_RoutingMessageHandler_peer_connected(this_arg: *const c_void, mut _their_node_id: crate::c_types::PublicKey, _init: &crate::lightning::ln::msgs::Init) {
+       <nativeIgnoringMessageHandler as lightning::ln::msgs::RoutingMessageHandler<>>::peer_connected(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, &_their_node_id.into_rust(), _init.get_native_ref())
 }
 #[must_use]
 extern "C" fn IgnoringMessageHandler_RoutingMessageHandler_handle_reply_channel_range(this_arg: *const c_void, mut _their_node_id: crate::c_types::PublicKey, mut _msg: crate::lightning::ln::msgs::ReplyChannelRange) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
@@ -943,7 +943,13 @@ pub extern "C" fn PeerManager_get_peer_node_ids(this_arg: &PeerManager) -> crate
        local_ret.into()
 }
 
-/// Indicates a new outbound connection has been established to a node with the given node_id.
+/// Indicates a new outbound connection has been established to a node with the given node_id
+/// and an optional remote network address.
+///
+/// The remote network address adds the option to report a remote IP address back to a connecting
+/// peer using the init message.
+/// The user should pass the remote network address of the host they are connected to.
+///
 /// Note that if an Err is returned here you MUST NOT call socket_disconnected for the new
 /// descriptor but must disconnect the connection immediately.
 ///
@@ -955,13 +961,19 @@ pub extern "C" fn PeerManager_get_peer_node_ids(this_arg: &PeerManager) -> crate
 /// [`socket_disconnected()`]: PeerManager::socket_disconnected
 #[must_use]
 #[no_mangle]
-pub extern "C" fn PeerManager_new_outbound_connection(this_arg: &PeerManager, mut their_node_id: crate::c_types::PublicKey, mut descriptor: crate::lightning::ln::peer_handler::SocketDescriptor) -> crate::c_types::derived::CResult_CVec_u8ZPeerHandleErrorZ {
-       let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.new_outbound_connection(their_node_id.into_rust(), descriptor);
+pub extern "C" fn PeerManager_new_outbound_connection(this_arg: &PeerManager, mut their_node_id: crate::c_types::PublicKey, mut descriptor: crate::lightning::ln::peer_handler::SocketDescriptor, mut remote_network_address: crate::c_types::derived::COption_NetAddressZ) -> crate::c_types::derived::CResult_CVec_u8ZPeerHandleErrorZ {
+       let mut local_remote_network_address = { /* remote_network_address*/ let remote_network_address_opt = remote_network_address; { } if remote_network_address_opt.is_none() { None } else { Some({ remote_network_address_opt.take().into_native() }) } };
+       let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.new_outbound_connection(their_node_id.into_rust(), descriptor, local_remote_network_address);
        let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_ret_0 = Vec::new(); for mut item in o.drain(..) { local_ret_0.push( { item }); }; local_ret_0.into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::peer_handler::PeerHandleError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
        local_ret
 }
 
-/// Indicates a new inbound connection has been established.
+/// Indicates a new inbound connection has been established to a node with an optional remote
+/// network address.
+///
+/// The remote network address adds the option to report a remote IP address back to a connecting
+/// peer using the init message.
+/// The user should pass the remote network address of the host they are connected to.
 ///
 /// May refuse the connection by returning an Err, but will never write bytes to the remote end
 /// (outbound connector always speaks first). Note that if an Err is returned here you MUST NOT
@@ -974,8 +986,9 @@ pub extern "C" fn PeerManager_new_outbound_connection(this_arg: &PeerManager, mu
 /// [`socket_disconnected()`]: PeerManager::socket_disconnected
 #[must_use]
 #[no_mangle]
-pub extern "C" fn PeerManager_new_inbound_connection(this_arg: &PeerManager, mut descriptor: crate::lightning::ln::peer_handler::SocketDescriptor) -> crate::c_types::derived::CResult_NonePeerHandleErrorZ {
-       let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.new_inbound_connection(descriptor);
+pub extern "C" fn PeerManager_new_inbound_connection(this_arg: &PeerManager, mut descriptor: crate::lightning::ln::peer_handler::SocketDescriptor, mut remote_network_address: crate::c_types::derived::COption_NetAddressZ) -> crate::c_types::derived::CResult_NonePeerHandleErrorZ {
+       let mut local_remote_network_address = { /* remote_network_address*/ let remote_network_address_opt = remote_network_address; { } if remote_network_address_opt.is_none() { None } else { Some({ remote_network_address_opt.take().into_native() }) } };
+       let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.new_inbound_connection(descriptor, local_remote_network_address);
        let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::peer_handler::PeerHandleError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
        local_ret
 }
@@ -1071,9 +1084,9 @@ pub extern "C" fn PeerManager_disconnect_all_peers(this_arg: &PeerManager) {
 /// Send pings to each peer and disconnect those which did not respond to the last round of
 /// pings.
 ///
-/// This may be called on any timescale you want, however, roughly once every five to ten
-/// seconds is preferred. The call rate determines both how often we send a ping to our peers
-/// and how much time they have to respond before we disconnect them.
+/// This may be called on any timescale you want, however, roughly once every ten seconds is
+/// preferred. The call rate determines both how often we send a ping to our peers and how much
+/// time they have to respond before we disconnect them.
 ///
 /// May call [`send_data`] on all [`SocketDescriptor`]s. Thus, be very careful with reentrancy
 /// issues!
index 4b278a95ff4c3d909c0478c66a211d6ef7be5006..a3fce9e527cf3357a0febda384306398751bd08d 100644 (file)
@@ -554,7 +554,7 @@ pub extern "C" fn NetGraphMsgHandler_as_RoutingMessageHandler(this_arg: &NetGrap
                handle_channel_update: NetGraphMsgHandler_RoutingMessageHandler_handle_channel_update,
                get_next_channel_announcements: NetGraphMsgHandler_RoutingMessageHandler_get_next_channel_announcements,
                get_next_node_announcements: NetGraphMsgHandler_RoutingMessageHandler_get_next_node_announcements,
-               sync_routing_table: NetGraphMsgHandler_RoutingMessageHandler_sync_routing_table,
+               peer_connected: NetGraphMsgHandler_RoutingMessageHandler_peer_connected,
                handle_reply_channel_range: NetGraphMsgHandler_RoutingMessageHandler_handle_reply_channel_range,
                handle_reply_short_channel_ids_end: NetGraphMsgHandler_RoutingMessageHandler_handle_reply_short_channel_ids_end,
                handle_query_channel_range: NetGraphMsgHandler_RoutingMessageHandler_handle_query_channel_range,
@@ -598,18 +598,18 @@ extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_get_next_node_announcemen
        let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::ln::msgs::NodeAnnouncement { inner: ObjOps::heap_alloc(item), is_owned: true } }); };
        local_ret.into()
 }
-extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_sync_routing_table(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, init_msg: &crate::lightning::ln::msgs::Init) {
-       <nativeNetGraphMsgHandler as lightning::ln::msgs::RoutingMessageHandler<>>::sync_routing_table(unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }, &their_node_id.into_rust(), init_msg.get_native_ref())
+extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_peer_connected(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, init_msg: &crate::lightning::ln::msgs::Init) {
+       <nativeNetGraphMsgHandler as lightning::ln::msgs::RoutingMessageHandler<>>::peer_connected(unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }, &their_node_id.into_rust(), init_msg.get_native_ref())
 }
 #[must_use]
-extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_handle_reply_channel_range(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, mut msg: crate::lightning::ln::msgs::ReplyChannelRange) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
-       let mut ret = <nativeNetGraphMsgHandler as lightning::ln::msgs::RoutingMessageHandler<>>::handle_reply_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_reply_channel_range(this_arg: *const c_void, mut _their_node_id: crate::c_types::PublicKey, mut _msg: crate::lightning::ln::msgs::ReplyChannelRange) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
+       let mut ret = <nativeNetGraphMsgHandler as lightning::ln::msgs::RoutingMessageHandler<>>::handle_reply_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( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
        local_ret
 }
 #[must_use]
-extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_handle_reply_short_channel_ids_end(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, mut msg: crate::lightning::ln::msgs::ReplyShortChannelIdsEnd) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
-       let mut ret = <nativeNetGraphMsgHandler as lightning::ln::msgs::RoutingMessageHandler<>>::handle_reply_short_channel_ids_end(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_reply_short_channel_ids_end(this_arg: *const c_void, mut _their_node_id: crate::c_types::PublicKey, mut _msg: crate::lightning::ln::msgs::ReplyShortChannelIdsEnd) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
+       let mut ret = <nativeNetGraphMsgHandler as lightning::ln::msgs::RoutingMessageHandler<>>::handle_reply_short_channel_ids_end(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( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
        local_ret
 }
index 35a01f27c7cebef5d42502ffc40587f38671b2d9..6ba1106e877569a369d4d564d6465c268c43e97e 100644 (file)
@@ -1092,9 +1092,9 @@ pub extern "C" fn RouteHintHop_read(ser: crate::c_types::u8slice) -> crate::c_ty
 ///
 /// Note that first_hops (or a relevant inner pointer) may be NULL or all-0s to represent None
 #[no_mangle]
-pub extern "C" fn find_route(mut our_node_pubkey: crate::c_types::PublicKey, route_params: &crate::lightning::routing::router::RouteParameters, network: &crate::lightning::routing::network_graph::NetworkGraph, first_hops: *mut crate::c_types::derived::CVec_ChannelDetailsZ, mut logger: crate::lightning::util::logger::Logger, scorer: &crate::lightning::routing::scoring::Score) -> crate::c_types::derived::CResult_RouteLightningErrorZ {
+pub extern "C" fn find_route(mut our_node_pubkey: crate::c_types::PublicKey, route_params: &crate::lightning::routing::router::RouteParameters, network: &crate::lightning::routing::network_graph::NetworkGraph, first_hops: *mut crate::c_types::derived::CVec_ChannelDetailsZ, mut logger: crate::lightning::util::logger::Logger, scorer: &crate::lightning::routing::scoring::Score, random_seed_bytes: *const [u8; 32]) -> crate::c_types::derived::CResult_RouteLightningErrorZ {
        let mut local_first_hops_base = if first_hops == core::ptr::null_mut() { None } else { Some( { let mut local_first_hops_0 = Vec::new(); for mut item in unsafe { &mut *first_hops }.as_slice().iter() { local_first_hops_0.push( { item.get_native_ref() }); }; local_first_hops_0 }) }; let mut local_first_hops = local_first_hops_base.as_ref().map(|a| &a[..]);
-       let mut ret = lightning::routing::router::find_route::<crate::lightning::util::logger::Logger, crate::lightning::routing::scoring::Score>(&our_node_pubkey.into_rust(), route_params.get_native_ref(), network.get_native_ref(), local_first_hops, logger, scorer);
+       let mut ret = lightning::routing::router::find_route::<crate::lightning::util::logger::Logger, crate::lightning::routing::scoring::Score>(&our_node_pubkey.into_rust(), route_params.get_native_ref(), network.get_native_ref(), local_first_hops, logger, scorer, unsafe { &*random_seed_bytes});
        let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::router::Route { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
        local_ret
 }
index 1a2394d6d15c2eacff0d6487a68904e33b528787..85def69b662a7b4a379fa73d11e496ecb3225228 100644 (file)
@@ -19,6 +19,7 @@
 //! # use lightning::routing::network_graph::NetworkGraph;
 //! # use lightning::routing::router::{RouteParameters, find_route};
 //! # use lightning::routing::scoring::{ProbabilisticScorer, ProbabilisticScoringParameters, Scorer, ScoringParameters};
+//! # use lightning::chain::keysinterface::{KeysManager, KeysInterface};
 //! # use lightning::util::logger::{Logger, Record};
 //! # use secp256k1::key::PublicKey;
 //! #
@@ -39,8 +40,9 @@
 //!     ..ProbabilisticScoringParameters::default()
 //! };
 //! let scorer = ProbabilisticScorer::new(params, &network_graph);
+//! # let random_seed_bytes = [42u8; 32];
 //!
-//! let route = find_route(&payer, &route_params, &network_graph, None, &logger, &scorer);
+//! let route = find_route(&payer, &route_params, &network_graph, None, &logger, &scorer, &random_seed_bytes);
 //! # }
 //! ```
 //!
@@ -309,21 +311,24 @@ impl FixedPenaltyScorer {
                ret
        }
 }
-#[no_mangle]
-/// Serialize the FixedPenaltyScorer object into a byte array which can be read by FixedPenaltyScorer_read
-pub extern "C" fn FixedPenaltyScorer_write(obj: &FixedPenaltyScorer) -> crate::c_types::derived::CVec_u8Z {
-       crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
+impl Clone for FixedPenaltyScorer {
+       fn clone(&self) -> Self {
+               Self {
+                       inner: if <*mut nativeFixedPenaltyScorer>::is_null(self.inner) { core::ptr::null_mut() } else {
+                               ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
+                       is_owned: true,
+               }
+       }
 }
-#[no_mangle]
-pub(crate) extern "C" fn FixedPenaltyScorer_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
-       crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFixedPenaltyScorer) })
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn FixedPenaltyScorer_clone_void(this_ptr: *const c_void) -> *mut c_void {
+       Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeFixedPenaltyScorer)).clone() })) as *mut c_void
 }
 #[no_mangle]
-/// Read a FixedPenaltyScorer from a byte array, created by FixedPenaltyScorer_write
-pub extern "C" fn FixedPenaltyScorer_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FixedPenaltyScorerDecodeErrorZ {
-       let res: Result<lightning::routing::scoring::FixedPenaltyScorer, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
-       let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::scoring::FixedPenaltyScorer { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
-       local_res
+/// Creates a copy of the FixedPenaltyScorer
+pub extern "C" fn FixedPenaltyScorer_clone(orig: &FixedPenaltyScorer) -> FixedPenaltyScorer {
+       orig.clone()
 }
 /// Creates a new scorer using `penalty_msat`.
 #[must_use]
@@ -371,6 +376,23 @@ extern "C" fn FixedPenaltyScorer_Score_payment_path_successful(this_arg: *mut c_
        <nativeFixedPenaltyScorer as lightning::routing::scoring::Score<>>::payment_path_successful(unsafe { &mut *(this_arg as *mut nativeFixedPenaltyScorer) }, &local__path[..])
 }
 
+#[no_mangle]
+/// Serialize the FixedPenaltyScorer object into a byte array which can be read by FixedPenaltyScorer_read
+pub extern "C" fn FixedPenaltyScorer_write(obj: &FixedPenaltyScorer) -> crate::c_types::derived::CVec_u8Z {
+       crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
+}
+#[no_mangle]
+pub(crate) extern "C" fn FixedPenaltyScorer_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
+       crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFixedPenaltyScorer) })
+}
+#[no_mangle]
+/// Read a FixedPenaltyScorer from a byte array, created by FixedPenaltyScorer_write
+pub extern "C" fn FixedPenaltyScorer_read(ser: crate::c_types::u8slice, arg: u64) -> crate::c_types::derived::CResult_FixedPenaltyScorerDecodeErrorZ {
+       let arg_conv = arg;
+       let res: Result<lightning::routing::scoring::FixedPenaltyScorer, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj_arg(ser, arg_conv);
+       let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::scoring::FixedPenaltyScorer { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
+       local_res
+}
 
 use lightning::routing::scoring::Scorer as nativeScorerImport;
 pub(crate) type nativeScorer = nativeScorerImport;
@@ -616,6 +638,25 @@ pub extern "C" fn ScoringParameters_new(mut base_penalty_msat_arg: u64, mut fail
                failure_penalty_half_life: core::time::Duration::from_secs(failure_penalty_half_life_arg),
        }), is_owned: true }
 }
+impl Clone for ScoringParameters {
+       fn clone(&self) -> Self {
+               Self {
+                       inner: if <*mut nativeScoringParameters>::is_null(self.inner) { core::ptr::null_mut() } else {
+                               ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
+                       is_owned: true,
+               }
+       }
+}
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn ScoringParameters_clone_void(this_ptr: *const c_void) -> *mut c_void {
+       Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeScoringParameters)).clone() })) as *mut c_void
+}
+#[no_mangle]
+/// Creates a copy of the ScoringParameters
+pub extern "C" fn ScoringParameters_clone(orig: &ScoringParameters) -> ScoringParameters {
+       orig.clone()
+}
 #[no_mangle]
 /// Serialize the ScoringParameters object into a byte array which can be read by ScoringParameters_read
 pub extern "C" fn ScoringParameters_write(obj: &ScoringParameters) -> crate::c_types::derived::CVec_u8Z {
@@ -783,6 +824,9 @@ use lightning::routing::scoring::ProbabilisticScoringParameters as nativeProbabi
 pub(crate) type nativeProbabilisticScoringParameters = nativeProbabilisticScoringParametersImport;
 
 /// Parameters for configuring [`ProbabilisticScorer`].
+///
+/// Used to configure base, liquidity, and amount penalties, the sum of which comprises the channel
+/// penalty (i.e., the amount in msats willing to be paid to avoid routing through the channel).
 #[must_use]
 #[repr(C)]
 pub struct ProbabilisticScoringParameters {
@@ -829,17 +873,32 @@ impl ProbabilisticScoringParameters {
                ret
        }
 }
-/// A multiplier used to determine the amount in msats willing to be paid to avoid routing
-/// through a channel, as per multiplying by the negative `log10` of the channel's success
-/// probability for a payment.
+/// A fixed penalty in msats to apply to each channel.
 ///
-/// The success probability is determined by the effective channel capacity, the payment amount,
-/// and knowledge learned from prior successful and unsuccessful payments. The lower bound of
-/// the success probability is 0.01, effectively limiting the penalty to the range
-/// `0..=2*liquidity_penalty_multiplier_msat`. The knowledge learned is decayed over time based
-/// on [`liquidity_offset_half_life`].
+/// Default value: 500 msat
+#[no_mangle]
+pub extern "C" fn ProbabilisticScoringParameters_get_base_penalty_msat(this_ptr: &ProbabilisticScoringParameters) -> u64 {
+       let mut inner_val = &mut this_ptr.get_native_mut_ref().base_penalty_msat;
+       *inner_val
+}
+/// A fixed penalty in msats to apply to each channel.
 ///
-/// Default value: 10,000 msat
+/// Default value: 500 msat
+#[no_mangle]
+pub extern "C" fn ProbabilisticScoringParameters_set_base_penalty_msat(this_ptr: &mut ProbabilisticScoringParameters, mut val: u64) {
+       unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.base_penalty_msat = val;
+}
+/// A multiplier used in conjunction with the negative `log10` of the channel's success
+/// probability for a payment to determine the liquidity penalty.
+///
+/// The penalty is based in part on the knowledge learned from prior successful and unsuccessful
+/// payments. This knowledge is decayed over time based on [`liquidity_offset_half_life`]. The
+/// penalty is effectively limited to `2 * liquidity_penalty_multiplier_msat` (corresponding to
+/// lower bounding the success probability to `0.01`) when the amount falls within the
+/// uncertainty bounds of the channel liquidity balance. Amounts above the upper bound will
+/// result in a `u64::max_value` penalty, however.
+///
+/// Default value: 40,000 msat
 ///
 /// [`liquidity_offset_half_life`]: Self::liquidity_offset_half_life
 #[no_mangle]
@@ -847,17 +906,17 @@ pub extern "C" fn ProbabilisticScoringParameters_get_liquidity_penalty_multiplie
        let mut inner_val = &mut this_ptr.get_native_mut_ref().liquidity_penalty_multiplier_msat;
        *inner_val
 }
-/// A multiplier used to determine the amount in msats willing to be paid to avoid routing
-/// through a channel, as per multiplying by the negative `log10` of the channel's success
-/// probability for a payment.
+/// A multiplier used in conjunction with the negative `log10` of the channel's success
+/// probability for a payment to determine the liquidity penalty.
 ///
-/// The success probability is determined by the effective channel capacity, the payment amount,
-/// and knowledge learned from prior successful and unsuccessful payments. The lower bound of
-/// the success probability is 0.01, effectively limiting the penalty to the range
-/// `0..=2*liquidity_penalty_multiplier_msat`. The knowledge learned is decayed over time based
-/// on [`liquidity_offset_half_life`].
+/// The penalty is based in part on the knowledge learned from prior successful and unsuccessful
+/// payments. This knowledge is decayed over time based on [`liquidity_offset_half_life`]. The
+/// penalty is effectively limited to `2 * liquidity_penalty_multiplier_msat` (corresponding to
+/// lower bounding the success probability to `0.01`) when the amount falls within the
+/// uncertainty bounds of the channel liquidity balance. Amounts above the upper bound will
+/// result in a `u64::max_value` penalty, however.
 ///
-/// Default value: 10,000 msat
+/// Default value: 40,000 msat
 ///
 /// [`liquidity_offset_half_life`]: Self::liquidity_offset_half_life
 #[no_mangle]
@@ -899,13 +958,58 @@ pub extern "C" fn ProbabilisticScoringParameters_get_liquidity_offset_half_life(
 pub extern "C" fn ProbabilisticScoringParameters_set_liquidity_offset_half_life(this_ptr: &mut ProbabilisticScoringParameters, mut val: u64) {
        unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.liquidity_offset_half_life = core::time::Duration::from_secs(val);
 }
+/// A multiplier used in conjunction with a payment amount and the negative `log10` of the
+/// channel's success probability for the payment to determine the amount penalty.
+///
+/// The purpose of the amount penalty is to avoid having fees dominate the channel cost (i.e.,
+/// fees plus penalty) for large payments. The penalty is computed as the product of this
+/// multiplier and `2^20`ths of the payment amount, weighted by the negative `log10` of the
+/// success probability.
+///
+/// `-log10(success_probability) * amount_penalty_multiplier_msat * amount_msat / 2^20`
+///
+/// In practice, this means for 0.1 success probability (`-log10(0.1) == 1`) each `2^20`th of
+/// the amount will result in a penalty of the multiplier. And, as the success probability
+/// decreases, the negative `log10` weighting will increase dramatically. For higher success
+/// probabilities, the multiplier will have a decreasing effect as the negative `log10` will
+/// fall below `1`.
+///
+/// Default value: 256 msat
+#[no_mangle]
+pub extern "C" fn ProbabilisticScoringParameters_get_amount_penalty_multiplier_msat(this_ptr: &ProbabilisticScoringParameters) -> u64 {
+       let mut inner_val = &mut this_ptr.get_native_mut_ref().amount_penalty_multiplier_msat;
+       *inner_val
+}
+/// A multiplier used in conjunction with a payment amount and the negative `log10` of the
+/// channel's success probability for the payment to determine the amount penalty.
+///
+/// The purpose of the amount penalty is to avoid having fees dominate the channel cost (i.e.,
+/// fees plus penalty) for large payments. The penalty is computed as the product of this
+/// multiplier and `2^20`ths of the payment amount, weighted by the negative `log10` of the
+/// success probability.
+///
+/// `-log10(success_probability) * amount_penalty_multiplier_msat * amount_msat / 2^20`
+///
+/// In practice, this means for 0.1 success probability (`-log10(0.1) == 1`) each `2^20`th of
+/// the amount will result in a penalty of the multiplier. And, as the success probability
+/// decreases, the negative `log10` weighting will increase dramatically. For higher success
+/// probabilities, the multiplier will have a decreasing effect as the negative `log10` will
+/// fall below `1`.
+///
+/// Default value: 256 msat
+#[no_mangle]
+pub extern "C" fn ProbabilisticScoringParameters_set_amount_penalty_multiplier_msat(this_ptr: &mut ProbabilisticScoringParameters, mut val: u64) {
+       unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.amount_penalty_multiplier_msat = val;
+}
 /// Constructs a new ProbabilisticScoringParameters given each field
 #[must_use]
 #[no_mangle]
-pub extern "C" fn ProbabilisticScoringParameters_new(mut liquidity_penalty_multiplier_msat_arg: u64, mut liquidity_offset_half_life_arg: u64) -> ProbabilisticScoringParameters {
+pub extern "C" fn ProbabilisticScoringParameters_new(mut base_penalty_msat_arg: u64, mut liquidity_penalty_multiplier_msat_arg: u64, mut liquidity_offset_half_life_arg: u64, mut amount_penalty_multiplier_msat_arg: u64) -> ProbabilisticScoringParameters {
        ProbabilisticScoringParameters { inner: ObjOps::heap_alloc(nativeProbabilisticScoringParameters {
+               base_penalty_msat: base_penalty_msat_arg,
                liquidity_penalty_multiplier_msat: liquidity_penalty_multiplier_msat_arg,
                liquidity_offset_half_life: core::time::Duration::from_secs(liquidity_offset_half_life_arg),
+               amount_penalty_multiplier_msat: amount_penalty_multiplier_msat_arg,
        }), is_owned: true }
 }
 impl Clone for ProbabilisticScoringParameters {
@@ -927,22 +1031,6 @@ pub(crate) extern "C" fn ProbabilisticScoringParameters_clone_void(this_ptr: *co
 pub extern "C" fn ProbabilisticScoringParameters_clone(orig: &ProbabilisticScoringParameters) -> ProbabilisticScoringParameters {
        orig.clone()
 }
-#[no_mangle]
-/// Serialize the ProbabilisticScoringParameters object into a byte array which can be read by ProbabilisticScoringParameters_read
-pub extern "C" fn ProbabilisticScoringParameters_write(obj: &ProbabilisticScoringParameters) -> crate::c_types::derived::CVec_u8Z {
-       crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
-}
-#[no_mangle]
-pub(crate) extern "C" fn ProbabilisticScoringParameters_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
-       crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeProbabilisticScoringParameters) })
-}
-#[no_mangle]
-/// Read a ProbabilisticScoringParameters from a byte array, created by ProbabilisticScoringParameters_write
-pub extern "C" fn ProbabilisticScoringParameters_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ProbabilisticScoringParametersDecodeErrorZ {
-       let res: Result<lightning::routing::scoring::ProbabilisticScoringParameters, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
-       let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::scoring::ProbabilisticScoringParameters { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
-       local_res
-}
 /// Creates a new scorer using the given scoring parameters for sending payments from a node
 /// through a network graph.
 #[must_use]
@@ -996,6 +1084,17 @@ extern "C" fn ProbabilisticScorer_Score_payment_path_successful(this_arg: *mut c
        <nativeProbabilisticScorer as lightning::routing::scoring::Score<>>::payment_path_successful(unsafe { &mut *(this_arg as *mut nativeProbabilisticScorer) }, &local_path[..])
 }
 
+mod approx {
+
+use alloc::str::FromStr;
+use core::ffi::c_void;
+use core::convert::Infallible;
+use bitcoin::hashes::Hash;
+use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
+
+}
 #[no_mangle]
 /// Serialize the ProbabilisticScorer object into a byte array which can be read by ProbabilisticScorer_read
 pub extern "C" fn ProbabilisticScorer_write(obj: &ProbabilisticScorer) -> crate::c_types::derived::CVec_u8Z {
index bf1972f7525923a2fba8f1d142c5c7f196b76b1c..13485b9508c2d93a01d4721ba47e660a61ee062c 100644 (file)
@@ -151,14 +151,66 @@ pub extern "C" fn ChannelHandshakeConfig_get_our_htlc_minimum_msat(this_ptr: &Ch
 pub extern "C" fn ChannelHandshakeConfig_set_our_htlc_minimum_msat(this_ptr: &mut ChannelHandshakeConfig, mut val: u64) {
        unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.our_htlc_minimum_msat = val;
 }
+/// If set, we attempt to negotiate the `scid_privacy` (referred to as `scid_alias` in the
+/// BOLTs) option for outbound private channels. This provides better privacy by not including
+/// our real on-chain channel UTXO in each invoice and requiring that our counterparty only
+/// relay HTLCs to us using the channel's SCID alias.
+///
+/// If this option is set, channels may be created that will not be readable by LDK versions
+/// prior to 0.0.106, causing [`ChannelManager`]'s read method to return a
+/// [`DecodeError:InvalidValue`].
+///
+/// Note that setting this to true does *not* prevent us from opening channels with
+/// counterparties that do not support the `scid_alias` option; we will simply fall back to a
+/// private channel without that option.
+///
+/// Ignored if the channel is negotiated to be announced, see
+/// [`ChannelConfig::announced_channel`] and
+/// [`ChannelHandshakeLimits::force_announced_channel_preference`] for more.
+///
+/// Default value: false. This value is likely to change to true in the future.
+///
+/// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
+/// [`DecodeError:InvalidValue`]: crate::ln::msgs::DecodeError::InvalidValue
+#[no_mangle]
+pub extern "C" fn ChannelHandshakeConfig_get_negotiate_scid_privacy(this_ptr: &ChannelHandshakeConfig) -> bool {
+       let mut inner_val = &mut this_ptr.get_native_mut_ref().negotiate_scid_privacy;
+       *inner_val
+}
+/// If set, we attempt to negotiate the `scid_privacy` (referred to as `scid_alias` in the
+/// BOLTs) option for outbound private channels. This provides better privacy by not including
+/// our real on-chain channel UTXO in each invoice and requiring that our counterparty only
+/// relay HTLCs to us using the channel's SCID alias.
+///
+/// If this option is set, channels may be created that will not be readable by LDK versions
+/// prior to 0.0.106, causing [`ChannelManager`]'s read method to return a
+/// [`DecodeError:InvalidValue`].
+///
+/// Note that setting this to true does *not* prevent us from opening channels with
+/// counterparties that do not support the `scid_alias` option; we will simply fall back to a
+/// private channel without that option.
+///
+/// Ignored if the channel is negotiated to be announced, see
+/// [`ChannelConfig::announced_channel`] and
+/// [`ChannelHandshakeLimits::force_announced_channel_preference`] for more.
+///
+/// Default value: false. This value is likely to change to true in the future.
+///
+/// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
+/// [`DecodeError:InvalidValue`]: crate::ln::msgs::DecodeError::InvalidValue
+#[no_mangle]
+pub extern "C" fn ChannelHandshakeConfig_set_negotiate_scid_privacy(this_ptr: &mut ChannelHandshakeConfig, mut val: bool) {
+       unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.negotiate_scid_privacy = val;
+}
 /// Constructs a new ChannelHandshakeConfig given each field
 #[must_use]
 #[no_mangle]
-pub extern "C" fn ChannelHandshakeConfig_new(mut minimum_depth_arg: u32, mut our_to_self_delay_arg: u16, mut our_htlc_minimum_msat_arg: u64) -> ChannelHandshakeConfig {
+pub extern "C" fn ChannelHandshakeConfig_new(mut minimum_depth_arg: u32, mut our_to_self_delay_arg: u16, mut our_htlc_minimum_msat_arg: u64, mut negotiate_scid_privacy_arg: bool) -> ChannelHandshakeConfig {
        ChannelHandshakeConfig { inner: ObjOps::heap_alloc(nativeChannelHandshakeConfig {
                minimum_depth: minimum_depth_arg,
                our_to_self_delay: our_to_self_delay_arg,
                our_htlc_minimum_msat: our_htlc_minimum_msat_arg,
+               negotiate_scid_privacy: negotiate_scid_privacy_arg,
        }), is_owned: true }
 }
 impl Clone for ChannelHandshakeConfig {
index c284ddc8cb4c91133caaeb2cfd0e6dd8581611ab..02fd0edf07ec3f757d36b6d3b996472851408dbc 100644 (file)
@@ -571,11 +571,15 @@ pub enum Event {
                /// The channel_id of the channel which has been closed. Note that on-chain transactions
                /// resolving the channel are likely still awaiting confirmation.
                channel_id: crate::c_types::ThirtyTwoBytes,
-               /// The `user_channel_id` value passed in to [`ChannelManager::create_channel`], or 0 for
-               /// an inbound channel. This will always be zero for objects serialized with LDK versions
-               /// prior to 0.0.102.
+               /// The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound
+               /// channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if
+               /// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise
+               /// `user_channel_id` will be 0 for an inbound channel.
+               /// This will always be zero for objects serialized with LDK versions prior to 0.0.102.
                ///
                /// [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
+               /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
+               /// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
                user_channel_id: u64,
                /// The reason the channel was closed.
                reason: crate::lightning::util::events::ClosureReason,
@@ -637,6 +641,16 @@ pub enum Event {
                funding_satoshis: u64,
                /// Our starting balance in the channel if the request is accepted, in milli-satoshi.
                push_msat: u64,
+               /// The features that this channel will operate with. If you reject the channel, a
+               /// well-behaved counterparty may automatically re-attempt the channel with a new set of
+               /// feature flags.
+               ///
+               /// Note that if [`ChannelTypeFeatures::supports_scid_privacy`] returns true on this type,
+               /// the resulting [`ChannelManager`] will not be readable by versions of LDK prior to
+               /// 0.0.106.
+               ///
+               /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
+               channel_type: crate::lightning::ln::features::ChannelTypeFeatures,
        },
 }
 use lightning::util::events::Event as nativeEvent;
@@ -765,16 +779,18 @@ impl Event {
                                        path: local_path_nonref,
                                }
                        },
-                       Event::OpenChannelRequest {ref temporary_channel_id, ref counterparty_node_id, ref funding_satoshis, ref push_msat, } => {
+                       Event::OpenChannelRequest {ref temporary_channel_id, ref counterparty_node_id, ref funding_satoshis, ref push_msat, ref channel_type, } => {
                                let mut temporary_channel_id_nonref = (*temporary_channel_id).clone();
                                let mut counterparty_node_id_nonref = (*counterparty_node_id).clone();
                                let mut funding_satoshis_nonref = (*funding_satoshis).clone();
                                let mut push_msat_nonref = (*push_msat).clone();
+                               let mut channel_type_nonref = (*channel_type).clone();
                                nativeEvent::OpenChannelRequest {
                                        temporary_channel_id: temporary_channel_id_nonref.data,
                                        counterparty_node_id: counterparty_node_id_nonref.into_rust(),
                                        funding_satoshis: funding_satoshis_nonref,
                                        push_msat: push_msat_nonref,
+                                       channel_type: *unsafe { Box::from_raw(channel_type_nonref.take_inner()) },
                                }
                        },
                }
@@ -870,12 +886,13 @@ impl Event {
                                        path: local_path,
                                }
                        },
-                       Event::OpenChannelRequest {mut temporary_channel_id, mut counterparty_node_id, mut funding_satoshis, mut push_msat, } => {
+                       Event::OpenChannelRequest {mut temporary_channel_id, mut counterparty_node_id, mut funding_satoshis, mut push_msat, mut channel_type, } => {
                                nativeEvent::OpenChannelRequest {
                                        temporary_channel_id: temporary_channel_id.data,
                                        counterparty_node_id: counterparty_node_id.into_rust(),
                                        funding_satoshis: funding_satoshis,
                                        push_msat: push_msat,
+                                       channel_type: *unsafe { Box::from_raw(channel_type.take_inner()) },
                                }
                        },
                }
@@ -1004,16 +1021,18 @@ impl Event {
                                        path: local_path_nonref.into(),
                                }
                        },
-                       nativeEvent::OpenChannelRequest {ref temporary_channel_id, ref counterparty_node_id, ref funding_satoshis, ref push_msat, } => {
+                       nativeEvent::OpenChannelRequest {ref temporary_channel_id, ref counterparty_node_id, ref funding_satoshis, ref push_msat, ref channel_type, } => {
                                let mut temporary_channel_id_nonref = (*temporary_channel_id).clone();
                                let mut counterparty_node_id_nonref = (*counterparty_node_id).clone();
                                let mut funding_satoshis_nonref = (*funding_satoshis).clone();
                                let mut push_msat_nonref = (*push_msat).clone();
+                               let mut channel_type_nonref = (*channel_type).clone();
                                Event::OpenChannelRequest {
                                        temporary_channel_id: crate::c_types::ThirtyTwoBytes { data: temporary_channel_id_nonref },
                                        counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id_nonref),
                                        funding_satoshis: funding_satoshis_nonref,
                                        push_msat: push_msat_nonref,
+                                       channel_type: crate::lightning::ln::features::ChannelTypeFeatures { inner: ObjOps::heap_alloc(channel_type_nonref), is_owned: true },
                                }
                        },
                }
@@ -1109,12 +1128,13 @@ impl Event {
                                        path: local_path.into(),
                                }
                        },
-                       nativeEvent::OpenChannelRequest {mut temporary_channel_id, mut counterparty_node_id, mut funding_satoshis, mut push_msat, } => {
+                       nativeEvent::OpenChannelRequest {mut temporary_channel_id, mut counterparty_node_id, mut funding_satoshis, mut push_msat, mut channel_type, } => {
                                Event::OpenChannelRequest {
                                        temporary_channel_id: crate::c_types::ThirtyTwoBytes { data: temporary_channel_id },
                                        counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id),
                                        funding_satoshis: funding_satoshis,
                                        push_msat: push_msat,
+                                       channel_type: crate::lightning::ln::features::ChannelTypeFeatures { inner: ObjOps::heap_alloc(channel_type), is_owned: true },
                                }
                        },
                }
@@ -1229,12 +1249,13 @@ pub extern "C" fn Event_payment_path_successful(payment_id: crate::c_types::Thir
 }
 #[no_mangle]
 /// Utility method to constructs a new OpenChannelRequest-variant Event
-pub extern "C" fn Event_open_channel_request(temporary_channel_id: crate::c_types::ThirtyTwoBytes, counterparty_node_id: crate::c_types::PublicKey, funding_satoshis: u64, push_msat: u64) -> Event {
+pub extern "C" fn Event_open_channel_request(temporary_channel_id: crate::c_types::ThirtyTwoBytes, counterparty_node_id: crate::c_types::PublicKey, funding_satoshis: u64, push_msat: u64, channel_type: crate::lightning::ln::features::ChannelTypeFeatures) -> Event {
        Event::OpenChannelRequest {
                temporary_channel_id,
                counterparty_node_id,
                funding_satoshis,
                push_msat,
+               channel_type,
        }
 }
 #[no_mangle]
@@ -1399,6 +1420,14 @@ pub enum MessageSendEvent {
                /// The reply_channel_range which should be sent.
                msg: crate::lightning::ln::msgs::ReplyChannelRange,
        },
+       /// Sends a timestamp filter for inbound gossip. This should be sent on each new connection to
+       /// enable receiving gossip messages from the peer.
+       SendGossipTimestampFilter {
+               /// The node_id of this message recipient
+               node_id: crate::c_types::PublicKey,
+               /// The gossip_timestamp_filter which should be sent.
+               msg: crate::lightning::ln::msgs::GossipTimestampFilter,
+       },
 }
 use lightning::util::events::MessageSendEvent as nativeMessageSendEvent;
 impl MessageSendEvent {
@@ -1553,6 +1582,14 @@ impl MessageSendEvent {
                                        msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
                                }
                        },
+                       MessageSendEvent::SendGossipTimestampFilter {ref node_id, ref msg, } => {
+                               let mut node_id_nonref = (*node_id).clone();
+                               let mut msg_nonref = (*msg).clone();
+                               nativeMessageSendEvent::SendGossipTimestampFilter {
+                                       node_id: node_id_nonref.into_rust(),
+                                       msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
+                               }
+                       },
                }
        }
        #[allow(unused)]
@@ -1670,6 +1707,12 @@ impl MessageSendEvent {
                                        msg: *unsafe { Box::from_raw(msg.take_inner()) },
                                }
                        },
+                       MessageSendEvent::SendGossipTimestampFilter {mut node_id, mut msg, } => {
+                               nativeMessageSendEvent::SendGossipTimestampFilter {
+                                       node_id: node_id.into_rust(),
+                                       msg: *unsafe { Box::from_raw(msg.take_inner()) },
+                               }
+                       },
                }
        }
        #[allow(unused)]
@@ -1823,6 +1866,14 @@ impl MessageSendEvent {
                                        msg: crate::lightning::ln::msgs::ReplyChannelRange { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
                                }
                        },
+                       nativeMessageSendEvent::SendGossipTimestampFilter {ref node_id, ref msg, } => {
+                               let mut node_id_nonref = (*node_id).clone();
+                               let mut msg_nonref = (*msg).clone();
+                               MessageSendEvent::SendGossipTimestampFilter {
+                                       node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
+                                       msg: crate::lightning::ln::msgs::GossipTimestampFilter { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
+                               }
+                       },
                }
        }
        #[allow(unused)]
@@ -1940,6 +1991,12 @@ impl MessageSendEvent {
                                        msg: crate::lightning::ln::msgs::ReplyChannelRange { inner: ObjOps::heap_alloc(msg), is_owned: true },
                                }
                        },
+                       nativeMessageSendEvent::SendGossipTimestampFilter {mut node_id, mut msg, } => {
+                               MessageSendEvent::SendGossipTimestampFilter {
+                                       node_id: crate::c_types::PublicKey::from_rust(&node_id),
+                                       msg: crate::lightning::ln::msgs::GossipTimestampFilter { inner: ObjOps::heap_alloc(msg), is_owned: true },
+                               }
+                       },
                }
        }
 }
@@ -2101,6 +2158,14 @@ pub extern "C" fn MessageSendEvent_send_reply_channel_range(node_id: crate::c_ty
                msg,
        }
 }
+#[no_mangle]
+/// Utility method to constructs a new SendGossipTimestampFilter-variant MessageSendEvent
+pub extern "C" fn MessageSendEvent_send_gossip_timestamp_filter(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::GossipTimestampFilter) -> MessageSendEvent {
+       MessageSendEvent::SendGossipTimestampFilter {
+               node_id,
+               msg,
+       }
+}
 /// A trait indicating an object may generate message send events
 #[repr(C)]
 pub struct MessageSendEventsProvider {
index 0bd445298b0e5c89383ccb29a508d13545031f9e..ba51e42eeab2d1d920388040bcef3b7d5e3c7f9e 100644 (file)
@@ -93,47 +93,52 @@ impl BackgroundProcessor {
                ret
        }
 }
-/// Trait which handles persisting a [`ChannelManager`] to disk.
-///
-/// [`ChannelManager`]: lightning::ln::channelmanager::ChannelManager
+/// Trait that handles persisting a [`ChannelManager`] and [`NetworkGraph`] to disk.
 #[repr(C)]
-pub struct ChannelManagerPersister {
+pub struct Persister {
        /// 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,
        /// Persist the given [`ChannelManager`] to disk, returning an error if persistence failed
-       /// (which will cause the [`BackgroundProcessor`] which called this method to exit.
-       ///
-       /// [`ChannelManager`]: lightning::ln::channelmanager::ChannelManager
+       /// (which will cause the [`BackgroundProcessor`] which called this method to exit).
        #[must_use]
        pub persist_manager: extern "C" fn (this_arg: *const c_void, channel_manager: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::c_types::derived::CResult_NoneErrorZ,
+       /// Persist the given [`NetworkGraph`] to disk, returning an error if persistence failed.
+       #[must_use]
+       pub persist_graph: extern "C" fn (this_arg: *const c_void, network_graph: &crate::lightning::routing::network_graph::NetworkGraph) -> crate::c_types::derived::CResult_NoneErrorZ,
        /// 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)>,
 }
-unsafe impl Send for ChannelManagerPersister {}
-unsafe impl Sync for ChannelManagerPersister {}
+unsafe impl Send for Persister {}
+unsafe impl Sync for Persister {}
 #[no_mangle]
-pub(crate) extern "C" fn ChannelManagerPersister_clone_fields(orig: &ChannelManagerPersister) -> ChannelManagerPersister {
-       ChannelManagerPersister {
+pub(crate) extern "C" fn Persister_clone_fields(orig: &Persister) -> Persister {
+       Persister {
                this_arg: orig.this_arg,
                persist_manager: Clone::clone(&orig.persist_manager),
+               persist_graph: Clone::clone(&orig.persist_graph),
                free: Clone::clone(&orig.free),
        }
 }
 
-use lightning_background_processor::ChannelManagerPersister as rustChannelManagerPersister;
-impl rustChannelManagerPersister<crate::lightning::chain::keysinterface::Sign, crate::lightning::chain::Watch, crate::lightning::chain::chaininterface::BroadcasterInterface, crate::lightning::chain::keysinterface::KeysInterface, crate::lightning::chain::chaininterface::FeeEstimator, crate::lightning::util::logger::Logger> for ChannelManagerPersister {
+use lightning_background_processor::Persister as rustPersister;
+impl rustPersister<crate::lightning::chain::keysinterface::Sign, crate::lightning::chain::Watch, crate::lightning::chain::chaininterface::BroadcasterInterface, crate::lightning::chain::keysinterface::KeysInterface, crate::lightning::chain::chaininterface::FeeEstimator, crate::lightning::util::logger::Logger> for Persister {
        fn persist_manager(&self, mut channel_manager: &lightning::ln::channelmanager::ChannelManager<crate::lightning::chain::keysinterface::Sign, crate::lightning::chain::Watch, crate::lightning::chain::chaininterface::BroadcasterInterface, crate::lightning::chain::keysinterface::KeysInterface, crate::lightning::chain::chaininterface::FeeEstimator, crate::lightning::util::logger::Logger>) -> Result<(), std::io::Error> {
                let mut ret = (self.persist_manager)(self.this_arg, &crate::lightning::ln::channelmanager::ChannelManager { inner: unsafe { ObjOps::nonnull_ptr_to_inner((channel_manager as *const lightning::ln::channelmanager::ChannelManager<_, _, _, _, _, _, >) 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)) })*/ }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).to_rust() })};
                local_ret
        }
+       fn persist_graph(&self, mut network_graph: &lightning::routing::network_graph::NetworkGraph) -> Result<(), std::io::Error> {
+               let mut ret = (self.persist_graph)(self.this_arg, &crate::lightning::routing::network_graph::NetworkGraph { inner: unsafe { ObjOps::nonnull_ptr_to_inner((network_graph as *const lightning::routing::network_graph::NetworkGraph<>) 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)) })*/ }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).to_rust() })};
+               local_ret
+       }
 }
 
 // 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 core::ops::Deref for ChannelManagerPersister {
+impl core::ops::Deref for Persister {
        type Target = Self;
        fn deref(&self) -> &Self {
                self
@@ -141,8 +146,8 @@ impl core::ops::Deref for ChannelManagerPersister {
 }
 /// Calls the free function if one is set
 #[no_mangle]
-pub extern "C" fn ChannelManagerPersister_free(this_ptr: ChannelManagerPersister) { }
-impl Drop for ChannelManagerPersister {
+pub extern "C" fn Persister_free(this_ptr: Persister) { }
+impl Drop for Persister {
        fn drop(&mut self) {
                if let Some(f) = self.free {
                        f(self.this_arg);
@@ -153,17 +158,21 @@ impl Drop for ChannelManagerPersister {
 /// documentation].
 ///
 /// The thread runs indefinitely unless the object is dropped, [`stop`] is called, or
-/// `persist_manager` returns an error. In case of an error, the error is retrieved by calling
+/// [`Persister::persist_manager`] returns an error. In case of an error, the error is retrieved by calling
 /// either [`join`] or [`stop`].
 ///
 /// # Data Persistence
 ///
-/// `persist_manager` is responsible for writing out the [`ChannelManager`] to disk, and/or
+/// [`Persister::persist_manager`] is responsible for writing out the [`ChannelManager`] to disk, and/or
 /// uploading to one or more backup services. See [`ChannelManager::write`] for writing out a
 /// [`ChannelManager`]. See [`FilesystemPersister::persist_manager`] for Rust-Lightning's
 /// provided implementation.
 ///
-/// Typically, users should either implement [`ChannelManagerPersister`] to never return an
+/// [`Persister::persist_graph`] is responsible for writing out the [`NetworkGraph`] to disk. See
+/// [`NetworkGraph::write`] for writing out a [`NetworkGraph`]. See [`FilesystemPersister::persist_network_graph`]
+/// for Rust-Lightning's provided implementation.
+///
+/// Typically, users should either implement [`Persister::persist_manager`] to never return an
 /// error or call [`join`] and handle any error that may arise. For the latter case,
 /// `BackgroundProcessor` must be restarted by calling `start` again after handling the error.
 ///
@@ -180,12 +189,14 @@ impl Drop for ChannelManagerPersister {
 /// [`ChannelManager`]: lightning::ln::channelmanager::ChannelManager
 /// [`ChannelManager::write`]: lightning::ln::channelmanager::ChannelManager#impl-Writeable
 /// [`FilesystemPersister::persist_manager`]: lightning_persister::FilesystemPersister::persist_manager
+/// [`FilesystemPersister::persist_network_graph`]: lightning_persister::FilesystemPersister::persist_network_graph
 /// [`NetworkGraph`]: lightning::routing::network_graph::NetworkGraph
+/// [`NetworkGraph::write`]: lightning::routing::network_graph::NetworkGraph#impl-Writeable
 ///
 /// Note that net_graph_msg_handler (or a relevant inner pointer) may be NULL or all-0s to represent None
 #[must_use]
 #[no_mangle]
-pub extern "C" fn BackgroundProcessor_start(mut persister: crate::lightning_background_processor::ChannelManagerPersister, mut event_handler: crate::lightning::util::events::EventHandler, chain_monitor: &crate::lightning::chain::chainmonitor::ChainMonitor, channel_manager: &crate::lightning::ln::channelmanager::ChannelManager, mut net_graph_msg_handler: crate::lightning::routing::network_graph::NetGraphMsgHandler, peer_manager: &crate::lightning::ln::peer_handler::PeerManager, mut logger: crate::lightning::util::logger::Logger) -> BackgroundProcessor {
+pub extern "C" fn BackgroundProcessor_start(mut persister: crate::lightning_background_processor::Persister, mut event_handler: crate::lightning::util::events::EventHandler, chain_monitor: &crate::lightning::chain::chainmonitor::ChainMonitor, channel_manager: &crate::lightning::ln::channelmanager::ChannelManager, mut net_graph_msg_handler: crate::lightning::routing::network_graph::NetGraphMsgHandler, peer_manager: &crate::lightning::ln::peer_handler::PeerManager, mut logger: crate::lightning::util::logger::Logger) -> BackgroundProcessor {
        let mut local_net_graph_msg_handler = if net_graph_msg_handler.inner.is_null() { None } else { Some( { net_graph_msg_handler.get_native_ref() }) };
        let mut ret = lightning_background_processor::BackgroundProcessor::start(persister, event_handler, chain_monitor.get_native_ref(), channel_manager.get_native_ref(), local_net_graph_msg_handler, peer_manager.get_native_ref(), logger);
        BackgroundProcessor { inner: ObjOps::heap_alloc(ret), is_owned: true }
index 29d658366b85e65eba14afdd38ae5682b700d7b8..4e182729280f1c57c41a37bd1e1a808bc27b53cd 100644 (file)
@@ -49,6 +49,41 @@ pub extern "C" fn create_phantom_invoice(mut amt_msat: crate::c_types::derived::
        local_ret
 }
 
+/// Utility to create an invoice that can be paid to one of multiple nodes, or a \"phantom invoice.\"
+/// See [`PhantomKeysManager`] for more information on phantom node payments.
+///
+/// `phantom_route_hints` parameter:
+/// * Contains channel info for all nodes participating in the phantom invoice
+/// * Entries are retrieved from a call to [`ChannelManager::get_phantom_route_hints`] on each
+///   participating node
+/// * It is fine to cache `phantom_route_hints` and reuse it across invoices, as long as the data is
+///   updated when a channel becomes disabled or closes
+/// * Note that if too many channels are included in [`PhantomRouteHints::channels`], the invoice
+///   may be too long for QR code scanning. To fix this, `PhantomRouteHints::channels` may be pared
+///   down
+///
+/// `description_hash` is a SHA-256 hash of the description text
+///
+/// `payment_hash` and `payment_secret` come from [`ChannelManager::create_inbound_payment`] or
+/// [`ChannelManager::create_inbound_payment_for_hash`]. These values can be retrieved from any
+/// participating node.
+///
+/// Note that the provided `keys_manager`'s `KeysInterface` implementation must support phantom
+/// invoices in its `sign_invoice` implementation ([`PhantomKeysManager`] satisfies this
+/// requirement).
+///
+/// [`PhantomKeysManager`]: lightning::chain::keysinterface::PhantomKeysManager
+/// [`ChannelManager::get_phantom_route_hints`]: lightning::ln::channelmanager::ChannelManager::get_phantom_route_hints
+/// [`PhantomRouteHints::channels`]: lightning::ln::channelmanager::PhantomRouteHints::channels
+#[no_mangle]
+pub extern "C" fn create_phantom_invoice_with_description_hash(mut amt_msat: crate::c_types::derived::COption_u64Z, mut description_hash: crate::lightning_invoice::Sha256, mut payment_hash: crate::c_types::ThirtyTwoBytes, mut payment_secret: crate::c_types::ThirtyTwoBytes, mut phantom_route_hints: crate::c_types::derived::CVec_PhantomRouteHintsZ, mut keys_manager: crate::lightning::chain::keysinterface::KeysInterface, mut network: crate::lightning_invoice::Currency) -> crate::c_types::derived::CResult_InvoiceSignOrCreationErrorZ {
+       let mut local_amt_msat = if amt_msat.is_some() { Some( { amt_msat.take() }) } else { None };
+       let mut local_phantom_route_hints = Vec::new(); for mut item in phantom_route_hints.into_rust().drain(..) { local_phantom_route_hints.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
+       let mut ret = lightning_invoice::utils::create_phantom_invoice_with_description_hash::<crate::lightning::chain::keysinterface::Sign, crate::lightning::chain::keysinterface::KeysInterface>(local_amt_msat, *unsafe { Box::from_raw(description_hash.take_inner()) }, ::lightning::ln::PaymentHash(payment_hash.data), ::lightning::ln::PaymentSecret(payment_secret.data), local_phantom_route_hints, keys_manager, network.into_native());
+       let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::Invoice { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::SignOrCreationError::native_into(e) }).into() };
+       local_ret
+}
+
 /// Utility to construct an invoice. Generally, unless you want to do something like a custom
 /// cltv_expiry, this is what you should be using to create an invoice. The reason being, this
 /// method stores the invoice's payment secret and preimage in `ChannelManager`, so (a) the user
@@ -62,6 +97,31 @@ pub extern "C" fn create_invoice_from_channelmanager(channelmanager: &crate::lig
        local_ret
 }
 
+/// Utility to construct an invoice. Generally, unless you want to do something like a custom
+/// cltv_expiry, this is what you should be using to create an invoice. The reason being, this
+/// method stores the invoice's payment secret and preimage in `ChannelManager`, so (a) the user
+/// doesn't have to store preimage/payment secret information and (b) `ChannelManager` can verify
+/// that the payment secret is valid when the invoice is paid.
+/// Use this variant if you want to pass the `description_hash` to the invoice.
+#[no_mangle]
+pub extern "C" fn create_invoice_from_channelmanager_with_description_hash(channelmanager: &crate::lightning::ln::channelmanager::ChannelManager, mut keys_manager: crate::lightning::chain::keysinterface::KeysInterface, mut network: crate::lightning_invoice::Currency, mut amt_msat: crate::c_types::derived::COption_u64Z, mut description_hash: crate::lightning_invoice::Sha256) -> crate::c_types::derived::CResult_InvoiceSignOrCreationErrorZ {
+       let mut local_amt_msat = if amt_msat.is_some() { Some( { amt_msat.take() }) } else { None };
+       let mut ret = lightning_invoice::utils::create_invoice_from_channelmanager_with_description_hash::<crate::lightning::chain::keysinterface::Sign, crate::lightning::chain::Watch, crate::lightning::chain::chaininterface::BroadcasterInterface, crate::lightning::chain::keysinterface::KeysInterface, crate::lightning::chain::chaininterface::FeeEstimator, crate::lightning::util::logger::Logger>(channelmanager.get_native_ref(), keys_manager, network.into_native(), local_amt_msat, *unsafe { Box::from_raw(description_hash.take_inner()) });
+       let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::Invoice { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::SignOrCreationError::native_into(e) }).into() };
+       local_ret
+}
+
+/// See [`create_invoice_from_channelmanager_with_description_hash`]
+/// This version can be used in a `no_std` environment, where [`std::time::SystemTime`] is not
+/// available and the current time is supplied by the caller.
+#[no_mangle]
+pub extern "C" fn create_invoice_from_channelmanager_with_description_hash_and_duration_since_epoch(channelmanager: &crate::lightning::ln::channelmanager::ChannelManager, mut keys_manager: crate::lightning::chain::keysinterface::KeysInterface, mut network: crate::lightning_invoice::Currency, mut amt_msat: crate::c_types::derived::COption_u64Z, mut description_hash: crate::lightning_invoice::Sha256, mut duration_since_epoch: u64) -> crate::c_types::derived::CResult_InvoiceSignOrCreationErrorZ {
+       let mut local_amt_msat = if amt_msat.is_some() { Some( { amt_msat.take() }) } else { None };
+       let mut ret = lightning_invoice::utils::create_invoice_from_channelmanager_with_description_hash_and_duration_since_epoch::<crate::lightning::chain::keysinterface::Sign, crate::lightning::chain::Watch, crate::lightning::chain::chaininterface::BroadcasterInterface, crate::lightning::chain::keysinterface::KeysInterface, crate::lightning::chain::chaininterface::FeeEstimator, crate::lightning::util::logger::Logger>(channelmanager.get_native_ref(), keys_manager, network.into_native(), local_amt_msat, *unsafe { Box::from_raw(description_hash.take_inner()) }, core::time::Duration::from_secs(duration_since_epoch));
+       let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::Invoice { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::SignOrCreationError::native_into(e) }).into() };
+       local_ret
+}
+
 /// See [`create_invoice_from_channelmanager`]
 /// This version can be used in a `no_std` environment, where [`std::time::SystemTime`] is not
 /// available and the current time is supplied by the caller.
@@ -124,11 +184,12 @@ impl DefaultRouter {
                ret
        }
 }
-/// Creates a new router using the given [`NetworkGraph`] and  [`Logger`].
+/// Creates a new router using the given [`NetworkGraph`], a [`Logger`], and a randomness source
+/// `random_seed_bytes`.
 #[must_use]
 #[no_mangle]
-pub extern "C" fn DefaultRouter_new(network_graph: &crate::lightning::routing::network_graph::NetworkGraph, mut logger: crate::lightning::util::logger::Logger) -> DefaultRouter {
-       let mut ret = lightning_invoice::utils::DefaultRouter::new(network_graph.get_native_ref(), logger);
+pub extern "C" fn DefaultRouter_new(network_graph: &crate::lightning::routing::network_graph::NetworkGraph, mut logger: crate::lightning::util::logger::Logger, mut random_seed_bytes: crate::c_types::ThirtyTwoBytes) -> DefaultRouter {
+       let mut ret = lightning_invoice::utils::DefaultRouter::new(network_graph.get_native_ref(), logger, random_seed_bytes.data);
        DefaultRouter { inner: ObjOps::heap_alloc(ret), is_owned: true }
 }
 
index 0ab058294e0301cda3882a3e7a1ccdbb40693947..cd112e9c488cf3ad608750bcd897125d9a204eef 100644 (file)
@@ -116,6 +116,16 @@ pub extern "C" fn FilesystemPersister_persist_manager(mut data_dir: crate::c_typ
        local_ret
 }
 
+/// Write the provided `NetworkGraph` to the path provided at `FilesystemPersister`
+/// initialization, within a file called \"network_graph\"
+#[must_use]
+#[no_mangle]
+pub extern "C" fn FilesystemPersister_persist_network_graph(mut data_dir: crate::c_types::Str, network_graph: &crate::lightning::routing::network_graph::NetworkGraph) -> crate::c_types::derived::CResult_NoneErrorZ {
+       let mut ret = lightning_persister::FilesystemPersister::persist_network_graph(data_dir.into_string(), network_graph.get_native_ref());
+       let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::c_types::IOError::from_rust(e) }).into() };
+       local_ret
+}
+
 /// Read `ChannelMonitor`s from disk.
 #[must_use]
 #[no_mangle]