Skip to content
Merged
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
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ bitcoin-payment-instructions = { git = "https://github.com/moneydevkit/bitcoin-p
"http",
] }
# Branch: https://github.com/moneydevkit/ldk-node/commits/lsp-0.7.0_accept-underpaying-htlcs_with_timing_logs
ldk-node = { default-features = false, git = "https://github.com/moneydevkit/ldk-node.git", rev = "5dce44b6e795560bbf62f49d3648308ce88a0586" }
ldk-node = { default-features = false, git = "https://github.com/moneydevkit/ldk-node.git", rev = "5616db4ed0db15534d6d92356fef8c5bad79acb1" }
#ldk-node = { path = "../ldk-node" }

napi = { version = "2", features = ["napi4"] }
Expand Down
48 changes: 22 additions & 26 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
/**
* Derive the node public key from a mnemonic and network without building the full node.
Expand Down Expand Up @@ -64,6 +61,12 @@ export interface MaxSendableConfig {
feeBufferBps?: number
/** Absolute lower bound on the buffer, in sats. Default: 10. */
feeBufferFloorSats?: number
/**
* Fee budget multiplier in basis points of the cheapest route's
* total fees (10_000 = 1.0x, 20_000 = 2.0x). Reserved so a send has
* headroom to retry along a costlier path. Default: 11_000 (1.1x).
*/
routeRetryFeeMultiplierBps?: number
}
export interface PaymentMetadata {
bolt11: string
Expand Down Expand Up @@ -184,16 +187,26 @@ export declare class MdkNode {
* Best-effort estimate of the largest amount that can flow out over
* Lightning right now, with routing-fee headroom subtracted.
*
* When `destination` is supplied, the fee budget comes from a real
* `find_route` against that destination (currently zero-amount BOLT11
* only). BOLT12, LNURL-pay, and HRN destinations parse but fall back
* to the destination-agnostic buffer until invoice/HRN resolution
* moves into the estimator.
*
* Returns `null` when no usable LSP channel exists. `Some(amountMsat: 0)`
* is distinct from `null` — it means a channel exists but the balance
* is fully consumed by the fee buffer (dust). Consumers should never
* see a positive `getBalance()` paired with a `null` here: both
* project from the same `list_channels()` snapshot inside a single
* call.
*
* Throws `InvalidArg` when the destination cannot be parsed, dictates
* its own amount (fixed-amount BOLT11/BOLT12), or carries no Lightning
* method. Throws `GenericFailure` when routing fails outright.
*
* Read-only; safe to call whether or not the node has been started.
*/
getMaxSendable(): MaxSendableEstimate | null
getMaxSendable(destination?: string | undefined | null): MaxSendableEstimate | null
/**
* Manually sync the RGS snapshot.
*
Expand All @@ -213,18 +226,9 @@ export declare class MdkNode {
* Use this when the node is already running via start_receiving().
*/
getVariableAmountJitInvoiceWhileRunning(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
/**
* Get a BOLT12 offer for receiving via LSPS4 JIT channel.
* Use this when the node is already running via start_receiving().
Expand Down Expand Up @@ -252,11 +256,7 @@ export declare class MdkNode {
* For fixed-amount BOLT11 invoices, amount_msat can be omitted (the invoice amount is used).
* For variable-amount destinations, amount_msat is required.
*/
pay(
destination: string,
amountMsat?: number | undefined | null,
waitForPaymentSecs?: number | undefined | null,
): PaymentResult
pay(destination: string, amountMsat?: number | undefined | null, waitForPaymentSecs?: number | undefined | null): PaymentResult
/**
* Unified payment method that auto-detects the destination type.
* Use this when the node is already running via start_receiving().
Expand All @@ -270,9 +270,5 @@ export declare class MdkNode {
* For fixed-amount BOLT11 invoices, amount_msat can be omitted (the invoice amount is used).
* For variable-amount destinations, amount_msat is required.
*/
payWhileRunning(
destination: string,
amountMsat?: number | undefined | null,
waitForPaymentSecs?: number | undefined | null,
): PaymentResult
payWhileRunning(destination: string, amountMsat?: number | undefined | null, waitForPaymentSecs?: number | undefined | null): PaymentResult
}
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