Skip to content
This repository was archived by the owner on Oct 24, 2022. It is now read-only.

Commit f525198

Browse files
committed
Update README.md
Code cleanup Code cleanup
1 parent f693e0e commit f525198

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

README.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ yarn android
4545
import lnd, {
4646
ENetworks,
4747
LndConf,
48-
TCurrentLndState,
48+
ss_lnrpc
4949
} from '@synonymdev/react-native-lightning';
5050

5151
const lndConf = new LndConf(ENetworks.regtest);
@@ -59,11 +59,16 @@ if (res.isErr()) {
5959
}
6060

6161
//LND state changes
62-
lnd.subscribeToCurrentState(({lndRunning, walletUnlocked, grpcReady}) => {
63-
console.log(`lndRunning: ${lndRunning}`);
64-
console.log(`walletUnlocked: ${walletUnlocked}`);
65-
console.log(`grpcReady: ${grpcReady}`);
66-
});
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+
);
6772

6873

6974
//Subscribe to LND logs

src/services/walletunlocker.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import GrpcAction from '../grpc';
22
import { err, ok, Result } from '../utils/result';
3-
import { EGrpcStreamMethods, EGrpcSyncMethods } from '../utils/types';
3+
import { EGrpcSyncMethods } from '../utils/types';
44
import { lnrpc, wu_lnrpc } from '../';
55
import { hexStringToBytes, stringToBytes } from '../utils/helpers';
6-
import base64 from 'base64-js';
76

87
class WalletUnlocker {
98
private readonly grpc: GrpcAction;
@@ -33,7 +32,7 @@ class WalletUnlocker {
3332

3433
/**
3534
* Once LND is started then the wallet can be created and unlocked with this.
36-
* @return {Promise<Ok<any> | Err<unknown>>}
35+
* @return {Promise<Err<unknown> | Ok<wu_lnrpc.InitWalletResponse>>}
3736
* @param password
3837
* @param seed
3938
* @param multiChanBackup
@@ -69,7 +68,7 @@ class WalletUnlocker {
6968

7069
/**
7170
* Once LND is started then the wallet can be unlocked with this.
72-
* @return {Promise<Ok<string> | Err<unknown>>}
71+
* @return {Promise<Ok<wu_lnrpc.UnlockWalletResponse> | Err<unknown>>}
7372
* @param password
7473
*/
7574
async unlockWallet(password: string): Promise<Result<wu_lnrpc.UnlockWalletResponse>> {

0 commit comments

Comments
 (0)