UNPKG

@node-lightning/wire

Version:
62 lines (61 loc) 2.41 kB
/// <reference types="node" /> import { PeerHostRecord } from "../PeerHostRecord"; import { promises as dnsPromises } from "dns"; import { AddressType } from "../domain/AddressType"; export interface DnsPeerQueryOptions { /** * The domain of the dns seed. */ dnsSeed: string; /** * The realm byte used to specify what realm the returned nodes must support. */ realm?: number; /** * The address type bit field specifies the address types that should be returned. * It follows the format of the address descriptor type specified in BOLT #7. */ addressTypes?: AddressType[]; /** * The bech32-encoded node id used to retrive the result of a single node. */ nodeId?: string; /** * The number of desired reply records. */ desiredReplyRecords?: number; } /** * This class implements the node discovery mechanism described * in BOLT #10. * The purpose of this component is to assist in the initial * node discovery process for nodes that have no known contacts, * and to help nodes discover the current network address of previously * known peers. A domain name server that implements BOLT #10 is * referred to as a DNS Seed and answers incoming DNS queries of * type A, AAAA, or SRV. */ export declare class DnsPeerQuery { private resolver; constructor(resolver?: dnsPromises.Resolver); /** * The query method starts by querying a DNS seed for SRV records. * This will result in a list of returned SRV records that each * represent a lightning node that can be connected to. Each record * is a subdomain of the dns seed where the first component of the * subdomain is the bech32 encoded public key of the node (also known * as the node_id). Each subdomain can subsequently be used to query * the DNS seed for the A (or AAA) records of the lightning node with * the specified node_id. The query method ends by constructing peer * host records using the port from the SRV records and the ip * address from the A (or AAA) records. * @param dnsPeerQueryOptions * @returns valid peer host records */ query(dnsPeerQueryOptions: DnsPeerQueryOptions): Promise<PeerHostRecord[]>; private _createPeerHostRecord; private _buildUrl; private _getPublicKeyFromSrvRecord; private _getPeerSrvRecords; private _resolveSrvNameToIp; }