Skip to content

Commit a5ec787

Browse files
authored
Merge pull request #37 from lightninglabs/main
[Releases] v0.0.1-alpha.rc1
2 parents acb7d7e + 45cd439 commit a5ec787

File tree

108 files changed

+59288
-1483
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+59288
-1483
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
*.DS_Store
22
node_modules/
3+
dist/

README.md

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,32 @@
1-
# @lightninglabs/lnc
1+
# @lightninglabs/lnc-web
22

33
## A npm module for Lightning Node Connect
44

55
## API Design
6+
67
#### Set-up and connection
78

89
The constructor for the LNC object takes a parameters object with the three following fields:
910

10-
- `pairingPhrase` (string, required): Your LNC pairing phrase
11-
- `serverHost` (string): Specify a custom Lightning Node Connect proxy server. If not specified we'll default to `mailbox.terminal.lightning.today:443`
12-
- `wasmClientCode` (string): Custom location for the WASM client code. Can be remote or local. If not specified we’ll default to our instance on our CDN.
11+
- `pairingPhrase` (string): Your LNC pairing phrase
12+
- `serverHost` (string): Specify a custom Lightning Node Connect proxy server. If not specified we'll default to `mailbox.terminal.lightning.today:443`.
13+
- `wasmClientCode` (string): Custom location for the WASM client code. Can be remote or local. If not specified we’ll default to our instance on our CDN.
14+
- `namespace` (string): JavaScript namespace used for the main WASM calls. You can maintain multiple connections if you use different namespaces. If not specified we'll default to `default`.
15+
- `password` (string): By default, this module will handle storage of your local and remote keys for you in local storage. We highly recommend encrypting that data with a password you set here.
1316

1417
```
15-
import LNC from ‘@lightninglabs/lnc’;
18+
import LNC from ‘@lightninglabs/lnc-web’;
1619
1720
const pairingPhrase = ‘artefact morning piano photo consider light’;
21+
const password = 'u*E0F?gU\d($N&Ckh8u)tLm';
1822
1923
// default connection using WASM from CDN
2024
// WASM loaded on object creation
2125
// default host: mailbox.terminal.lightning.today:443
26+
// password used for encrypting credentials
2227
const lnc = new LNC({
23-
pairingPhrase
28+
pairingPhrase,
29+
password
2430
});
2531
2632
// using custom Lightning Node Connect proxy server
@@ -32,7 +38,7 @@ const lnc = new LNC({
3238
// using WASM pulled into app
3339
const lnc = new LNC({
3440
pairingPhrase,
35-
wasmClientCode: ‘​​wasm-client.wasm’
41+
wasmClientCode: ‘/path/to/​​wasm-client.wasm’
3642
});
3743
3844
// using WASM from external link
@@ -74,7 +80,6 @@ const poolAccount = await pool.trader.initAccount(100000000, 1000);
7480
const insights = await faraday.channelInsights();
7581
```
7682

77-
7883
#### Subscriptions
7984

8085
```
@@ -84,11 +89,13 @@ const { lnd } = lnc;
8489
lnd.lightning.subscribeTransactions(
8590
params,
8691
transaction => handleNewData(transaction),
92+
error => handleError(error),
8793
);
8894
8995
lnd.lightning.subscribeChannelEvents(
9096
params,
9197
event => handleNewChannelEventData(event),
98+
error => handleError(error),
9299
);
93100
```
94101

demos/connect-demo/.gitignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# production
12+
/build
13+
14+
# misc
15+
.DS_Store
16+
.env.local
17+
.env.development.local
18+
.env.test.local
19+
.env.production.local
20+
21+
npm-debug.log*
22+
yarn-debug.log*
23+
yarn-error.log*
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"overrides": [
3+
{
4+
"files": [".prettierrc", ".babelrc", ".eslintrc", ".stylelintrc"],
5+
"options": {
6+
"parser": "json"
7+
}
8+
}
9+
],
10+
"printWidth": 90,
11+
"proseWrap": "always",
12+
"singleQuote": true,
13+
"useTabs": false,
14+
"semi": true,
15+
"tabWidth": 2,
16+
"trailingComma": "all",
17+
"bracketSpacing": true,
18+
"jsxBracketSameLine": false,
19+
"arrowParens": "avoid"
20+
}

demos/connect-demo/README.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# LNC Demo - Basic Connect
2+
3+
This demo showcases the most basic flow to connect from a browser to a Lightning Terminal
4+
(litd) node using the `lnc-web` NPM package.
5+
6+
## Running the demo
7+
8+
To run the demo, you'll need to have NodeJS installed and a Lightning Terminal node
9+
accessible that you can obtain a pairing phrase from.
10+
11+
1. Clone this repo
12+
```sh
13+
$ git clone https://github.com/lightninglabs/lnc-web.git
14+
$ cd lnc-web/demos/connect-demo
15+
```
16+
2. Install the dependencies
17+
```sh
18+
$ npm install
19+
```
20+
3. Start the web app
21+
```sh
22+
$ npm start
23+
```
24+
Your browser should open to http://localhost:3000 and you should see the home page
25+
below
26+
27+
## Screenshots
28+
29+
### Welcome page with Connect button
30+
31+
![1_welcome](./public/img/1_welcome.png)
32+
33+
### Connect page
34+
35+
Enter your pairing phrase and a new password to use so you don't need to login again
36+
37+
![2_connect](./public/img/2_connect.png)
38+
39+
### Welcome page when connected
40+
41+
After connecting to your node, you'll be redirected back to the welcome page, but now it
42+
will display some information obtained from calling `GetInfo` on `lnd`.
43+
44+
![3_connected](./public/img/3_connected.png)
45+
46+
### Login page
47+
48+
If you reload the page or click the Logout link, you will be taken back to the Welcome
49+
page. It will detect that you have already connected from this browser in the past and
50+
display a "Login" button instead of "Connect". When you click "Login", you'll be take to
51+
the Login page where you only need to provide your password to reconnect to your node.
52+
53+
![4_login](./public/img/4_login.png)

0 commit comments

Comments
 (0)