Skip to content

Commit a474f1f

Browse files
authored
Merge pull request #1 from lightninglabs/init-project
Initialize lnc-core
2 parents d5f1d35 + 00b0cc6 commit a474f1f

Some content is hidden

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

69 files changed

+30521
-2
lines changed

.gitignore

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

.prettierignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.github/**
2+
dist/**
3+
lib/types/**
4+
package-lock.json
5+
package.json
6+
README.md
7+
tsconfig.json
8+
tslint.json

.prettierrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"singleQuote": true,
3+
"tabWidth": 4,
4+
"semi": true,
5+
"trailingComma": "none",
6+
"bracketSpacing": true
7+
}

README.md

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,32 @@
1-
# lnc-core
2-
Type definitions and utilities for Lightning Node Connect, leveraged by lnc-web and lnc-rn
1+
# @lightninglabs/lnc-core
2+
3+
## Type definitions and utilities for Lightning Node Connect, leveraged by lnc-web and lnc-rn
4+
5+
## Install
6+
7+
`npm i @lightninglabs/lnc-core`
8+
9+
## Updating protos
10+
11+
First, update the service version under the `config` block in `package.json`.
12+
13+
eg.
14+
15+
```
16+
"config": {
17+
"lnd_release_tag": "v0.14.2-beta",
18+
"loop_release_tag": "v0.17.0-beta",
19+
"pool_release_tag": "v0.5.5-alpha",
20+
"faraday_release_tag": "v0.2.5-alpha",
21+
"protoc_version": "3.15.8"
22+
},
23+
```
24+
25+
Then run the following commands:
26+
27+
```
28+
# download schemas
29+
npm run update-protos
30+
# format schemas
31+
npm run generate
32+
```

lib/api/faraday.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { FaradayServer } from '../types/proto/faraday/faraday';
2+
import { serviceNames as sn } from '../types/proto/schema';
3+
4+
/**
5+
* An API wrapper to communicate with the Faraday node via GRPC
6+
*/
7+
class FaradayApi {
8+
faradayServer: FaradayServer;
9+
10+
constructor(createRpc: Function, lnc: any) {
11+
this.faradayServer = createRpc(sn.frdrpc.FaradayServer, lnc);
12+
}
13+
}
14+
15+
export default FaradayApi;

lib/api/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export { default as LndApi } from './lnd';
2+
export { default as LoopApi } from './loop';
3+
export { default as PoolApi } from './pool';
4+
export { default as FaradayApi } from './faraday';

lib/api/lnd.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { Autopilot } from '../types/proto/lnd/autopilotrpc/autopilot';
2+
import { ChainNotifier } from '../types/proto/lnd/chainrpc/chainnotifier';
3+
import { Invoices } from '../types/proto/lnd/invoicesrpc/invoices';
4+
import { Lightning } from '../types/proto/lnd/lightning';
5+
import { Router } from '../types/proto/lnd/routerrpc/router';
6+
import { Signer } from '../types/proto/lnd/signrpc/signer';
7+
import { WalletKit } from '../types/proto/lnd/walletrpc/walletkit';
8+
import { WalletUnlocker } from '../types/proto/lnd/walletunlocker';
9+
import { Watchtower } from '../types/proto/lnd/watchtowerrpc/watchtower';
10+
import { WatchtowerClient } from '../types/proto/lnd/wtclientrpc/wtclient';
11+
import { serviceNames as sn } from '../types/proto/schema';
12+
13+
/**
14+
* An API wrapper to communicate with the LND node via GRPC
15+
*/
16+
class LndApi {
17+
autopilot: Autopilot;
18+
chainNotifier: ChainNotifier;
19+
invoices: Invoices;
20+
lightning: Lightning;
21+
router: Router;
22+
signer: Signer;
23+
walletKit: WalletKit;
24+
walletUnlocker: WalletUnlocker;
25+
watchtower: Watchtower;
26+
watchtowerClient: WatchtowerClient;
27+
28+
constructor(createRpc: Function, lnc: any) {
29+
this.autopilot = createRpc(sn.autopilotrpc.Autopilot, lnc);
30+
this.chainNotifier = createRpc(sn.chainrpc.ChainNotifier, lnc);
31+
this.invoices = createRpc(sn.invoicesrpc.Invoices, lnc);
32+
this.lightning = createRpc(sn.lnrpc.Lightning, lnc);
33+
this.router = createRpc(sn.routerrpc.Router, lnc);
34+
this.signer = createRpc(sn.signrpc.Signer, lnc);
35+
this.walletKit = createRpc(sn.walletrpc.WalletKit, lnc);
36+
this.walletUnlocker = createRpc(sn.lnrpc.WalletUnlocker, lnc);
37+
this.watchtower = createRpc(sn.watchtowerrpc.Watchtower, lnc);
38+
this.watchtowerClient = createRpc(sn.wtclientrpc.WatchtowerClient, lnc);
39+
}
40+
}
41+
42+
export default LndApi;

lib/api/loop.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { SwapClient } from '../types/proto/loop/client';
2+
import { Debug } from '../types/proto/loop/debug';
3+
import { serviceNames as sn } from '../types/proto/schema';
4+
5+
/**
6+
* An API wrapper to communicate with the Loop node via GRPC
7+
*/
8+
class LoopApi {
9+
swapClient: SwapClient;
10+
debug: Debug;
11+
12+
constructor(createRpc: Function, lnc: any) {
13+
this.swapClient = createRpc(sn.looprpc.SwapClient, lnc);
14+
this.debug = createRpc(sn.looprpc.Debug, lnc);
15+
}
16+
}
17+
18+
export default LoopApi;

lib/api/pool.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { ChannelAuctioneer } from '../types/proto/pool/auctioneerrpc/auctioneer';
2+
import { HashMail } from '../types/proto/pool/auctioneerrpc/hashmail';
3+
import { Trader } from '../types/proto/pool/trader';
4+
import { serviceNames as sn } from '../types/proto/schema';
5+
6+
/**
7+
* An API wrapper to communicate with the Pool node via GRPC
8+
*/
9+
class PoolApi {
10+
trader: Trader;
11+
channelAuctioneer: ChannelAuctioneer;
12+
hashmail: HashMail;
13+
14+
constructor(createRpc: Function, lnc: any) {
15+
this.trader = createRpc(sn.poolrpc.Trader, lnc);
16+
this.channelAuctioneer = createRpc(sn.poolrpc.ChannelAuctioneer, lnc);
17+
this.hashmail = createRpc(sn.poolrpc.HashMail, lnc);
18+
}
19+
}
20+
21+
export default PoolApi;

lib/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export * from './types/proto';
2+
export { camelKeysToSnake, isObject, snakeKeysToCamel } from './util/objects';
3+
export { LndApi, LoopApi, PoolApi, FaradayApi } from './api';
4+
export { subscriptionMethods } from './types/proto/schema';

0 commit comments

Comments
 (0)