lightningdevkit
Version:
Lightning Development Kit
91 lines (90 loc) • 4.19 kB
text/typescript
import { MessageContext } from '../structs/MessageContext.mjs';
import { Result_NoneNoneZ } from '../structs/Result_NoneNoneZ.mjs';
import { BlindedHop } from '../structs/BlindedHop.mjs';
import { NodeId } from '../structs/NodeId.mjs';
import { EntropySource } from '../structs/EntropySource.mjs';
import { NodeSigner } from '../structs/NodeSigner.mjs';
import { MessageForwardNode } from '../structs/MessageForwardNode.mjs';
import { Result_BlindedMessagePathDecodeErrorZ } from '../structs/Result_BlindedMessagePathDecodeErrorZ.mjs';
import { Result_BlindedMessagePathNoneZ } from '../structs/Result_BlindedMessagePathNoneZ.mjs';
import { NodeIdLookUp } from '../structs/NodeIdLookUp.mjs';
import { ReadOnlyNetworkGraph } from '../structs/ReadOnlyNetworkGraph.mjs';
import { IntroductionNode } from '../structs/IntroductionNode.mjs';
import { CommonBase } from './CommonBase.mjs';
/**
* A blinded path to be used for sending or receiving a message, hiding the identity of the
* recipient.
*/
export declare class BlindedMessagePath extends CommonBase {
clone_ptr(): bigint;
/**
* Creates a copy of the BlindedMessagePath
*/
clone(): BlindedMessagePath;
/**
* Generates a non-cryptographic 64-bit hash of the BlindedMessagePath.
*/
hash(): bigint;
/**
* Checks if two BlindedMessagePaths contain equal inner contents.
* This ignores pointers and is_owned flags and looks at the values in fields.
* Two objects with NULL inner values will be considered "equal" here.
*/
eq(b: BlindedMessagePath): boolean;
/**
* Serialize the BlindedMessagePath object into a byte array which can be read by BlindedMessagePath_read
*/
write(): Uint8Array;
/**
* Read a BlindedMessagePath from a byte array, created by BlindedMessagePath_write
*/
static constructor_read(ser: Uint8Array): Result_BlindedMessagePathDecodeErrorZ;
/**
* Create a one-hop blinded path for a message.
*/
static constructor_one_hop(recipient_node_id: Uint8Array, context: MessageContext, entropy_source: EntropySource): Result_BlindedMessagePathNoneZ;
/**
* Create a path for an onion message, to be forwarded along `node_pks`. The last node
* pubkey in `node_pks` will be the destination node.
*
* Errors if no hops are provided or if `node_pk`(s) are invalid.
*/
static constructor_new(intermediate_nodes: MessageForwardNode[], recipient_node_id: Uint8Array, context: MessageContext, entropy_source: EntropySource): Result_BlindedMessagePathNoneZ;
/**
* Attempts to a use a compact representation for the [`IntroductionNode`] by using a directed
* short channel id from a channel in `network_graph` leading to the introduction node.
*
* While this may result in a smaller encoding, there is a trade off in that the path may
* become invalid if the channel is closed or hasn't been propagated via gossip. Therefore,
* calling this may not be suitable for long-lived blinded paths.
*/
use_compact_introduction_node(network_graph: ReadOnlyNetworkGraph): void;
/**
* Returns the introduction [`NodeId`] of the blinded path, if it is publicly reachable (i.e.,
* it is found in the network graph).
*
* Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
*/
public_introduction_node_id(network_graph: ReadOnlyNetworkGraph): NodeId;
/**
* The [`IntroductionNode`] of the blinded path.
*/
introduction_node(): IntroductionNode;
/**
* Used by the [`IntroductionNode`] to decrypt its [`encrypted_payload`] to forward the message.
*
* [`encrypted_payload`]: BlindedHop::encrypted_payload
*/
blinding_point(): Uint8Array;
/**
* The [`BlindedHop`]s within the blinded path.
*/
blinded_hops(): BlindedHop[];
/**
* Advance the blinded onion message path by one hop, making the second hop into the new
* introduction node.
*
* Will only modify `self` when returning `Ok`.
*/
advance_path_by_one(node_signer: NodeSigner, node_id_lookup: NodeIdLookUp): Result_NoneNoneZ;
}