UNPKG

lnurl-pay

Version:

Client library for lnurl-pay and lightning address

220 lines (219 loc) 6.47 kB
import * as bolt11 from "bolt11"; //#region rolldown:runtime //#endregion //#region src/types.d.ts declare const satoshisSymbol: unique symbol; type Satoshis = number & { [satoshisSymbol]: never; }; type Json = { [key: string]: any; }; type LightningAddress = { username: string; domain: string; }; type LNURLPaySuccessAction = { tag: string; description: string | null; url: string | null; message: string | null; ciphertext: string | null; iv: string | null; decipher: (preimage: string) => string | null; }; type FetcGetArgs = { url: string; params?: Json; }; type LnUrlPayServiceArgs = { lnUrlOrAddress: string; onionAllowed?: boolean; fetchGet?: (args: FetcGetArgs) => Promise<Json>; }; type LnUrlPayServiceResponse = { callback: string; fixed: boolean; min: Satoshis; max: Satoshis; domain?: string; metadata: Array<Array<string>>; metadataHash: string; identifier: string; description: string; image: string; commentAllowed: number; rawData: { [key: string]: string | number; }; }; type LnUrlRequestInvoiceBaseArgs = { tokens: Satoshis; comment?: string; onionAllowed?: boolean; fetchGet?: (args: FetcGetArgs) => Promise<Json>; validateInvoice?: boolean; }; type LnUrlrequestInvoiceWithServiceParamsArgs = LnUrlRequestInvoiceBaseArgs & { params: LnUrlPayServiceResponse; }; type LnUrlRequestInvoiceArgs = LnUrlRequestInvoiceBaseArgs & { lnUrlOrAddress: string; }; type LnUrlRequestInvoiceResponse = { params: LnUrlPayServiceResponse; rawData: Json; invoice: string; hasValidAmount: boolean; hasValidDescriptionHash: boolean; successAction?: LNURLPaySuccessAction; validatePreimage: (preimage: string) => boolean; }; type BufferEncoding = 'ascii' | 'utf8' | 'utf-8' | 'utf16le' | 'utf-16le' | 'ucs2' | 'ucs-2' | 'base64' | 'base64url' | 'latin1' | 'binary' | 'hex'; declare namespace utils_d_exports { export { checkedToSats, decipherAES, decodeInvoice, decodeUrlOrAddress, getHashFromInvoice, getJson, isLightningAddress, isLnurl, isLnurlp, isOnionUrl, isUrl, isValidAmount, isValidPreimage, parseLightningAddress, parseLnUrl, parseLnurlp, sha256, toSats }; } /** * Decode a bech32 encoded url (lnurl), lightning address or lnurlp url and return a url * @method decodeUrlOrAddress * @param lnUrlOrAddress string to decode * @return plain url or null if is an invalid url, lightning address or lnurlp */ declare const decodeUrlOrAddress: (lnUrlOrAddress: string) => string | null; /** * Parse an url and return a bech32 encoded url (lnurl) * @method parseLnUrl * @param url string to parse * @return bech32 encoded url (lnurl) or null if is an invalid url */ declare const parseLnUrl: (url: string) => string | null; /** * Verify if a string is a valid lnurl value * @method isLnurl * @param url string to validate * @return true if is a valid lnurl value */ declare const isLnurl: (url: string) => boolean; /** * Verify if a string is a lightning adress * @method isLightningAddress * @param address string to validate * @return true if is a lightning address */ declare const isLightningAddress: (address: string) => boolean; /** * Parse an address and return username and domain * @method parseLightningAddress * @param address string to parse * @return LightningAddress { username, domain } */ declare const parseLightningAddress: (address: string) => LightningAddress | null; /** * Verify if a string is a lnurlp url * @method isLnurlp * @param url string to validate * @return true if is a lnurlp url */ declare const isLnurlp: (url: string) => boolean; /** * Parse a lnurlp url and return an url with the proper protocol * @method parseLnurlp * @param url string to parse * @return url (http or https) or null if is an invalid lnurlp */ declare const parseLnurlp: (url: string) => string | null; /** * Verify if a string is an url * @method isUrl * @param url string to validate * @return true if is an url */ declare const isUrl: (url: string | null) => url is string; /** * Verify if a string is an onion url * @method isOnionUrl * @param url string to validate * @return true if is an onion url */ declare const isOnionUrl: (url: string | null) => boolean; /** * Parse a number to Satoshis * @method checkedToSats * @param value number to parse * @return Satoshis or null */ declare const checkedToSats: (value: number) => Satoshis | null; /** * Cast a number to Satoshis type * @method toSats * @param value number to cast * @return Satoshis */ declare const toSats: (value: number) => Satoshis; declare const isValidAmount: ({ amount, min, max }: { amount: number; min: number; max: number; }) => boolean; declare const getJson: ({ url, params }: { url: string; params?: { [key: string]: string | number; }; }) => Promise<{ [key: string]: string | number; }>; declare const sha256: (data: string, encoding?: BufferEncoding) => string; declare const decodeInvoice: (invoice: string) => (bolt11.PaymentRequestObject & { tagsObject: bolt11.TagsObject; }) | null; declare const getHashFromInvoice: (invoice: string) => string | null; declare const isValidPreimage: ({ invoice, preimage }: { invoice: string; preimage: string; }) => boolean; declare const decipherAES: ({ successAction, preimage }: { successAction: LNURLPaySuccessAction; preimage: string; }) => string | null; //#endregion //#region src/request-pay-service-params.d.ts declare const requestPayServiceParams: ({ lnUrlOrAddress, onionAllowed, fetchGet }: LnUrlPayServiceArgs) => Promise<LnUrlPayServiceResponse>; //#endregion //#region src/request-invoice.d.ts declare const requestInvoiceWithServiceParams: ({ params, tokens, comment, onionAllowed, validateInvoice, fetchGet }: LnUrlrequestInvoiceWithServiceParamsArgs) => Promise<LnUrlRequestInvoiceResponse>; declare const requestInvoice: ({ lnUrlOrAddress, tokens, comment, onionAllowed, validateInvoice, fetchGet }: LnUrlRequestInvoiceArgs) => Promise<LnUrlRequestInvoiceResponse>; //#endregion export { BufferEncoding, FetcGetArgs, LNURLPaySuccessAction, LightningAddress, LnUrlPayServiceArgs, LnUrlPayServiceResponse, LnUrlRequestInvoiceArgs, LnUrlRequestInvoiceBaseArgs, LnUrlRequestInvoiceResponse, LnUrlrequestInvoiceWithServiceParamsArgs, Satoshis, requestInvoice, requestInvoiceWithServiceParams, requestPayServiceParams, utils_d_exports as utils }; //# sourceMappingURL=index.d.ts.map