Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.DS_Store
node_modules/
dist/
8 changes: 8 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.github/**
dist/**
lib/types/**
package-lock.json
package.json
README.md
tsconfig.json
tslint.json
7 changes: 7 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"singleQuote": true,
"tabWidth": 4,
"semi": true,
"trailingComma": "none",
"bracketSpacing": true
}
34 changes: 32 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,32 @@
# lnc-core
Type definitions and utilities for Lightning Node Connect, leveraged by lnc-web and lnc-rn
# @lightninglabs/lnc-core

## Type definitions and utilities for Lightning Node Connect, leveraged by lnc-web and lnc-rn

## Install

`npm i @lightninglabs/lnc-core`

## Updating protos

First, update the service version under the `config` block in `package.json`.

eg.

```
"config": {
"lnd_release_tag": "v0.14.2-beta",
"loop_release_tag": "v0.17.0-beta",
"pool_release_tag": "v0.5.5-alpha",
"faraday_release_tag": "v0.2.5-alpha",
"protoc_version": "3.15.8"
},
```

Then run the following commands:

```
# download schemas
npm run update-protos
# format schemas
npm run generate
```
15 changes: 15 additions & 0 deletions lib/api/faraday.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { FaradayServer } from '../types/proto/faraday/faraday';
import { serviceNames as sn } from '../types/proto/schema';

/**
* An API wrapper to communicate with the Faraday node via GRPC
*/
class FaradayApi {
faradayServer: FaradayServer;

constructor(createRpc: Function, lnc: any) {
this.faradayServer = createRpc(sn.frdrpc.FaradayServer, lnc);
}
}

export default FaradayApi;
4 changes: 4 additions & 0 deletions lib/api/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export { default as LndApi } from './lnd';
export { default as LoopApi } from './loop';
export { default as PoolApi } from './pool';
export { default as FaradayApi } from './faraday';
42 changes: 42 additions & 0 deletions lib/api/lnd.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { Autopilot } from '../types/proto/lnd/autopilotrpc/autopilot';
import { ChainNotifier } from '../types/proto/lnd/chainrpc/chainnotifier';
import { Invoices } from '../types/proto/lnd/invoicesrpc/invoices';
import { Lightning } from '../types/proto/lnd/lightning';
import { Router } from '../types/proto/lnd/routerrpc/router';
import { Signer } from '../types/proto/lnd/signrpc/signer';
import { WalletKit } from '../types/proto/lnd/walletrpc/walletkit';
import { WalletUnlocker } from '../types/proto/lnd/walletunlocker';
import { Watchtower } from '../types/proto/lnd/watchtowerrpc/watchtower';
import { WatchtowerClient } from '../types/proto/lnd/wtclientrpc/wtclient';
import { serviceNames as sn } from '../types/proto/schema';

/**
* An API wrapper to communicate with the LND node via GRPC
*/
class LndApi {
autopilot: Autopilot;
chainNotifier: ChainNotifier;
invoices: Invoices;
lightning: Lightning;
router: Router;
signer: Signer;
walletKit: WalletKit;
walletUnlocker: WalletUnlocker;
watchtower: Watchtower;
watchtowerClient: WatchtowerClient;

constructor(createRpc: Function, lnc: any) {
this.autopilot = createRpc(sn.autopilotrpc.Autopilot, lnc);
this.chainNotifier = createRpc(sn.chainrpc.ChainNotifier, lnc);
this.invoices = createRpc(sn.invoicesrpc.Invoices, lnc);
this.lightning = createRpc(sn.lnrpc.Lightning, lnc);
this.router = createRpc(sn.routerrpc.Router, lnc);
this.signer = createRpc(sn.signrpc.Signer, lnc);
this.walletKit = createRpc(sn.walletrpc.WalletKit, lnc);
this.walletUnlocker = createRpc(sn.lnrpc.WalletUnlocker, lnc);
this.watchtower = createRpc(sn.watchtowerrpc.Watchtower, lnc);
this.watchtowerClient = createRpc(sn.wtclientrpc.WatchtowerClient, lnc);
}
}

export default LndApi;
18 changes: 18 additions & 0 deletions lib/api/loop.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { SwapClient } from '../types/proto/loop/client';
import { Debug } from '../types/proto/loop/debug';
import { serviceNames as sn } from '../types/proto/schema';

/**
* An API wrapper to communicate with the Loop node via GRPC
*/
class LoopApi {
swapClient: SwapClient;
debug: Debug;

constructor(createRpc: Function, lnc: any) {
this.swapClient = createRpc(sn.looprpc.SwapClient, lnc);
this.debug = createRpc(sn.looprpc.Debug, lnc);
}
}

export default LoopApi;
21 changes: 21 additions & 0 deletions lib/api/pool.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { ChannelAuctioneer } from '../types/proto/pool/auctioneerrpc/auctioneer';
import { HashMail } from '../types/proto/pool/auctioneerrpc/hashmail';
import { Trader } from '../types/proto/pool/trader';
import { serviceNames as sn } from '../types/proto/schema';

/**
* An API wrapper to communicate with the Pool node via GRPC
*/
class PoolApi {
trader: Trader;
channelAuctioneer: ChannelAuctioneer;
hashmail: HashMail;

constructor(createRpc: Function, lnc: any) {
this.trader = createRpc(sn.poolrpc.Trader, lnc);
this.channelAuctioneer = createRpc(sn.poolrpc.ChannelAuctioneer, lnc);
this.hashmail = createRpc(sn.poolrpc.HashMail, lnc);
}
}

export default PoolApi;
4 changes: 4 additions & 0 deletions lib/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export * from './types/proto';
export { camelKeysToSnake, isObject, snakeKeysToCamel } from './util/objects';
export { LndApi, LoopApi, PoolApi, FaradayApi } from './api';
export { subscriptionMethods } from './types/proto/schema';
1 change: 1 addition & 0 deletions lib/types/proto/autopilotrpc.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './lnd/autopilotrpc/autopilot';
1 change: 1 addition & 0 deletions lib/types/proto/chainrpc.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './lnd/chainrpc/chainnotifier';
Loading