* # extern crate bitcoin;
* # use bitcoin::hashes::_export::_core::time::Duration;
* # use bitcoin::secp256k1::{PublicKey, Secp256k1, SecretKey};
- * # use lightning::chain::keysinterface::{InMemorySigner, KeysManager, KeysInterface};
- * # use lightning::ln::msgs::DecodeError;
+ * # use lightning::blinded_path::BlindedPath;
+ * # use lightning::chain::keysinterface::KeysManager;
* # use lightning::ln::peer_handler::IgnoringMessageHandler;
* # use lightning::onion_message::messenger::{Destination, OnionMessenger};
- * # use lightning::onion_message::packet::CustomOnionMessageContents;
- * # use lightning::onion_message::blinded_route::BlindedRoute;
+ * # use lightning::onion_message::packet::{CustomOnionMessageContents, OnionMessageContents};
* # use lightning::util::logger::{Logger, Record};
* # use lightning::util::ser::{Writeable, Writer};
* # use lightning::io;
* # use std::sync::Arc;
- * # struct FakeLogger {};
+ * # struct FakeLogger;
* # impl Logger for FakeLogger {
* # fn log(&self, record: &Record) { unimplemented!() }
* # }
* # let your_custom_message_handler = IgnoringMessageHandler {};
* Create the onion messenger. This must use the same `keys_manager` as is passed to your
* ChannelManager.
- * let onion_messenger = OnionMessenger::new(&keys_manager, logger, your_custom_message_handler);
+ * let onion_messenger = OnionMessenger::new(&keys_manager, &keys_manager, logger, &your_custom_message_handler);
*
* # #[derive(Clone)]
* # struct YourCustomMessage {}
* let intermediate_hops = [hop_node_id1, hop_node_id2];
* let reply_path = None;
* # let your_custom_message = YourCustomMessage {};
- * onion_messenger.send_custom_onion_message(&intermediate_hops, Destination::Node(destination_node_id), your_custom_message, reply_path);
+ * let message = OnionMessageContents::Custom(your_custom_message);
+ * onion_messenger.send_onion_message(&intermediate_hops, Destination::Node(destination_node_id), message, reply_path);
*
- * Create a blinded route to yourself, for someone to send an onion message to.
+ * Create a blinded path to yourself, for someone to send an onion message to.
* # let your_node_id = hop_node_id1;
* let hops = [hop_node_id3, hop_node_id4, your_node_id];
- * let blinded_route = BlindedRoute::new(&hops, &keys_manager, &secp_ctx).unwrap();
+ * let blinded_path = BlindedPath::new_for_message(&hops, &keys_manager, &secp_ctx).unwrap();
*
- * Send a custom onion message to a blinded route.
+ * Send a custom onion message to a blinded path.
* # let intermediate_hops = [hop_node_id1, hop_node_id2];
* let reply_path = None;
* # let your_custom_message = YourCustomMessage {};
- * onion_messenger.send_custom_onion_message(&intermediate_hops, Destination::BlindedRoute(blinded_route), your_custom_message, reply_path);
+ * let message = OnionMessageContents::Custom(your_custom_message);
+ * onion_messenger.send_onion_message(&intermediate_hops, Destination::BlindedPath(blinded_path), message, reply_path);
* ```
*
* [offers]: <https://github.com/lightning/bolts/pull/798>
* Constructs a new `OnionMessenger` to send, forward, and delegate received onion messages to
* their respective handlers.
*/
- public static OnionMessenger of(KeysInterface keys_manager, Logger logger, CustomOnionMessageHandler custom_handler) {
- long ret = bindings.OnionMessenger_new(keys_manager == null ? 0 : keys_manager.ptr, logger == null ? 0 : logger.ptr, custom_handler == null ? 0 : custom_handler.ptr);
- Reference.reachabilityFence(keys_manager);
+ public static OnionMessenger of(org.ldk.structs.EntropySource entropy_source, org.ldk.structs.NodeSigner node_signer, org.ldk.structs.Logger logger, org.ldk.structs.CustomOnionMessageHandler custom_handler) {
+ long ret = bindings.OnionMessenger_new(entropy_source == null ? 0 : entropy_source.ptr, node_signer == null ? 0 : node_signer.ptr, logger == null ? 0 : logger.ptr, custom_handler == null ? 0 : custom_handler.ptr);
+ Reference.reachabilityFence(entropy_source);
+ Reference.reachabilityFence(node_signer);
Reference.reachabilityFence(logger);
Reference.reachabilityFence(custom_handler);
if (ret >= 0 && ret <= 4096) { return null; }
org.ldk.structs.OnionMessenger ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OnionMessenger(null, ret); }
if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
- if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(keys_manager); };
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(entropy_source); };
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(node_signer); };
if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(logger); };
if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(custom_handler); };
return ret_hu_conv;
*
* Note that reply_path (or a relevant inner pointer) may be NULL or all-0s to represent None
*/
- public Result_NoneSendErrorZ send_custom_onion_message(byte[][] intermediate_nodes, Destination destination, CustomOnionMessageContents msg, @Nullable BlindedRoute reply_path) {
- long ret = bindings.OnionMessenger_send_custom_onion_message(this.ptr, intermediate_nodes != null ? Arrays.stream(intermediate_nodes).map(intermediate_nodes_conv_8 -> InternalUtils.check_arr_len(intermediate_nodes_conv_8, 33)).toArray(byte[][]::new) : null, destination.ptr, msg == null ? 0 : msg.ptr, reply_path == null ? 0 : reply_path.ptr);
+ public Result_NoneSendErrorZ send_onion_message(byte[][] intermediate_nodes, org.ldk.structs.Destination destination, org.ldk.structs.OnionMessageContents message, @Nullable org.ldk.structs.BlindedPath reply_path) {
+ long ret = bindings.OnionMessenger_send_onion_message(this.ptr, intermediate_nodes != null ? Arrays.stream(intermediate_nodes).map(intermediate_nodes_conv_8 -> InternalUtils.check_arr_len(intermediate_nodes_conv_8, 33)).toArray(byte[][]::new) : null, destination.ptr, message.ptr, reply_path == null ? 0 : reply_path.ptr);
Reference.reachabilityFence(this);
Reference.reachabilityFence(intermediate_nodes);
Reference.reachabilityFence(destination);
- Reference.reachabilityFence(msg);
+ Reference.reachabilityFence(message);
Reference.reachabilityFence(reply_path);
if (ret >= 0 && ret <= 4096) { return null; }
Result_NoneSendErrorZ ret_hu_conv = Result_NoneSendErrorZ.constr_from_ptr(ret);
- if (this != null) { this.ptrs_to.add(msg); };
+ if (this != null) { this.ptrs_to.add(destination); };
+ if (this != null) { this.ptrs_to.add(message); };
if (this != null) { this.ptrs_to.add(reply_path); };
return ret_hu_conv;
}