This library hopes to simplify the process of adding Lightning via LDK to any React-Native app.
yarn add @synonymdev/react-native-ldk
#or
npm i -S @synonymdev/react-native-ldkcd ios && pod install &&cd ../- Add the following line to
dependenciesin/android/app/build.gradledependencies { //... implementation files("../../node_modules/@synonymdev/react-native-ldk/android/libs/LDK-release.aar") // <- this } - Ensure
minSdkVersionis set to at least24in/android/build.gradle
- Open
lib/androidin Android Studio - To enable documentation for the LDK code, follow this guide: How to attach JavaDoc to the library in Android Studio, ie.:
- Switch to
Projectview in the Project browser tool window - Expand
External Libraries - Right click on
Gradle: ./libs/LDK-release.aarthenLibrary Properties… - Tap the ➕ button and select the
./lib/android/libs/ldk-java-javadoc.jarfile - In the popup that appears select
JavaDocsand tapOKthenOKagain
- Switch to
# apply your changescd example
yarn reinstall # bump versions package.json & podfilecd ../
# copy version from `./lib/package.json` to `backup-server/package.json`See also ./example/README.md
# Build dist files
git clone https://github.com/synonymdev/react-native-ldk.git
cd react-native-ldk/lib/ && yarn install && yarn build &&cd ../
cd example/ && yarn install && yarn rn-setup
yarn ios
# or
yarn androidIn constants.ts update peers.lnd if you're using Polar locally.
// export const peers = {// lnd: {pubKey:
'_033f4d3032ce7f54224f4bd9747b50b7cd72074a859758e40e1ca46ffa79a34324_',address: '10.0.2.2',port: 9737,// },- It is important to not mix and match account names and seeds when starting LDK. Doing so can result in a corrupt save.
Channels needs to be manually accepted but this is handled by channel-manager.ts if counterparty is in our trusted peer list.
constuserConfig: TUserConfig={channel_handshake_config: {announced_channel: false,minimum_depth: 1,max_htlc_value_in_flight_percent_of_channel: 100,negotiate_anchors_zero_fee_htlc_tx: true,//Required for zero conf},manually_accept_inbound_channels: true,//Required for zero confaccept_inbound_channels: true,};When starting LDK, provide a list of node public keys from which you are willing to accept zero-confirmation channels.
constlmStart=awaitlm.start(
...
trustedZeroConfPeers: ['03fc8877790430d7fb29e7bcf6b8bbfa3050e5e89189e27f97300e8a1e9ce589a3']From LND update your conf as specified here and open with these params:
lncli openchannel --node_key=03c6b2081d6f333fe3a9655cdb864be7b6b46c8648188a44b6a412e41b63a43272 --local_amt=200000 --push_amt=50000 --private=true --zero_conf --channel_type=anchors
- Use latest LDK-release.aar from ldk-garbagecollected and place in
lib/android/libs. - Use latest LDKFramework.xcframework from ldk-swift and place in lib/ios.
- To get
pod installworking you might have to open theLDKFramework.xcframeworkdirectory, delete non ios frameworks and remove all references to deleted frameworks insideLDKFramework.xcframework/Info.plist.
- To get
- Update Swift and Kotlin code if there are any breaking changes.
Tests are implemented using mocha-remote. To run tests at first you need to install docker and start tesing regtest enviroment using docker-compose:
cd example
docker-compose upThen to run tests open two terminals and execute the following commands:
# Terminal 1cd example
npm run start# Terminal 2cd example
npm run test:mochaBecause it's a native module, you need to mock this package.
The package provides a default mock you may use in your __mocks__/@synonymdev/react-native-ldk.js or jest.setup.js.
import*asmockLDKfrom'@synonymdev/react-native-ldk/dist/mock';jest.mock('@synonymdev/react-native-ldk',()=>mockLDK);