Skip to content

Commit 59fd153

Browse files
authored
Merge pull request #1 from synonymdev/lnd-to-ldk
Replacing LND with LDK
2 parents 23c9233 + fc9c589 commit 59fd153

File tree

107 files changed

+124614
-10265
lines changed

Some content is hidden

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

107 files changed

+124614
-10265
lines changed

README.md

Lines changed: 11 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,29 @@
1-
# react-native-lightning
1+
# react-native-ldk
22

33
:warning: This is pre-alpha software. Please use at your own risk.
44

55

66
### Description
7-
This library hopes to simplify the process of adding Lightning via LND's Neutrino to any React-Native app.
7+
This library hopes to simplify the process of adding Lightning via LDK to any React-Native app.
88

99
## Getting started
1010

1111
```bash
12-
yarn add @synonymdev/react-native-lightning
12+
yarn add @synonymdev/react-native-ldk
1313
#or
14-
npm i -s @synonymdev/react-native-lightning
14+
npm i -s @synonymdev/react-native-ldk
1515
````
1616

1717
### iOS installation
1818
```bash
1919
cd ios && pod install && cd ../
2020
````
2121
22-
### Android installation
23-
24-
open `android/app/build.gradle` and add the below line to `dependencies`
25-
26-
`implementation files("../../node_modules/@synonymdev/react-native-lightning/android/libs/Lndmobile.aar")`
27-
2822
## Running example app
2923
```bash
3024

3125
#Build dist files
32-
git clone https://github.com/synonymdev/react-native-lightning.git
26+
git clone https://github.com/synonymdev/react-native-ldk.git
3327
yarn install && yarn build
3428

3529
cd example/
@@ -42,95 +36,22 @@ yarn android
4236

4337
## Usage
4438
```javascript
45-
import lnd, {
46-
ENetworks,
47-
LndConf,
48-
ss_lnrpc
49-
} from '@synonymdev/react-native-lightning';
50-
51-
const lndConf = new LndConf(ENetworks.regtest);
39+
import ldk from '@synonymdev/react-native-ldk';
5240
```
5341

5442
```javascript
55-
const res = await lnd.start(lndConf);
43+
const res = await ldk.start();
5644
if (res.isErr()) {
57-
//Lnd failed to start
45+
//LDK failed to start
5846
console.error(res.error)
5947
}
6048

61-
//LND state changes
62-
lnd.stateService.subscribeToStateChanges(
63-
(res: Result<ss_lnrpc.WalletState>) => {
64-
if (res.isOk()) {
65-
setLndState(res.value);
66-
}
67-
},
68-
() => {
69-
//Subscription has ended
70-
},
71-
);
72-
73-
74-
//Subscribe to LND logs
75-
const logListener = lnd.addLogListener((message) => {
49+
//Subscribe to LDK logs
50+
const logListener = ldk.addLogListener((message) => {
7651
console.log(message);
7752
});
7853

7954
//Unsubscribe if listening component is unmounted
80-
lnd.removeLogListener(logListener);
81-
82-
//All function results can be checked with res.isOk() or res.isErr()
83-
const res = await lnd.getInfo();
84-
if (res.isErr()) {
85-
console.log(res.error.message);
86-
}
87-
88-
if (res.isOk()) {
89-
console.log(res.value);
90-
}
91-
92-
//Use subscribeToOnChainTransactions/subscribeToInvoices for real time transaction updates
93-
lnd.subscribeToOnChainTransactions(
94-
(res) => {
95-
if (res.isOk()) {
96-
const { amount, blockHeight, numConfirmations } = res.value;
97-
98-
alert(`Received ${amount} sats on chain in block ${blockHeight}`)
99-
}
100-
},
101-
(res) => {
102-
//If this fails ever then we need to subscribe again
103-
console.error(res);
104-
},
105-
);
106-
107-
108-
```
109-
110-
### Using neutrino headers cache
111-
Initial neutrino sync times can take a while for first time users. This is a trusted setup that allows the app to download a cached pre-synced archive of the neutrino headers. This speeds up the time it takes for LND to become usable as syncing doesn't need to start from scratch.
112-
```bash
113-
#Add these dependencies to your app
114-
yarn add react-native-fs react-native-zip-archive
115-
#or
116-
npm i react-native-fs react-native-zip-archive -S
117-
118-
cd ios && pod install && cd ../
119-
````
120-
121-
Using it:
122-
123-
```javascript
124-
import lndCache from '@synonymdev/react-native-lightning/dist/utils/neutrino-cache';
125-
```
126-
127-
```javascript
128-
lndCache.addStateListener(
129-
(state: ICachedNeutrinoDBDownloadState) => {
130-
setMessage(JSON.stringify(state));
131-
},
132-
);
55+
ldk.removeLogListener(logListener);
13356

134-
await lndCache.downloadCache(ENetworks.testnet);
135-
await startLnd();
13657
```
-17 Bytes
Binary file not shown.

android/README.md

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)