UNPKG

lightningdevkit

Version:
73 lines 2.6 kB
import { NodeId } from '../structs/NodeId.mjs'; import { ChannelInfo } from '../structs/ChannelInfo.mjs'; import { EffectiveCapacity } from '../structs/EffectiveCapacity.mjs'; import { CommonBase } from './CommonBase.mjs'; import * as bindings from '../bindings.mjs'; /** * A wrapper around [`ChannelInfo`] representing information about the channel as directed from a * source node to a target node. */ export class DirectedChannelInfo extends CommonBase { /* @internal */ constructor(_dummy, ptr) { super(ptr, bindings.DirectedChannelInfo_free); } clone_ptr() { const ret = bindings.DirectedChannelInfo_clone_ptr(this.ptr); return ret; } /** * Creates a copy of the DirectedChannelInfo */ clone() { const ret = bindings.DirectedChannelInfo_clone(this.ptr); const ret_hu_conv = new DirectedChannelInfo(null, ret); CommonBase.add_ref_from(ret_hu_conv, this); return ret_hu_conv; } /** * Returns information for the channel. */ channel() { const ret = bindings.DirectedChannelInfo_channel(this.ptr); const ret_hu_conv = new ChannelInfo(null, ret); CommonBase.add_ref_from(ret_hu_conv, this); return ret_hu_conv; } /** * Returns the [`EffectiveCapacity`] of the channel in the direction. * * This is either the total capacity from the funding transaction, if known, or the * `htlc_maximum_msat` for the direction as advertised by the gossip network, if known, * otherwise. */ effective_capacity() { const ret = bindings.DirectedChannelInfo_effective_capacity(this.ptr); const ret_hu_conv = EffectiveCapacity.constr_from_ptr(ret); CommonBase.add_ref_from(ret_hu_conv, this); return ret_hu_conv; } /** * Returns the `node_id` of the source hop. * * Refers to the `node_id` forwarding the payment to the next hop. */ source() { const ret = bindings.DirectedChannelInfo_source(this.ptr); const ret_hu_conv = new NodeId(null, ret); CommonBase.add_ref_from(ret_hu_conv, this); return ret_hu_conv; } /** * Returns the `node_id` of the target hop. * * Refers to the `node_id` receiving the payment from the previous hop. */ target() { const ret = bindings.DirectedChannelInfo_target(this.ptr); const ret_hu_conv = new NodeId(null, ret); CommonBase.add_ref_from(ret_hu_conv, this); return ret_hu_conv; } } //# sourceMappingURL=DirectedChannelInfo.mjs.map