@sunnyln/lni 0.1.3 → 0.1.5

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 (2) hide show
  1. package/README.md +27 -15
  2. package/package.json +4 -3
package/README.md CHANGED
@@ -60,6 +60,33 @@ const status = await node.lookupInvoice({ paymentHash: invoice.paymentHash });
60
60
  const txs = await node.listTransactions({ from: 0, limit: 10 });
61
61
  ```
62
62
 
63
+ ### Invoice Event Polling
64
+
65
+ Poll for invoice settlement after creating an invoice. The callback fires with `'success'`, `'pending'`, or `'failure'`.
66
+
67
+ ```ts
68
+ await node.onInvoiceEvents(
69
+ {
70
+ paymentHash: invoice.paymentHash,
71
+ pollingDelaySec: 3,
72
+ maxPollingSec: 60,
73
+ },
74
+ (status, tx) => {
75
+ if (status === 'success') {
76
+ // Invoice was paid and settled
77
+ console.log('Paid!', tx.amountMsats, 'msats');
78
+ console.log('Preimage:', tx.preimage);
79
+ } else if (status === 'pending') {
80
+ // Still waiting — fires each poll interval
81
+ console.log('Waiting for payment...');
82
+ } else if (status === 'failure') {
83
+ // maxPollingSec exceeded without settlement
84
+ console.log('Invoice was not paid within the timeout');
85
+ }
86
+ },
87
+ );
88
+ ```
89
+
63
90
  ### Spark (browser + Expo Go oriented)
64
91
 
65
92
  ```ts
@@ -155,21 +182,6 @@ const info = await getPaymentInfo(destination, 100_000);
155
182
  const bolt11 = await resolveToBolt11(destination, 100_000);
156
183
  ```
157
184
 
158
- ### Invoice Event Polling
159
-
160
- ```ts
161
- await node.onInvoiceEvents(
162
- {
163
- paymentHash: invoice.paymentHash,
164
- pollingDelaySec: 3,
165
- maxPollingSec: 60,
166
- },
167
- (status, tx) => {
168
- console.log('Invoice event:', status, tx);
169
- },
170
- );
171
- ```
172
-
173
185
  ## Implemented in this package
174
186
 
175
187
  - `PhoenixdNode`
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@sunnyln/lni",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "private": false,
5
- "description": "Frontend-first TypeScript port of LNI lightning wallet HTTP adapters",
5
+ "description": "Lightning Node Interface. Connect to CLN, LND, Phoenixd, NWC, Strike, Speed, Blink and Spark. Supports BOLT11, BOLT12, LNURL, Lightning Address (Frontend-first TypeScript support, no wasm, no native node modules)",
6
6
  "type": "module",
7
7
  "sideEffects": false,
8
8
  "repository": {
@@ -43,7 +43,8 @@
43
43
  }
44
44
  },
45
45
  "files": [
46
- "dist"
46
+ "dist",
47
+ "README.md"
47
48
  ],
48
49
  "scripts": {
49
50
  "clean": "rm -rf dist",