@moneydevkit/lightning-js 0.1.68 → 0.1.71

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/index.d.ts +21 -2
  2. package/index.js +15 -40
  3. package/package.json +14 -14
package/index.d.ts CHANGED
@@ -8,6 +8,13 @@ export declare function setLogListener(
8
8
  minLevel?: string | undefined | null,
9
9
  ): void
10
10
  export declare function generateMnemonic(): string
11
+ /**
12
+ * Derive the node public key from a mnemonic and network without building the full node.
13
+ * This replicates the exact derivation path used in `build_with_store_internal()`:
14
+ * mnemonic -> BIP39 seed -> BIP32 master xprv -> 32-byte secret -> KeysManager -> node_id
15
+ * Runs in ~1ms vs ~4s for full node construction.
16
+ */
17
+ export declare function deriveNodeId(mnemonicStr: string, networkStr: string): string
11
18
  export interface MdkNodeOptions {
12
19
  network: string
13
20
  mdkApiKey: string
@@ -28,6 +35,18 @@ export interface ReceivedPayment {
28
35
  paymentHash: string
29
36
  amount: number
30
37
  }
38
+ /** Result of a successful outbound payment. */
39
+ export interface PaymentResult {
40
+ /** Opaque payment identifier. Always present - can be used to correlate async BOLT12 payments. */
41
+ paymentId: string
42
+ /**
43
+ * The payment hash from the invoice/offer (identifies the HTLC).
44
+ * Available immediately for BOLT11; populated from the PaymentSuccessful event for BOLT12.
45
+ */
46
+ paymentHash?: string
47
+ /** The payment preimage (proof of payment). Available after the payment succeeds. */
48
+ preimage?: string
49
+ }
31
50
  export interface PaymentEvent {
32
51
  eventType: PaymentEventType
33
52
  paymentHash: string
@@ -140,7 +159,7 @@ export declare class MdkNode {
140
159
  destination: string,
141
160
  amountMsat?: number | undefined | null,
142
161
  waitForPaymentSecs?: number | undefined | null,
143
- ): string
162
+ ): PaymentResult
144
163
  /**
145
164
  * Unified payment method that auto-detects the destination type.
146
165
  * Use this when the node is already running via start_receiving().
@@ -158,5 +177,5 @@ export declare class MdkNode {
158
177
  destination: string,
159
178
  amountMsat?: number | undefined | null,
160
179
  waitForPaymentSecs?: number | undefined | null,
161
- ): string
180
+ ): PaymentResult
162
181
  }
package/index.js CHANGED
@@ -62,9 +62,7 @@ switch (platform) {
62
62
  case 'win32':
63
63
  switch (arch) {
64
64
  case 'x64':
65
- localFileExisted = existsSync(
66
- join(__dirname, 'lightning-js.win32-x64-msvc.node')
67
- )
65
+ localFileExisted = existsSync(join(__dirname, 'lightning-js.win32-x64-msvc.node'))
68
66
  try {
69
67
  if (localFileExisted) {
70
68
  nativeBinding = require('./lightning-js.win32-x64-msvc.node')
@@ -76,9 +74,7 @@ switch (platform) {
76
74
  }
77
75
  break
78
76
  case 'ia32':
79
- localFileExisted = existsSync(
80
- join(__dirname, 'lightning-js.win32-ia32-msvc.node')
81
- )
77
+ localFileExisted = existsSync(join(__dirname, 'lightning-js.win32-ia32-msvc.node'))
82
78
  try {
83
79
  if (localFileExisted) {
84
80
  nativeBinding = require('./lightning-js.win32-ia32-msvc.node')
@@ -90,9 +86,7 @@ switch (platform) {
90
86
  }
91
87
  break
92
88
  case 'arm64':
93
- localFileExisted = existsSync(
94
- join(__dirname, 'lightning-js.win32-arm64-msvc.node')
95
- )
89
+ localFileExisted = existsSync(join(__dirname, 'lightning-js.win32-arm64-msvc.node'))
96
90
  try {
97
91
  if (localFileExisted) {
98
92
  nativeBinding = require('./lightning-js.win32-arm64-msvc.node')
@@ -131,9 +125,7 @@ switch (platform) {
131
125
  }
132
126
  break
133
127
  case 'arm64':
134
- localFileExisted = existsSync(
135
- join(__dirname, 'lightning-js.darwin-arm64.node')
136
- )
128
+ localFileExisted = existsSync(join(__dirname, 'lightning-js.darwin-arm64.node'))
137
129
  try {
138
130
  if (localFileExisted) {
139
131
  nativeBinding = require('./lightning-js.darwin-arm64.node')
@@ -167,9 +159,7 @@ switch (platform) {
167
159
  switch (arch) {
168
160
  case 'x64':
169
161
  if (isMusl()) {
170
- localFileExisted = existsSync(
171
- join(__dirname, 'lightning-js.linux-x64-musl.node')
172
- )
162
+ localFileExisted = existsSync(join(__dirname, 'lightning-js.linux-x64-musl.node'))
173
163
  try {
174
164
  if (localFileExisted) {
175
165
  nativeBinding = require('./lightning-js.linux-x64-musl.node')
@@ -180,9 +170,7 @@ switch (platform) {
180
170
  loadError = e
181
171
  }
182
172
  } else {
183
- localFileExisted = existsSync(
184
- join(__dirname, 'lightning-js.linux-x64-gnu.node')
185
- )
173
+ localFileExisted = existsSync(join(__dirname, 'lightning-js.linux-x64-gnu.node'))
186
174
  try {
187
175
  if (localFileExisted) {
188
176
  nativeBinding = require('./lightning-js.linux-x64-gnu.node')
@@ -196,9 +184,7 @@ switch (platform) {
196
184
  break
197
185
  case 'arm64':
198
186
  if (isMusl()) {
199
- localFileExisted = existsSync(
200
- join(__dirname, 'lightning-js.linux-arm64-musl.node')
201
- )
187
+ localFileExisted = existsSync(join(__dirname, 'lightning-js.linux-arm64-musl.node'))
202
188
  try {
203
189
  if (localFileExisted) {
204
190
  nativeBinding = require('./lightning-js.linux-arm64-musl.node')
@@ -209,9 +195,7 @@ switch (platform) {
209
195
  loadError = e
210
196
  }
211
197
  } else {
212
- localFileExisted = existsSync(
213
- join(__dirname, 'lightning-js.linux-arm64-gnu.node')
214
- )
198
+ localFileExisted = existsSync(join(__dirname, 'lightning-js.linux-arm64-gnu.node'))
215
199
  try {
216
200
  if (localFileExisted) {
217
201
  nativeBinding = require('./lightning-js.linux-arm64-gnu.node')
@@ -225,9 +209,7 @@ switch (platform) {
225
209
  break
226
210
  case 'arm':
227
211
  if (isMusl()) {
228
- localFileExisted = existsSync(
229
- join(__dirname, 'lightning-js.linux-arm-musleabihf.node')
230
- )
212
+ localFileExisted = existsSync(join(__dirname, 'lightning-js.linux-arm-musleabihf.node'))
231
213
  try {
232
214
  if (localFileExisted) {
233
215
  nativeBinding = require('./lightning-js.linux-arm-musleabihf.node')
@@ -238,9 +220,7 @@ switch (platform) {
238
220
  loadError = e
239
221
  }
240
222
  } else {
241
- localFileExisted = existsSync(
242
- join(__dirname, 'lightning-js.linux-arm-gnueabihf.node')
243
- )
223
+ localFileExisted = existsSync(join(__dirname, 'lightning-js.linux-arm-gnueabihf.node'))
244
224
  try {
245
225
  if (localFileExisted) {
246
226
  nativeBinding = require('./lightning-js.linux-arm-gnueabihf.node')
@@ -254,9 +234,7 @@ switch (platform) {
254
234
  break
255
235
  case 'riscv64':
256
236
  if (isMusl()) {
257
- localFileExisted = existsSync(
258
- join(__dirname, 'lightning-js.linux-riscv64-musl.node')
259
- )
237
+ localFileExisted = existsSync(join(__dirname, 'lightning-js.linux-riscv64-musl.node'))
260
238
  try {
261
239
  if (localFileExisted) {
262
240
  nativeBinding = require('./lightning-js.linux-riscv64-musl.node')
@@ -267,9 +245,7 @@ switch (platform) {
267
245
  loadError = e
268
246
  }
269
247
  } else {
270
- localFileExisted = existsSync(
271
- join(__dirname, 'lightning-js.linux-riscv64-gnu.node')
272
- )
248
+ localFileExisted = existsSync(join(__dirname, 'lightning-js.linux-riscv64-gnu.node'))
273
249
  try {
274
250
  if (localFileExisted) {
275
251
  nativeBinding = require('./lightning-js.linux-riscv64-gnu.node')
@@ -282,9 +258,7 @@ switch (platform) {
282
258
  }
283
259
  break
284
260
  case 's390x':
285
- localFileExisted = existsSync(
286
- join(__dirname, 'lightning-js.linux-s390x-gnu.node')
287
- )
261
+ localFileExisted = existsSync(join(__dirname, 'lightning-js.linux-s390x-gnu.node'))
288
262
  try {
289
263
  if (localFileExisted) {
290
264
  nativeBinding = require('./lightning-js.linux-s390x-gnu.node')
@@ -310,9 +284,10 @@ if (!nativeBinding) {
310
284
  throw new Error(`Failed to load native binding`)
311
285
  }
312
286
 
313
- const { setLogListener, generateMnemonic, PaymentEventType, MdkNode } = nativeBinding
287
+ const { setLogListener, generateMnemonic, deriveNodeId, PaymentEventType, MdkNode } = nativeBinding
314
288
 
315
289
  module.exports.setLogListener = setLogListener
316
290
  module.exports.generateMnemonic = generateMnemonic
291
+ module.exports.deriveNodeId = deriveNodeId
317
292
  module.exports.PaymentEventType = PaymentEventType
318
293
  module.exports.MdkNode = MdkNode
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moneydevkit/lightning-js",
3
- "version": "0.1.68",
3
+ "version": "0.1.71",
4
4
  "main": "index.js",
5
5
  "files": [
6
6
  "index.d.ts",
@@ -80,18 +80,18 @@
80
80
  "packageManager": "yarn@4.9.1",
81
81
  "repository": "https://github.com/moneydevkit/lightning-js",
82
82
  "optionalDependencies": {
83
- "@moneydevkit/lightning-js-win32-x64-msvc": "0.1.68",
84
- "@moneydevkit/lightning-js-darwin-x64": "0.1.68",
85
- "@moneydevkit/lightning-js-linux-x64-gnu": "0.1.68",
86
- "@moneydevkit/lightning-js-linux-x64-musl": "0.1.68",
87
- "@moneydevkit/lightning-js-linux-arm64-gnu": "0.1.68",
88
- "@moneydevkit/lightning-js-win32-ia32-msvc": "0.1.68",
89
- "@moneydevkit/lightning-js-linux-arm-gnueabihf": "0.1.68",
90
- "@moneydevkit/lightning-js-darwin-arm64": "0.1.68",
91
- "@moneydevkit/lightning-js-android-arm64": "0.1.68",
92
- "@moneydevkit/lightning-js-freebsd-x64": "0.1.68",
93
- "@moneydevkit/lightning-js-linux-arm64-musl": "0.1.68",
94
- "@moneydevkit/lightning-js-win32-arm64-msvc": "0.1.68",
95
- "@moneydevkit/lightning-js-android-arm-eabi": "0.1.68"
83
+ "@moneydevkit/lightning-js-win32-x64-msvc": "0.1.71",
84
+ "@moneydevkit/lightning-js-darwin-x64": "0.1.71",
85
+ "@moneydevkit/lightning-js-linux-x64-gnu": "0.1.71",
86
+ "@moneydevkit/lightning-js-linux-x64-musl": "0.1.71",
87
+ "@moneydevkit/lightning-js-linux-arm64-gnu": "0.1.71",
88
+ "@moneydevkit/lightning-js-win32-ia32-msvc": "0.1.71",
89
+ "@moneydevkit/lightning-js-linux-arm-gnueabihf": "0.1.71",
90
+ "@moneydevkit/lightning-js-darwin-arm64": "0.1.71",
91
+ "@moneydevkit/lightning-js-android-arm64": "0.1.71",
92
+ "@moneydevkit/lightning-js-freebsd-x64": "0.1.71",
93
+ "@moneydevkit/lightning-js-linux-arm64-musl": "0.1.71",
94
+ "@moneydevkit/lightning-js-win32-arm64-msvc": "0.1.71",
95
+ "@moneydevkit/lightning-js-android-arm-eabi": "0.1.71"
96
96
  }
97
97
  }