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-ldk
cd ios && pod install && cd ../
- Add the following line to
dependencies
in/android/app/build.gradle
dependencies { //... implementation files("../../node_modules/@synonymdev/react-native-ldk/android/libs/LDK-release.aar") // <- this }
- Ensure
minSdkVersion
is set to at least24
in/android/build.gradle
- Open
lib/android
in 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
Project
view in the Project browser tool window - Expand
External Libraries
- Right click on
Gradle: ./libs/LDK-release.aar
thenLibrary Properties…
- Tap the ➕ button and select the
./lib/android/libs/ldk-java-javadoc.jar
file - In the popup that appears select
JavaDocs
and tapOK
thenOK
again
- Switch to
# apply your changes
cd example
yarn reinstall # bump versions package.json & podfile
cd ../
# 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 android
In 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.
const userConfig: 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 conf
accept_inbound_channels: true,
};
When starting LDK, provide a list of node public keys from which you are willing to accept zero-confirmation channels.
const lmStart = await lm.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 install
working you might have to open theLDKFramework.xcframework
directory, 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 up
Then to run tests open two terminals and execute the following commands:
# Terminal 1
cd example
npm run start
# Terminal 2
cd example
npm run test:mocha
Because 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 * as mockLDK from '@synonymdev/react-native-ldk/dist/mock';
jest.mock('@synonymdev/react-native-ldk', () => mockLDK);