commit f5c9247f127cf21859f7b07bb1f64dca72ad3993
parent fcb77a520908b5b1dae25280bfcf7c51ed871716
Author: William Casarin <jb55@jb55.com>
Date: Wed, 23 Mar 2022 11:43:31 -0700
more js instructions
Diffstat:
1 file changed, 16 insertions(+), 5 deletions(-)
diff --git a/README.md b/README.md
@@ -35,6 +35,13 @@ This will build `lnsocket.a`, `libsodium.a` and `libsecp256k1.a` under
### WASM/JS/Web
+Building manually:
+
+ $ make js
+
+This will build `lnsocket.js` and `lnsocket.wasm` in `target/js` so that you
+can connect to the lightning network from your browser via websockets.
+
There are packaged versions of the js build under [dist/js](dist/js)
If you are in a web environment that supports npm modules, you can import
@@ -51,13 +58,17 @@ async function makeRequest(method, params, rune) {
}
```
-Building manually:
+The plain js file under [dist/js](dist/js) declares an `lnsocket_init()`
+function like so:
- $ make js
+```js
+const LNSocket = await lnsocket_init()
+const ln = LNSocket()
-This will build `lnsocket.js` and `lnsocket.wasm` in `target/js` so that you
-can connect to the lightning network from your browser via websockets. See
-[examples/websockets.js](examples/websockets.js) for a demo.
+ln.genkey()
+```
+
+See [examples/websockets.js](examples/websockets.js) for a demo.
### NodeJS