Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,9 @@ lto = true
[dev-dependencies]
bitcoin = "0.32"
lightning-invoice = "0.33.2"

# Patch lightning crates so bitcoin-payment-instructions uses the same versions as ldk-node
# This avoids type mismatches between the two crates' Bolt11Invoice/Offer types
[patch.crates-io]
lightning = { git = "https://github.com/moneydevkit/rust-lightning", rev = "42bad4fd3c908958b96b6b70ed63bd6aa3cbaf5f" }
lightning-invoice = { git = "https://github.com/moneydevkit/rust-lightning", rev = "42bad4fd3c908958b96b6b70ed63bd6aa3cbaf5f" }
35 changes: 20 additions & 15 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -55,19 +52,27 @@ export declare class MdkNode {
syncRgs(doFullSync: boolean): number
receivePayment(minThresholdMs: number, quietThresholdMs: number): Array<ReceivedPayment>
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
/**
* Universal payout method that handles any form of Lightning payment instruction.
*
* This method accepts:
* - Bolt11 invoices (with or without amount)
* - Bolt12 offers
* - BIP-353 addresses (e.g., user@domain) that resolve to Bolt12 offers or LNURL
* - LNURLp endpoints
* - Lightning Addresses (e.g., user@domain)
*
* The `amount_msat` parameter is required for instructions without a fixed amount
* (variable-amount invoices, offers without amounts, LNURL, etc.).
* For fixed-amount instructions, the `amount_msat` is ignored if provided.
*
* Returns the payment ID as a hex string on success.
*/
payOut(instruction: string, amountMsat?: number | undefined | null, waitForPaymentSecs?: number | undefined | null): string
}
52 changes: 39 additions & 13 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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')
Expand All @@ -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')
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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')
Expand All @@ -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')
Expand All @@ -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')
Expand All @@ -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')
Expand All @@ -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')
Expand All @@ -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')
Expand All @@ -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')
Expand All @@ -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')
Expand All @@ -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')
Expand Down
Loading
Loading