Skip to content

Commit

Permalink
Merge pull request #269 from synonymdev/local-fundend-channels-rn-run…
Browse files Browse the repository at this point in the history
…-fix

Fix Example app on Android for Local funded channels PR
  • Loading branch information
Jasonvdb authored Sep 4, 2024
2 parents 39a6143 + 369f0e1 commit a90b556
Show file tree
Hide file tree
Showing 6 changed files with 521 additions and 60 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.vscode/
.idea/
**/.DS_Store
example/.watchman*
Expand Down
35 changes: 24 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@ This library hopes to simplify the process of adding Lightning via LDK to any Re
yarn add @synonymdev/react-native-ldk
#or
npm i -S @synonymdev/react-native-ldk
````
```

### iOS installation
```bash
cd ios && pod install && cd ../
````
```

### Android installation
1. 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")
}
```
```groovy
dependencies {
//...
implementation files("../../node_modules/@synonymdev/react-native-ldk/android/libs/LDK-release.aar") // <- this
}
```
2. Ensure `minSdkVersion` is set to at least `24` in `/android/build.gradle`
## Development
Expand All @@ -40,19 +40,32 @@ dependencies {
5. In the popup that appears select `JavaDocs` and tap `OK` then `OK` again
## Running example app
See also [`./example/README.md`](./example/README.md)
```bash

#Build dist files
# 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
# or
yarn android
```

### Update config to match your local setup
In `constants.ts` update `peers.lnd` if you're using Polar locally.
### Example for Android
```ts
// export const peers = {
// lnd: {
pubKey:
'_033f4d3032ce7f54224f4bd9747b50b7cd72074a859758e40e1ca46ffa79a34324_',
address: '10.0.2.2',
port: 9737,
// },
```

## Notes
- It is important to not mix and match account names and seeds when starting LDK. Doing so can result in a corrupt save.

Expand Down
5 changes: 5 additions & 0 deletions example/babel.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
module.exports = {
presets: ['module:metro-react-native-babel-preset'],
plugins: [
['@babel/plugin-transform-class-properties', { loose: false }],
['@babel/plugin-proposal-private-methods', { loose: false }],
['@babel/plugin-transform-private-property-in-object', { loose: false }],
],
};
21 changes: 18 additions & 3 deletions example/metro.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,26 @@
const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');
const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config');
const path = require('path');

/**
* Metro configuration
* https://facebook.github.io/metro/docs/configuration
*
* @type {import('metro-config').MetroConfig}
*/
const config = {};
const defaultConfig = getDefaultConfig(__dirname);

module.exports = mergeConfig(getDefaultConfig(__dirname), config);
const config = {
resolver: {
extraNodeModules: {
stream: path.resolve(__dirname, 'node_modules/stream-browserify'),
buffer: path.resolve(__dirname, 'node_modules/buffer/'),
assert: path.resolve(__dirname, 'node_modules/assert/'),
events: path.resolve(__dirname, 'node_modules/events/'),
crypto: path.resolve(__dirname, 'node_modules/crypto-browserify/'),
vm: path.resolve(__dirname, 'node_modules/vm-browserify/'),
process: path.resolve(__dirname, 'node_modules/process/'),
},
},
};

module.exports = mergeConfig(defaultConfig, config);
14 changes: 9 additions & 5 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,17 @@
"@react-native-async-storage/async-storage": "1.19.4",
"@react-native-clipboard/clipboard": "1.12.1",
"@synonymdev/react-native-ldk": "../lib",
"assert": "1.5.0",
"assert": "^2.1.0",
"b4a": "^1.6.4",
"bip32": "2.0.6",
"bip39": "3.0.4",
"bitcoinjs-lib": "6.0.2",
"buffer": "4.9.2",
"buffer": "^6.0.3",
"chai": "^4.3.7",
"events": "1.1.1",
"crypto-browserify": "^3.12.0",
"events": "^3.3.0",
"mocha-remote-client": "^1.6.1",
"process": "0.11.10",
"process": "^0.11.10",
"query-string": "^8.1.0",
"react": "18.2.0",
"react-native": "0.72.4",
Expand All @@ -52,10 +53,13 @@
"readable-stream": "4.4.2",
"rn-electrum-client": "github:synonymdev/react-native-electrum-client#dfbe9ebba4e4cf0d16e3ccea3dc49e05285d860f",
"stream-browserify": "^3.0.0",
"vm-browserify": "0.0.4"
"vm-browserify": "^1.1.2"
},
"devDependencies": {
"@babel/core": "^7.20.0",
"@babel/plugin-proposal-private-methods": "^7.18.6",
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
"@babel/plugin-transform-private-property-in-object": "^7.24.7",
"@babel/preset-env": "^7.20.0",
"@babel/runtime": "^7.20.0",
"@react-native/eslint-config": "^0.72.2",
Expand Down
Loading

0 comments on commit a90b556

Please sign in to comment.