UNPKG

lightningdevkit

Version:
52 lines 2.02 kB
import { CommonBase } from './CommonBase.mjs'; import * as bindings from '../bindings.mjs'; class LDKNodeIdLookUpHolder { constructor() { this.held = null; } } /** * An interface for looking up the node id of a channel counterparty for the purpose of forwarding * an [`OnionMessage`]. * * [`OnionMessage`]: crate::ln::msgs::OnionMessage */ export class NodeIdLookUp extends CommonBase { /* @internal */ constructor(_dummy, ptr) { super(ptr, bindings.NodeIdLookUp_free); this.bindings_instance = null; } /** Creates a new instance of NodeIdLookUp from a given implementation */ static new_impl(arg) { const impl_holder = new LDKNodeIdLookUpHolder(); let structImplementation = { next_node_id(short_channel_id) { const ret = arg.next_node_id(short_channel_id); const result = bindings.encodeUint8Array(ret); return result; }, }; const ptr_idx = bindings.LDKNodeIdLookUp_new(structImplementation); impl_holder.held = new NodeIdLookUp(null, ptr_idx[0]); impl_holder.held.instance_idx = ptr_idx[1]; impl_holder.held.bindings_instance = structImplementation; return impl_holder.held; } /** * Returns the node id of the forwarding node's channel counterparty with `short_channel_id`. * * Here, the forwarding node is referring to the node of the [`OnionMessenger`] parameterized * by the [`NodeIdLookUp`] and the counterparty to one of that node's peers. * * [`OnionMessenger`]: crate::onion_message::messenger::OnionMessenger * * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ next_node_id(short_channel_id) { const ret = bindings.NodeIdLookUp_next_node_id(this.ptr, short_channel_id); const ret_conv = bindings.decodeUint8Array(ret); return ret_conv; } } //# sourceMappingURL=NodeIdLookUp.mjs.map