+/** An implementation of CustomMessageHandler */
export interface CustomMessageHandlerInterface {
+ /**Called with the message type that was received and the buffer to be read.
+ * Can return a `MessageHandlingError` if the message could not be handled.
+ */
handle_custom_message(msg: Type, sender_node_id: Uint8Array): Result_NoneLightningErrorZ;
+ /**Gets the list of pending messages which were generated by the custom message
+ * handler, clearing the list in the process. The first tuple element must
+ * correspond to the intended recipients node ids. If no connection to one of the
+ * specified node does not exist, the message is simply not sent to it.
+ */
get_and_clear_pending_msg(): TwoTuple_PublicKeyTypeZ[];
}
held: CustomMessageHandler;
}
+/**
+ * Handler for BOLT1-compliant messages.
+ */
export class CustomMessageHandler extends CommonBase {
/* @internal */
public bindings_instance?: bindings.LDKCustomMessageHandler;
this.bindings_instance = null;
}
- static new_impl(arg: CustomMessageHandlerInterface, customMessageReader_impl: CustomMessageReaderInterface): CustomMessageHandler {
+ /** Creates a new instance of CustomMessageHandler from a given implementation */
+ public static new_impl(arg: CustomMessageHandlerInterface, customMessageReader_impl: CustomMessageReaderInterface): CustomMessageHandler {
const impl_holder: LDKCustomMessageHandlerHolder = new LDKCustomMessageHandlerHolder();
let structImplementation = {
handle_custom_message (msg: number, sender_node_id: number): number {
impl_holder.held.ptrs_to.push(customMessageReader);
return impl_holder.held;
}
+
+ /**
+ * Called with the message type that was received and the buffer to be read.
+ * Can return a `MessageHandlingError` if the message could not be handled.
+ */
public handle_custom_message(msg: Type, sender_node_id: Uint8Array): Result_NoneLightningErrorZ {
const ret: number = bindings.CustomMessageHandler_handle_custom_message(this.ptr, msg == null ? 0 : CommonBase.get_ptr_of(msg), bindings.encodeUint8Array(bindings.check_arr_len(sender_node_id, 33)));
const ret_hu_conv: Result_NoneLightningErrorZ = Result_NoneLightningErrorZ.constr_from_ptr(ret);
return ret_hu_conv;
}
+ /**
+ * Gets the list of pending messages which were generated by the custom message
+ * handler, clearing the list in the process. The first tuple element must
+ * correspond to the intended recipients node ids. If no connection to one of the
+ * specified node does not exist, the message is simply not sent to it.
+ */
public get_and_clear_pending_msg(): TwoTuple_PublicKeyTypeZ[] {
const ret: number = bindings.CustomMessageHandler_get_and_clear_pending_msg(this.ptr);
const ret_conv_25_len: number = bindings.getArrayLength(ret);
CommonBase.add_ref_from(ret_conv_25_hu_conv, this);
ret_conv_25_arr[z] = ret_conv_25_hu_conv;
}
+ bindings.freeWasmMemory(ret)
return ret_conv_25_arr;
}