-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
69 changed files
with
8,043 additions
and
2,933 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: Delete old workflow runs | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
days: | ||
description: 'Number of days.' | ||
required: true | ||
default: '3' | ||
minimum_runs: | ||
description: 'The minimum runs to keep for each workflow.' | ||
required: true | ||
default: '5' | ||
|
||
jobs: | ||
del_runs: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Delete workflow runs | ||
uses: Mattraks/delete-workflow-runs@v2 | ||
with: | ||
token: ${{ github.token }} | ||
repository: ${{ github.repository }} | ||
retain_days: ${{ github.event.inputs.days }} | ||
keep_minimum_runs: ${{ github.event.inputs.minimum_runs }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
name: Build | ||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
push: | ||
branches: | ||
- 'build-*' | ||
tags: | ||
- 'nc-v*' | ||
|
||
env: | ||
GO_VERSION: 1.18.3 | ||
NDK_VERSION: 22.1.7171670 | ||
jobs: | ||
|
||
######################## | ||
# build mobile | ||
######################## | ||
lndmobile: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: git checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Cache docker | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
/tmp/.buildx-cache | ||
key: ${{ runner.os }}-buildx-${{ github.sha }} | ||
restore-keys: | | ||
${{ runner.os }}-buildx- | ||
- name: Cache golang | ||
uses: actions/cache@v3 | ||
with: | ||
path: /home/runner/work/go | ||
key: lnd-${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ github.job }}-${{ hashFiles('**/go.sum') }} | ||
restore-keys: | | ||
lnd-${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ github.job }}-${{ hashFiles('**/go.sum') }} | ||
lnd-${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ github.job }}- | ||
lnd-${{ runner.os }}-go-${{ env.GO_VERSION }}- | ||
lnd-${{ runner.os }}-go- | ||
- name: Setup Android SDK | ||
uses: android-actions/setup-android@v2 | ||
|
||
- name: Setup Android NDK | ||
run: | | ||
sdkmanager "ndk;${{ env.NDK_VERSION }}" | ||
- name: Setup go ${{ env.GO_VERSION }} | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: '${{ env.GO_VERSION }}' | ||
|
||
- name: Set up Docker Buildx | ||
id: buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Build | ||
run: | | ||
git config --global url."https://${{ secrets.AccessToken }}:x-oauth-basic@github.com/nayutaco/".insteadOf "https://github.com/nayutaco/" | ||
export ANDROID_NDK_HOME=$ANDROID_SDK_ROOT/ndk/${{ env.NDK_VERSION }} | ||
echo ANDROID_NDK_HOME=$ANDROID_NDK_HOME | ||
export GOPATH=~/go | ||
export GOPRIVATE="github.com/nayutaco" | ||
export PATH=$GOPATH/bin:$PATH | ||
mkdir -p $GOPATH/src/github.com/lightningnetwork/lnd | ||
mv ./* $GOPATH/src/github.com/lightningnetwork/lnd/ | ||
cd $GOPATH/src/github.com/lightningnetwork/lnd | ||
./mk-mobile.sh android | ||
- name: upload AAR | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: Lndmobile.aar | ||
path: ~/go/src/github.com/lightningnetwork/lnd/mobile/build/android/Lndmobile.aar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ name: Release build | |
on: | ||
push: | ||
tags: | ||
- 'v*' | ||
- 'zzzv*' | ||
|
||
defaults: | ||
run: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
servers*.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
@startuml CloseChecker | ||
|
||
participant NC2 | ||
participant Android | ||
participant CloseChecker | ||
participant ElectrumServer | ||
|
||
@enduml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# CloseChecker | ||
|
||
## Abstract | ||
|
||
モバイルアプリで Revoked Commitment Transaction によるクローズを検知したい。 | ||
Watchtower は個人レベルで運用することはできるが、会社として運用するには難しい。 | ||
LND が起動していない状態でチャネルクローズを検知できるように Electrum Server を使ってブロックチェーンを監視する。 | ||
|
||
## Electrum Server | ||
|
||
### Using method | ||
|
||
* ServerPeers | ||
* GetTransaction(verbose) | ||
* GetHistory | ||
|
||
GetHistory はアドレスから送金したトランザクションを取得するメソッドだが、Electrum Server API では直接アドレスを扱わず scriptHash を SHA256 した値を使っている。 | ||
|
||
### Find and connect Server | ||
|
||
`closechecker.getElectrumClient()` | ||
|
||
1. ハードコーディングしたElectrum Serverからランダムに1つ選ぶ | ||
2. 接続する | ||
a. 接続に失敗したら 1 に戻る(リトライは1〜3で30回まで) | ||
3. Server一覧を取得 | ||
a. エラーが発生したら 1 に戻る(リトライは1〜3で30回まで) | ||
4. ハードコーディングしたサーバと取得したサーバを合わせてランダムに1つ選ぶ | ||
a. 接続に失敗したら 4 に戻る(リトライは4〜5で30回まで) | ||
5. `GetTransaction()`を実施 | ||
a. エラーが発生したら 4 に戻る(リトライは4〜5で30回まで) | ||
6. 接続成功 | ||
|
||
* Memo | ||
* `GetTransaction()`をサポートしていないサーバがあったため確認している | ||
* onionノードは対応していないためリストから除外している | ||
|
||
### Hard coded Electrum Server list | ||
|
||
1. [Electrum](https://github.com/spesmilo/electrum/tree/master/electrum) からハードコーディングされた Electrum Server 一覧をダウンロードする。 | ||
* https://raw.githubusercontent.com/spesmilo/electrum/018a83078c93cfb5c14507d1bc62bd5baa2af825/electrum/servers.json | ||
* https://raw.githubusercontent.com/spesmilo/electrum/2af59e32b2c03961aa57d6d6872f6099ed8890f5/electrum/servers_testnet.json | ||
2. `conv.sh` を修正して実行する。 | ||
3. 出力されたファイルはまだ golang で使えるようになっていないので、手動で置き換える。 | ||
4. mainnet, testnet でそれぞれ配列を作り electrum-servers.go ファイルを更新する。 | ||
|
||
## Closed check | ||
|
||
LNDのバックエンドとしてNeutrinoを使っているため、ChannelPointがspentになっただけでは検知できない。チャネルを閉じたトランザクションがconfirmされる必要がある。 | ||
|
||
1. DBの先頭から順に取得する(key=チェックするchannelPoint, value=sighash) | ||
a. sighashが空欄の場合は計算してDBを更新する | ||
2. `GetHistory(sighash)`で送金されたTXID一覧を取得 | ||
3. TXID の Height が存在する場合 | ||
a. `GetTransaction(TXID)` | ||
b. トランザクションのVINが条件を満たすか確認 | ||
* VINの数は1つ | ||
* VINのTXIDがchannelPointのTXIDと一致する | ||
c. 一致する場合、そのチャネルは閉じられたと判断する |
Oops, something went wrong.