@ambosstech/lightning-mpp-adapter-nwc 0.1.1 → 0.2.2
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.
- package/README.md +59 -0
- package/package.json +15 -1
package/README.md
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# @ambosstech/lightning-mpp-adapter-nwc
|
|
2
|
+
|
|
3
|
+
[Nostr Wallet Connect](https://github.com/nostr-protocol/nips/blob/master/47.md) (NIP-47) adapter for the [Lightning MPP SDK](https://www.npmjs.com/package/@ambosstech/lightning-mpp-sdk). Connect to any NWC-compatible wallet — Alby Hub, coinos, Primal, etc.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @ambosstech/lightning-mpp-sdk @ambosstech/lightning-mpp-adapter-nwc
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { NwcLightningProvider } from "@ambosstech/lightning-mpp-adapter-nwc";
|
|
15
|
+
|
|
16
|
+
const provider = new NwcLightningProvider({
|
|
17
|
+
connectionString: "nostr+walletconnect://pubkey?relay=wss://relay.example.com&secret=hex",
|
|
18
|
+
timeoutSecs: 60, // optional, default 60
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
// Use like any other provider
|
|
22
|
+
const invoice = await provider.createInvoice({ amountSats: 1000, memo: "test" });
|
|
23
|
+
const { preimage } = await provider.payInvoice({ bolt11: invoice.bolt11 });
|
|
24
|
+
const lookup = await provider.lookupInvoice({ paymentHash: invoice.paymentHash });
|
|
25
|
+
|
|
26
|
+
// Clean up when done
|
|
27
|
+
provider.close();
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### With the SDK
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
import { lightningChargeServer } from "@ambosstech/lightning-mpp-sdk";
|
|
34
|
+
|
|
35
|
+
const chargeMethod = lightningChargeServer({
|
|
36
|
+
provider,
|
|
37
|
+
currency: "sat",
|
|
38
|
+
network: "mainnet",
|
|
39
|
+
});
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Configuration
|
|
43
|
+
|
|
44
|
+
| Option | Type | Default | Description |
|
|
45
|
+
| ------------------ | -------- | ------- | ------------------------------------ |
|
|
46
|
+
| `connectionString` | `string` | — | NWC connection URI (required) |
|
|
47
|
+
| `timeoutSecs` | `number` | `60` | Response timeout in seconds |
|
|
48
|
+
|
|
49
|
+
The connection string is provided by your wallet and contains the wallet pubkey, relay URL, and client secret. All communication is encrypted with NIP-44.
|
|
50
|
+
|
|
51
|
+
## Notes
|
|
52
|
+
|
|
53
|
+
- **Unit conversion**: The SDK uses satoshis; NWC uses millisatoshis. Conversion is handled automatically.
|
|
54
|
+
- **`maxFeeSats`**: NWC does not support fee limits — fees are controlled by the wallet. A warning is logged if provided.
|
|
55
|
+
- **Connection lifecycle**: The relay connection is established lazily on the first request. Call `provider.close()` to disconnect.
|
|
56
|
+
|
|
57
|
+
## License
|
|
58
|
+
|
|
59
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ambosstech/lightning-mpp-adapter-nwc",
|
|
3
|
-
"
|
|
3
|
+
"description": "Nostr Wallet Connect (NIP-47) adapter for the Lightning MPP SDK",
|
|
4
|
+
"keywords": [
|
|
5
|
+
"lightning",
|
|
6
|
+
"bitcoin",
|
|
7
|
+
"nostr",
|
|
8
|
+
"nwc",
|
|
9
|
+
"nip-47",
|
|
10
|
+
"mpp"
|
|
11
|
+
],
|
|
12
|
+
"version": "0.2.2",
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "https://github.com/AmbossTech/lightning-mpp-sdk.git",
|
|
16
|
+
"directory": "packages/adapter-nwc"
|
|
17
|
+
},
|
|
4
18
|
"type": "module",
|
|
5
19
|
"main": "./dist/index.cjs",
|
|
6
20
|
"module": "./dist/index.js",
|