react-native-lightning
:warning: This is pre-alpha software. Please use as your own risk.
Description
This library hopes to simplify the process of adding Lightning via LND's Neutrino to any React-Native app.
Getting started
yarn add react-native-lightning
cd ios && pod install && cd ../
or build and add from local repo
git clone https://github.com/synonymdev/react-native-lightning.git
cd react-native-lightning
yarn install && yarn build
cd ../
yarn add ../react-native-lightning
cd ios && pod install && cd ../
open `android/app/build.gradle` and add the below line to `dependencies`
`implementation files("../../node_modules/react-native-lightning/android/libs/Lndmobile.aar")`
Running example app
git clone https://github.com/synonymdev/react-native-lightning.git
yarn install && yarn build
cd example/
yarn install
yarn ios
yarn android
Usage
import lnd, {
ENetworks,
LndConf,
TCurrentLndState,
} from 'react-native-lightning';
const lndConf = new LndConf(ENetworks.regtest);
const res = await lnd.start(lndConf);
if (res.isErr()) {
console.error(res.error)
}
lnd.subscribeToCurrentState(({lndRunning, walletUnlocked, grpcReady}) => {
console.log(`lndRunning: ${lndRunning}`);
console.log(`walletUnlocked: ${walletUnlocked}`);
console.log(`grpcReady: ${grpcReady}`);
});
const logListener = lnd.addLogListener((message) => {
console.log(message);
});
lnd.removeLogListener(logListener);
const res = await lnd.getInfo();
if (res.isErr()) {
console.log(res.error.message);
}
if (res.isOk()) {
console.log(res.value);
}
lnd.subscribeToOnChainTransactions(
(res) => {
if (res.isOk()) {
const { amount, blockHeight, numConfirmations } = res.value;
alert(`Received ${amount} sats on chain in block ${blockHeight}`)
}
},
(res) => {
console.error(res);
},
);