diff --git a/index.d.ts b/index.d.ts index 605b6b5..47a9086 100644 --- a/index.d.ts +++ b/index.d.ts @@ -3,10 +3,7 @@ /* auto-generated by NAPI-RS */ -export declare function setLogListener( - callback?: (...args: any[]) => any | undefined | null, - minLevel?: string | undefined | null, -): void +export declare function setLogListener(callback?: (...args: any[]) => any | undefined | null, minLevel?: string | undefined | null): void export declare function generateMnemonic(): string export interface MdkNodeOptions { network: string @@ -29,11 +26,16 @@ export interface ReceivedPayment { amount: number } export interface PaymentEvent { - eventType: string + eventType: PaymentEventType paymentHash: string amountMsat?: number reason?: string } +export const enum PaymentEventType { + Claimable = 0, + Received = 1, + Failed = 2 +} export interface NodeChannel { channelId: string counterpartyNodeId: string @@ -76,18 +78,9 @@ export declare class MdkNode { syncRgs(doFullSync: boolean): number receivePayment(minThresholdMs: number, quietThresholdMs: number): Array getInvoice(amount: number, description: string, expirySecs: number): PaymentMetadata - getInvoiceWithScid( - humanReadableScid: string, - amount: number, - description: string, - expirySecs: number, - ): PaymentMetadata + getInvoiceWithScid(humanReadableScid: string, amount: number, description: string, expirySecs: number): PaymentMetadata getVariableAmountJitInvoice(description: string, expirySecs: number): PaymentMetadata - getVariableAmountJitInvoiceWithScid( - humanReadableScid: string, - description: string, - expirySecs: number, - ): PaymentMetadata + getVariableAmountJitInvoiceWithScid(humanReadableScid: string, description: string, expirySecs: number): PaymentMetadata payLnurl(lnurl: string, amountMsat: number, waitForPaymentSecs?: number | undefined | null): string payBolt11(bolt11Invoice: string): string payBolt12Offer(bolt12OfferString: string, amountMsat: number, waitForPaymentSecs?: number | undefined | null): string diff --git a/index.js b/index.js index 1f01f22..1cbda6c 100644 --- a/index.js +++ b/index.js @@ -62,7 +62,9 @@ switch (platform) { case 'win32': switch (arch) { case 'x64': - localFileExisted = existsSync(join(__dirname, 'lightning-js.win32-x64-msvc.node')) + localFileExisted = existsSync( + join(__dirname, 'lightning-js.win32-x64-msvc.node') + ) try { if (localFileExisted) { nativeBinding = require('./lightning-js.win32-x64-msvc.node') @@ -74,7 +76,9 @@ switch (platform) { } break case 'ia32': - localFileExisted = existsSync(join(__dirname, 'lightning-js.win32-ia32-msvc.node')) + localFileExisted = existsSync( + join(__dirname, 'lightning-js.win32-ia32-msvc.node') + ) try { if (localFileExisted) { nativeBinding = require('./lightning-js.win32-ia32-msvc.node') @@ -86,7 +90,9 @@ switch (platform) { } break case 'arm64': - localFileExisted = existsSync(join(__dirname, 'lightning-js.win32-arm64-msvc.node')) + localFileExisted = existsSync( + join(__dirname, 'lightning-js.win32-arm64-msvc.node') + ) try { if (localFileExisted) { nativeBinding = require('./lightning-js.win32-arm64-msvc.node') @@ -125,7 +131,9 @@ switch (platform) { } break case 'arm64': - localFileExisted = existsSync(join(__dirname, 'lightning-js.darwin-arm64.node')) + localFileExisted = existsSync( + join(__dirname, 'lightning-js.darwin-arm64.node') + ) try { if (localFileExisted) { nativeBinding = require('./lightning-js.darwin-arm64.node') @@ -159,7 +167,9 @@ switch (platform) { switch (arch) { case 'x64': if (isMusl()) { - localFileExisted = existsSync(join(__dirname, 'lightning-js.linux-x64-musl.node')) + localFileExisted = existsSync( + join(__dirname, 'lightning-js.linux-x64-musl.node') + ) try { if (localFileExisted) { nativeBinding = require('./lightning-js.linux-x64-musl.node') @@ -170,7 +180,9 @@ switch (platform) { loadError = e } } else { - localFileExisted = existsSync(join(__dirname, 'lightning-js.linux-x64-gnu.node')) + localFileExisted = existsSync( + join(__dirname, 'lightning-js.linux-x64-gnu.node') + ) try { if (localFileExisted) { nativeBinding = require('./lightning-js.linux-x64-gnu.node') @@ -184,7 +196,9 @@ switch (platform) { break case 'arm64': if (isMusl()) { - localFileExisted = existsSync(join(__dirname, 'lightning-js.linux-arm64-musl.node')) + localFileExisted = existsSync( + join(__dirname, 'lightning-js.linux-arm64-musl.node') + ) try { if (localFileExisted) { nativeBinding = require('./lightning-js.linux-arm64-musl.node') @@ -195,7 +209,9 @@ switch (platform) { loadError = e } } else { - localFileExisted = existsSync(join(__dirname, 'lightning-js.linux-arm64-gnu.node')) + localFileExisted = existsSync( + join(__dirname, 'lightning-js.linux-arm64-gnu.node') + ) try { if (localFileExisted) { nativeBinding = require('./lightning-js.linux-arm64-gnu.node') @@ -209,7 +225,9 @@ switch (platform) { break case 'arm': if (isMusl()) { - localFileExisted = existsSync(join(__dirname, 'lightning-js.linux-arm-musleabihf.node')) + localFileExisted = existsSync( + join(__dirname, 'lightning-js.linux-arm-musleabihf.node') + ) try { if (localFileExisted) { nativeBinding = require('./lightning-js.linux-arm-musleabihf.node') @@ -220,7 +238,9 @@ switch (platform) { loadError = e } } else { - localFileExisted = existsSync(join(__dirname, 'lightning-js.linux-arm-gnueabihf.node')) + localFileExisted = existsSync( + join(__dirname, 'lightning-js.linux-arm-gnueabihf.node') + ) try { if (localFileExisted) { nativeBinding = require('./lightning-js.linux-arm-gnueabihf.node') @@ -234,7 +254,9 @@ switch (platform) { break case 'riscv64': if (isMusl()) { - localFileExisted = existsSync(join(__dirname, 'lightning-js.linux-riscv64-musl.node')) + localFileExisted = existsSync( + join(__dirname, 'lightning-js.linux-riscv64-musl.node') + ) try { if (localFileExisted) { nativeBinding = require('./lightning-js.linux-riscv64-musl.node') @@ -245,7 +267,9 @@ switch (platform) { loadError = e } } else { - localFileExisted = existsSync(join(__dirname, 'lightning-js.linux-riscv64-gnu.node')) + localFileExisted = existsSync( + join(__dirname, 'lightning-js.linux-riscv64-gnu.node') + ) try { if (localFileExisted) { nativeBinding = require('./lightning-js.linux-riscv64-gnu.node') @@ -258,7 +282,9 @@ switch (platform) { } break case 's390x': - localFileExisted = existsSync(join(__dirname, 'lightning-js.linux-s390x-gnu.node')) + localFileExisted = existsSync( + join(__dirname, 'lightning-js.linux-s390x-gnu.node') + ) try { if (localFileExisted) { nativeBinding = require('./lightning-js.linux-s390x-gnu.node') @@ -284,8 +310,9 @@ if (!nativeBinding) { throw new Error(`Failed to load native binding`) } -const { setLogListener, generateMnemonic, MdkNode } = nativeBinding +const { setLogListener, generateMnemonic, PaymentEventType, MdkNode } = nativeBinding module.exports.setLogListener = setLogListener module.exports.generateMnemonic = generateMnemonic +module.exports.PaymentEventType = PaymentEventType module.exports.MdkNode = MdkNode