Skip to content

Commit 6fd3d34

Browse files
committed
update docs
1 parent 5e66af8 commit 6fd3d34

File tree

2 files changed

+28
-16
lines changed

2 files changed

+28
-16
lines changed

bindings/typescript/README.md

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,33 @@ const status = await node.lookupInvoice({ paymentHash: invoice.paymentHash });
6060
const txs = await node.listTransactions({ from: 0, limit: 10 });
6161
```
6262

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+
6390
### Spark (browser + Expo Go oriented)
6491

6592
```ts
@@ -155,21 +182,6 @@ const info = await getPaymentInfo(destination, 100_000);
155182
const bolt11 = await resolveToBolt11(destination, 100_000);
156183
```
157184

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-
173185
## Implemented in this package
174186

175187
- `PhoenixdNode`

bindings/typescript/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@sunnyln/lni",
3-
"version": "0.1.4",
3+
"version": "0.1.5",
44
"private": false,
55
"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)",
66
"type": "module",

0 commit comments

Comments
 (0)