Class CustomMessageHandler


  • public class CustomMessageHandler
    extends Object
    A handler provided to [`PeerManager`] for reading and handling custom messages. [BOLT 1] specifies a custom message type range for use with experimental or application-specific messages. `CustomMessageHandler` allows for user-defined handling of such types. See the [`lightning_custom_message`] crate for tools useful in composing more than one custom handler. [BOLT 1]: https://github.com/lightning/bolts/blob/master/01-messaging.md [`lightning_custom_message`]: https://docs.rs/lightning_custom_message/latest/lightning_custom_message
    • Method Detail

      • destroy

        public void destroy()
        Destroys the object, freeing associated resources. After this call, any access to this object may result in a SEGFAULT or worse. You should generally NEVER call this method. You should let the garbage collector do this for you when it finalizes objects. However, it may be useful for types which represent locks and should be closed immediately to avoid holding locks until the GC runs.
      • get_custom_message_reader

        public CustomMessageReader get_custom_message_reader()
        Gets the underlying CustomMessageReader.
      • handle_custom_message

        public Result_NoneLightningErrorZ handle_custom_message​(Type msg,
                                                                byte[] sender_node_id)
        Handles the given message sent from `sender_node_id`, possibly producing messages for [`CustomMessageHandler::get_and_clear_pending_msg`] to return and thus for [`PeerManager`] to send.
      • get_and_clear_pending_msg

        public TwoTuple_PublicKeyTypeZ[] get_and_clear_pending_msg()
        Returns the list of pending messages that were generated by the handler, clearing the list in the process. Each message is paired with the node id of the intended recipient. If no connection to the node exists, then the message is simply not sent.