Skip to content

Commit 2c38b06

Browse files
authored
Merge branch 'master' into dependabot/npm_and_yarn/example/semver-5.7.2
2 parents a57b7af + d4c07d9 commit 2c38b06

File tree

79 files changed

+92422
-65754
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+92422
-65754
lines changed

.github/workflows/mocha-android.yml

+118
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
name: mocha-android
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- 'master'
7+
push:
8+
branches:
9+
- 'master'
10+
11+
jobs:
12+
mocha-android:
13+
runs-on: macos-12
14+
timeout-minutes: 120
15+
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v3
19+
with:
20+
fetch-depth: 1
21+
22+
- name: Setup Docker Colima 1
23+
uses: douglascamata/setup-docker-macos-action@v1-alpha
24+
id: docker1
25+
continue-on-error: true
26+
27+
- name: Setup Docker Colima 2
28+
if: steps.docker1.outcome != 'success'
29+
uses: douglascamata/setup-docker-macos-action@v1-alpha
30+
id: docker2
31+
continue-on-error: true
32+
33+
- name: Setup Docker Default
34+
if: steps.docker1.outcome != 'success' && steps.docker2.outcome != 'success'
35+
uses: docker-practice/actions-setup-docker@1.0.12
36+
timeout-minutes: 30
37+
38+
- name: Run regtest setup
39+
working-directory: example/docker
40+
run: |
41+
mkdir lnd
42+
mkdir clightning
43+
chmod 777 lnd clightning
44+
docker-compose up -d
45+
46+
- name: Wait for electrum server
47+
timeout-minutes: 2
48+
run: while ! nc -z '127.0.0.1' 60001; do sleep 1; done
49+
50+
- name: Node
51+
uses: actions/setup-node@v3
52+
with:
53+
node-version: 16
54+
cache: 'yarn' # cache packages, but not node_modules
55+
cache-dependency-path: 'example/yarn.lock'
56+
57+
- name: Cache lib node modules
58+
uses: actions/cache@v3
59+
id: lib-npmcache
60+
with:
61+
path: lib/node_modules
62+
key: node-modules-${{ hashFiles('**/yarn.lock') }}
63+
64+
- name: Install lib dependencies
65+
if: steps.lib-npmcache.outputs.cache-hit != 'true'
66+
working-directory: lib
67+
run: yarn --no-audit --prefer-offline || yarn --no-audit --prefer-offline
68+
69+
- name: Build lib
70+
working-directory: lib
71+
run: yarn build
72+
73+
- name: Use gradle caches
74+
uses: actions/cache@v2
75+
with:
76+
path: ~/.gradle/caches
77+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
78+
restore-keys: |
79+
${{ runner.os }}-gradle-
80+
81+
# - name: Cache node modules
82+
# uses: actions/cache@v3
83+
# id: cache-nm
84+
# with:
85+
# path: node_modules
86+
# key: node-modules-${{ hashFiles('**/yarn.lock') }}
87+
88+
- name: Install node_modules
89+
working-directory: example
90+
run: yarn install && yarn rn-setup
91+
92+
- name: Use specific Java version for sdkmanager to work
93+
uses: actions/setup-java@v2
94+
with:
95+
distribution: 'temurin'
96+
java-version: '11'
97+
98+
# - name: Build
99+
# working-directory: example
100+
# run: npx react-native run-android --no-packager
101+
102+
- name: run tests
103+
uses: reactivecircus/android-emulator-runner@v2
104+
with:
105+
api-level: 31
106+
avd-name: Pixel_API_31_AOSP
107+
emulator-options: -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim -camera-back none -camera-front none -partition-size 2047
108+
arch: x86_64
109+
disable-animations: true
110+
working-directory: example
111+
script: |
112+
../.github/workflows/mocha-anrdoid.sh
113+
114+
- uses: actions/upload-artifact@v3
115+
if: failure()
116+
with:
117+
name: ldk-data
118+
path: example/artifacts/

.github/workflows/mocha-anrdoid.sh

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
3+
adb reverse tcp:8090 tcp:8090
4+
adb reverse tcp:9090 tcp:9090
5+
adb reverse tcp:9091 tcp:9091
6+
adb reverse tcp:9092 tcp:9092
7+
adb reverse tcp:9735 tcp:9735
8+
adb reverse tcp:9736 tcp:9736
9+
adb reverse tcp:9737 tcp:9737
10+
adb reverse tcp:18080 tcp:18080
11+
adb reverse tcp:28081 tcp:28081
12+
adb reverse tcp:60001 tcp:60001
13+
14+
set +e
15+
yarn test:mocha:android
16+
EXIT_CODE=$?
17+
set -e
18+
19+
echo $EXIT_CODE;
20+
if [ $EXIT_CODE -ne 0 ]; then
21+
adb root
22+
sleep 10
23+
adb pull /data/user/0/com.exmpl/files/ldk/ artifacts/
24+
fi
25+
26+
exit $EXIT_CODE

.github/workflows/mocha-ios.yml

+126
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
name: mocha-ios
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- 'master'
7+
push:
8+
branches:
9+
- 'master'
10+
11+
jobs:
12+
mocha-ios:
13+
runs-on: macos-12
14+
timeout-minutes: 120
15+
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v3
19+
with:
20+
fetch-depth: 1
21+
22+
- name: Setup Docker Colima 1
23+
uses: douglascamata/setup-docker-macos-action@v1-alpha
24+
id: docker1
25+
continue-on-error: true
26+
27+
- name: Setup Docker Colima 2
28+
if: steps.docker1.outcome != 'success'
29+
uses: douglascamata/setup-docker-macos-action@v1-alpha
30+
id: docker2
31+
continue-on-error: true
32+
33+
- name: Setup Docker Default
34+
if: steps.docker1.outcome != 'success' && steps.docker2.outcome != 'success'
35+
uses: docker-practice/actions-setup-docker@1.0.12
36+
timeout-minutes: 30
37+
38+
- name: Run regtest setup
39+
working-directory: example/docker
40+
run: |
41+
mkdir lnd
42+
mkdir clightning
43+
chmod 777 lnd clightning
44+
docker-compose up -d
45+
46+
- name: Wait for electrum server
47+
timeout-minutes: 2
48+
run: while ! nc -z '127.0.0.1' 60001; do sleep 1; done
49+
50+
- name: Node
51+
uses: actions/setup-node@v3
52+
with:
53+
node-version: 16
54+
cache: 'yarn' # cache packages, but not node_modules
55+
cache-dependency-path: 'example/yarn.lock'
56+
57+
- name: Cache lib node modules
58+
uses: actions/cache@v3
59+
id: lib-npmcache
60+
with:
61+
path: lib/node_modules
62+
key: node-modules-${{ hashFiles('**/yarn.lock') }}
63+
64+
- name: Install lib dependencies
65+
if: steps.lib-npmcache.outputs.cache-hit != 'true'
66+
working-directory: lib
67+
run: yarn --no-audit --prefer-offline || yarn --no-audit --prefer-offline
68+
69+
- name: Build lib
70+
working-directory: lib
71+
run: yarn build
72+
73+
- name: Cache app node modules
74+
uses: actions/cache@v3
75+
id: cache-nm
76+
with:
77+
path: example/node_modules
78+
key: node-modules-${{ hashFiles('**/yarn.lock') }}
79+
80+
- name: Rebuild detox
81+
if: steps.cache-nm.outputs.cache-hit == 'true'
82+
working-directory: example
83+
run: yarn detox clean-framework-cache && yarn detox build-framework-cache
84+
85+
- name: Install Dependencies
86+
if: steps.cache-nm.outputs.cache-hit != 'true'
87+
working-directory: example
88+
run: yarn install --no-audit --prefer-offline && yarn rn-setup
89+
90+
- name: Cache Pods
91+
uses: actions/cache@v3
92+
id: podcache
93+
with:
94+
path: example/ios/Pods
95+
key: pods-${{ hashFiles('**/Podfile.lock') }}
96+
97+
- name: Install pods
98+
working-directory: example
99+
run: |
100+
gem update cocoapods xcodeproj
101+
cd ios && pod install && cd ..
102+
103+
- name: Install applesimutils
104+
run: |
105+
brew tap wix/brew
106+
brew install applesimutils
107+
108+
- name: Build
109+
working-directory: example
110+
run: npx react-native run-ios --no-packager
111+
112+
- name: Test iOS app
113+
working-directory: example
114+
run: yarn test:mocha:ios
115+
116+
- name: Prepare articrafts
117+
if: failure()
118+
run: |
119+
mkdir articrafts
120+
find /Users/runner/Library/Developer/CoreSimulator/Devices/ -path '*Documents/ldk' -exec cp -r "{}" articrafts/ \;
121+
122+
- uses: actions/upload-artifact@v3
123+
if: failure()
124+
with:
125+
name: ldk-data
126+
path: articrafts

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
.idea/
22
**/.DS_Store
33
example/.watchman*
4+
5+
# docker
6+
example/docker/lnd/
7+
example/docker/clightning/

README.md

+49
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,61 @@ yarn android
4747
## Notes
4848
- It is important to not mix and match account names and seeds when starting LDK. Doing so can result in a corrupt save.
4949

50+
## Using zero conf channels
51+
Channels needs to be manually accepted but this is handled by channel-manager.ts if counterparty is in our trusted peer list.
52+
```javascript
53+
const userConfig: TUserConfig = {
54+
channel_handshake_config: {
55+
announced_channel: false,
56+
minimum_depth: 1,
57+
max_htlc_value_in_flight_percent_of_channel: 100,
58+
negotiate_anchors_zero_fee_htlc_tx: true, //Required for zero conf
59+
},
60+
manually_accept_inbound_channels: true, //Required for zero conf
61+
accept_inbound_channels: true,
62+
};
63+
```
64+
When starting LDK, provide a list of node public keys from which you are willing to accept zero-confirmation channels.
65+
66+
```javascript
67+
const lmStart = await lm.start(
68+
...
69+
trustedZeroConfPeers: ['03fc8877790430d7fb29e7bcf6b8bbfa3050e5e89189e27f97300e8a1e9ce589a3']
70+
```
71+
72+
From LND update your conf as specified [here](https://github.com/lightningnetwork/lnd/blob/master/docs/zero_conf_channels.md) and open with these params:
73+
`lncli openchannel --node_key=03c6b2081d6f333fe3a9655cdb864be7b6b46c8648188a44b6a412e41b63a43272 --local_amt=200000 --push_amt=50000 --private=true --zero_conf --channel_type=anchors`
74+
5075
## Upgrading LDK
5176
- Use latest LDK-release.aar from [ldk-garbagecollected](https://github.com/lightningdevkit/ldk-garbagecollected/releases) and place in `lib/android/libs`.
5277
- Use latest LDKFramework.xcframework from [ldk-swift](https://github.com/lightningdevkit/ldk-swift/releases) and place in lib/ios.
5378
- To get `pod install` working you might have to open the `LDKFramework.xcframework` directory, delete non ios frameworks and remove all references to deleted frameworks inside `LDKFramework.xcframework/Info.plist`.
5479
- Update Swift and Kotlin code if there are any breaking changes.
5580
81+
## Testing
82+
83+
Tests are implemented using [mocha-remote](https://github.com/kraenhansen/mocha-remote). To run tests at first you need to install docker and start tesing regtest enviroment using docker-compose:
84+
85+
```bash
86+
cd example
87+
docker-compose up
88+
```
89+
90+
Then to run tests open two terminals and execute the following commands:
91+
92+
```bash
93+
# Terminal 1
94+
cd example
95+
npm run start
96+
```
97+
98+
99+
```bash
100+
# Terminal 2
101+
cd example
102+
npm run test:mocha
103+
```
104+
56105
## How to test your code
57106
58107
Because it's a native module, you need to mock this package.

0 commit comments

Comments
 (0)