├── .github
└── workflows
│ └── precompile_binaries.yml
├── .gitignore
├── .metadata
├── CHANGELOG.md
├── LICENSE
├── LICENSE-APACHE
├── README.md
├── analysis_options.yaml
├── android
├── .gitignore
├── build.gradle
├── settings.gradle
└── src
│ └── main
│ └── AndroidManifest.xml
├── cargokit
├── .github
│ └── workflows
│ │ ├── check_and_lint.yml
│ │ └── test_example_plugin_build.yml
├── .gitignore
├── LICENSE
├── README
├── build_pod.sh
├── build_tool
│ ├── README.md
│ ├── analysis_options.yaml
│ ├── bin
│ │ └── build_tool.dart
│ ├── lib
│ │ ├── build_tool.dart
│ │ └── src
│ │ │ ├── android_environment.dart
│ │ │ ├── artifacts_provider.dart
│ │ │ ├── build_cmake.dart
│ │ │ ├── build_gradle.dart
│ │ │ ├── build_pod.dart
│ │ │ ├── build_tool.dart
│ │ │ ├── builder.dart
│ │ │ ├── cargo.dart
│ │ │ ├── crate_hash.dart
│ │ │ ├── environment.dart
│ │ │ ├── logging.dart
│ │ │ ├── options.dart
│ │ │ ├── precompile_binaries.dart
│ │ │ ├── rustup.dart
│ │ │ ├── target.dart
│ │ │ ├── util.dart
│ │ │ └── verify_binaries.dart
│ ├── pubspec.lock
│ ├── pubspec.yaml
│ └── test
│ │ ├── builder_test.dart
│ │ ├── cargo_test.dart
│ │ ├── options_test.dart
│ │ └── rustup_test.dart
├── cmake
│ ├── cargokit.cmake
│ └── resolve_symlinks.ps1
├── docs
│ ├── architecture.md
│ └── precompiled_binaries.md
├── gradle
│ └── plugin.gradle
├── run_build_tool.cmd
└── run_build_tool.sh
├── check_precompiled.sh
├── example
├── .gitignore
├── README.md
├── android
│ ├── .gitignore
│ ├── app
│ │ ├── build.gradle
│ │ └── src
│ │ │ ├── debug
│ │ │ └── AndroidManifest.xml
│ │ │ ├── main
│ │ │ ├── AndroidManifest.xml
│ │ │ ├── kotlin
│ │ │ │ └── io
│ │ │ │ │ └── ldk
│ │ │ │ │ └── f
│ │ │ │ │ └── ldk_node_example
│ │ │ │ │ └── MainActivity.kt
│ │ │ └── res
│ │ │ │ ├── drawable-v21
│ │ │ │ └── launch_background.xml
│ │ │ │ ├── drawable
│ │ │ │ └── launch_background.xml
│ │ │ │ ├── mipmap-hdpi
│ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-mdpi
│ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-xhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-xxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-xxxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ │ ├── values-night
│ │ │ │ └── styles.xml
│ │ │ │ └── values
│ │ │ │ └── styles.xml
│ │ │ └── profile
│ │ │ └── AndroidManifest.xml
│ ├── build.gradle
│ ├── gradle.properties
│ ├── gradle
│ │ └── wrapper
│ │ │ └── gradle-wrapper.properties
│ └── settings.gradle
├── cargokit_options.yaml
├── integration_test
│ ├── bolt11_test.dart
│ └── bolt12_test.dart
├── ios
│ ├── .gitignore
│ ├── Flutter
│ │ ├── AppFrameworkInfo.plist
│ │ ├── Debug.xcconfig
│ │ └── Release.xcconfig
│ ├── Podfile
│ ├── Podfile.lock
│ ├── Runner.xcodeproj
│ │ ├── project.pbxproj
│ │ ├── project.xcworkspace
│ │ │ ├── contents.xcworkspacedata
│ │ │ └── xcshareddata
│ │ │ │ ├── IDEWorkspaceChecks.plist
│ │ │ │ └── WorkspaceSettings.xcsettings
│ │ └── xcshareddata
│ │ │ └── xcschemes
│ │ │ ├── Runner.xcscheme
│ │ │ └── dev.xcscheme
│ ├── Runner.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcshareddata
│ │ │ ├── IDEWorkspaceChecks.plist
│ │ │ └── WorkspaceSettings.xcsettings
│ └── Runner
│ │ ├── AppDelegate.swift
│ │ ├── Assets.xcassets
│ │ ├── AppIcon.appiconset
│ │ │ ├── Contents.json
│ │ │ ├── Icon-App-1024x1024@1x.png
│ │ │ ├── Icon-App-20x20@1x.png
│ │ │ ├── Icon-App-20x20@2x.png
│ │ │ ├── Icon-App-20x20@3x.png
│ │ │ ├── Icon-App-29x29@1x.png
│ │ │ ├── Icon-App-29x29@2x.png
│ │ │ ├── Icon-App-29x29@3x.png
│ │ │ ├── Icon-App-40x40@1x.png
│ │ │ ├── Icon-App-40x40@2x.png
│ │ │ ├── Icon-App-40x40@3x.png
│ │ │ ├── Icon-App-60x60@2x.png
│ │ │ ├── Icon-App-60x60@3x.png
│ │ │ ├── Icon-App-76x76@1x.png
│ │ │ ├── Icon-App-76x76@2x.png
│ │ │ └── Icon-App-83.5x83.5@2x.png
│ │ └── LaunchImage.imageset
│ │ │ ├── Contents.json
│ │ │ ├── LaunchImage.png
│ │ │ ├── LaunchImage@2x.png
│ │ │ ├── LaunchImage@3x.png
│ │ │ └── README.md
│ │ ├── Base.lproj
│ │ ├── LaunchScreen.storyboard
│ │ └── Main.storyboard
│ │ ├── Info.plist
│ │ └── Runner-Bridging-Header.h
├── lib
│ └── main.dart
├── pubspec.lock
└── pubspec.yaml
├── flutter_rust_bridge.yaml
├── ios
├── .gitignore
├── Classes
│ ├── EnforceBundling.swift
│ ├── frb_generated.h
│ └── ldk_node.c
└── ldk_node.podspec
├── lefthook.yml
├── lib
├── ldk_node.dart
└── src
│ ├── generated
│ ├── api
│ │ ├── bolt11.dart
│ │ ├── bolt12.dart
│ │ ├── builder.dart
│ │ ├── graph.dart
│ │ ├── node.dart
│ │ ├── on_chain.dart
│ │ ├── spontaneous.dart
│ │ ├── types.dart
│ │ └── types.freezed.dart
│ ├── frb_generated.dart
│ ├── frb_generated.io.dart
│ ├── lib.dart
│ └── utils
│ │ ├── error.dart
│ │ └── error.freezed.dart
│ ├── root.dart
│ └── utils
│ ├── default_services.dart
│ ├── exceptions.dart
│ └── utils.dart
├── makefile
├── pubspec.yaml
└── rust
├── Cargo.lock
├── Cargo.toml
├── LICENSE-APACHE
├── LICENSE-MIT
├── LICENSE.md
├── cargokit.yaml
└── src
├── api
├── bolt11.rs
├── bolt12.rs
├── builder.rs
├── graph.rs
├── mod.rs
├── node.rs
├── on_chain.rs
├── spontaneous.rs
└── types.rs
├── frb_generated.io.rs
├── frb_generated.rs
├── lib.rs
└── utils
├── error.rs
└── mod.rs
/.github/workflows/precompile_binaries.yml:
--------------------------------------------------------------------------------
1 | on:
2 | push:
3 | branches: [main, v0.3.0]
4 |
5 | name: Precompile Binaries
6 |
7 | jobs:
8 | Precompile:
9 | strategy:
10 | fail-fast: true
11 | matrix:
12 | os: [ubuntu-20.04, macOS-latest]
13 | runs-on: ${{ matrix.os }}
14 | steps:
15 | - uses: actions/checkout@v4
16 | - uses: actions-rs/toolchain@v1
17 | with:
18 | profile: minimal
19 | toolchain: stable
20 | override: true
21 | - name: Configure Cargo.toml optimizations
22 | run: |
23 | mkdir -p .cargo
24 | echo "[profile.release]" >> .cargo/config.toml
25 | echo "opt-level = 3" >> .cargo/config.toml
26 | echo "lto = true" >> .cargo/config.toml
27 | echo "codegen-units = 1" >> .cargo/config.toml
28 | echo "panic = 'abort'" >> .cargo/config.toml
29 | - uses: dart-lang/setup-dart@v1
30 | - uses: subosito/flutter-action@v2
31 | with:
32 | channel: 'stable'
33 | - name: Precompile (with iOS)
34 | if: matrix.os == 'macOS-latest'
35 | run: dart run build_tool precompile-binaries -v --manifest-dir=../../rust --repository=LtbLightning/ldk-node-flutter
36 | working-directory: cargokit/build_tool
37 | env:
38 | GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
39 | PRIVATE_KEY: ${{ secrets.CARGOKIT_PRIVATE_KEY }}
40 | - name: Precompile (with Android)
41 | if: matrix.os == 'ubuntu-20.04'
42 | run: dart run build_tool precompile-binaries -v --manifest-dir=../../rust --repository=LtbLightning/ldk-node-flutter --android-sdk-location=/usr/local/lib/android/sdk --android-ndk-version=24.0.8215888 --android-min-sdk-version=23
43 | working-directory: cargokit/build_tool
44 | env:
45 | GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
46 | PRIVATE_KEY: ${{ secrets.CARGOKIT_PRIVATE_KEY }}
47 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Miscellaneous
2 | *.class
3 | *.log
4 | *.pyc
5 | *.swp
6 | .DS_Store
7 | .atom/
8 | .buildlog/
9 | .history
10 | .svn/
11 | migrate_working_dir/
12 |
13 | # IntelliJ related
14 | *.iml
15 | *.ipr
16 | *.iws
17 | .idea/
18 |
19 | # The .vscode folder contains launch configuration and tasks you configure in
20 | # VS Code which you may wish to be included in version control, so this line
21 | # is commented out by default.
22 | .vscode/
23 |
24 | # Flutter/Dart/Pub related
25 | # Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock.
26 | /pubspec.lock
27 | **/doc/api/
28 | .dart_tool/
29 | .packages
30 | build/
31 | rust/target/
32 | rust/wallets/
33 | rust/ldk.0.2.1/
34 |
--------------------------------------------------------------------------------
/.metadata:
--------------------------------------------------------------------------------
1 | # This file tracks properties of this Flutter project.
2 | # Used by Flutter tool to assess capabilities and perform upgrades etc.
3 | #
4 | # This file should be version controlled.
5 |
6 | version:
7 | revision: b8f7f1f9869bb2d116aa6a70dbeac61000b52849
8 | channel: stable
9 |
10 | project_type: plugin
11 |
12 | # Tracks metadata for the flutter migrate command
13 | migration:
14 | platforms:
15 | - platform: root
16 | create_revision: b8f7f1f9869bb2d116aa6a70dbeac61000b52849
17 | base_revision: b8f7f1f9869bb2d116aa6a70dbeac61000b52849
18 | - platform: android
19 | create_revision: b8f7f1f9869bb2d116aa6a70dbeac61000b52849
20 | base_revision: b8f7f1f9869bb2d116aa6a70dbeac61000b52849
21 | - platform: ios
22 | create_revision: b8f7f1f9869bb2d116aa6a70dbeac61000b52849
23 | base_revision: b8f7f1f9869bb2d116aa6a70dbeac61000b52849
24 |
25 | # User provided section
26 |
27 | # List of Local paths (relative to this file) that should be
28 | # ignored by the migrate tool.
29 | #
30 | # Files that are not part of the templates will be ignored by default.
31 | unmanaged_files:
32 | - 'lib/main.dart'
33 | - 'ios/Runner.xcodeproj/project.pbxproj'
34 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | ## [0.3.0]
2 | Updated `flutter_rust_bridge` to `2.0.0`.
3 | #### APIs added
4 | - `buildWithFsStore` method is added in the `Builder` class allowing to use the filesystem storage backend.
5 | - Exposed `setLiquiditySourceLsps2` method to `Builder` to configure the `Node` instance to source the inbound liquidity.
6 | - `nextEventAsync` method is added to `Node` class that allows polling the event queue asynchronously.
7 | - `status` method has been added to `Node` allowing to retrieve information about the Node's status.
8 | - `config` method added to get the config with which the `Node` was initialized.
9 | - The payment APIs have been restructured to use per-type (bolt11, onchain, bolt12) payment handlers which can be accessed via `node.{type}Payment`.
10 | - Support for sourcing inbound liquidity via LSPS2 just-in-time (JIT) channels has been added.
11 | - Support for creating and paying BOLT12 offers and refunds has been added.
12 | - Added `networkGraph` handler method allowing to query the network graph.
13 | - Added `forceCloseChannel` to `Node` class.
14 | #### API changed
15 | - All available balances outside of channel balances are now exposed via a unified `listBalances` interface method.
16 | #### Fixed
17 | Persisted peers are now correctly reconnected after startup.
18 |
19 | ## [0.2.2-dev]
20 | Updated Rust and Flutter dependencies.
21 | #### APIs added
22 | - Expose `isRunning()` in `Node` class.
23 | #### API changed
24 | - Renamed `waitUntilNextHandled()` to `waitNextHandled`.
25 | - Renamed `listeningAddress()` to `listeningAddresses`.
26 | - Upgraded `BuilderException` to handle invalid `socketAddress` & `trustedPeers.
27 | - Upgraded `NodeException` to handle invalid `txid`.
28 | #### Fixed
29 | - Functions hang indefinitely on iOs devices
30 | - Android support bug resolved
31 | - Thread `frb_workerpool` panic on `SocketAddress`, `PublicKey`, `Address` `Bolt11Invoice`, `Config` and `Txid`.
32 |
33 | ## [0.2.0]
34 | Updated `Rust` and `Flutter` dependencies.
35 |
36 | ## [0.1.3]
37 | Updated `Rust` and `Flutter` dependencies.
38 | Invalid `BuilderException` bug resolved
39 | #### APIs added
40 | - Expose `generate()` in `Mnemonic` class.
41 | #### API changed
42 | - Remove `generateEntropyMnemonic()`.
43 |
44 | ## [0.1.2]
45 | #### APIs added
46 | - Expose `generateEntropyMnemonic` function - a utility method for generating a BIP39 mnemonic.
47 | - Expose `Node` class's `updateChannelConfig`, `verifySignature`, `signMessage`, `sendPaymentProbe`, `sendSpontaneousPaymentProbe` methods.
48 | - Add `ChannelConfig?` to node.connectOpenChannel() params - a `ChannelConfig` may now be specified on channel open or updated afterwards.
49 | - Expose `counterpartyNodeId`, `funding_txo` & `channelValueSats` in `ChannelDetails`.
50 | - Expose `trustedPeers0Conf` `probingLiquidityLimitMultiplier`, `logDirPath`, `onchainWalletSyncInterval_secs`, `walletSyncIntervalSecs`, &
51 | `feeRateCacheUpdateIntervalSecs` in `Config` - allowing inbound trusted 0conf channels.
52 | - Non-permanently connected peers are now included in node.listPeers().
53 |
54 | #### API changed
55 | - node.newFundingAddress renamed to `newOnchainAddress`.
56 | - node.sendToOnChainAddress renamed to `sendToOnchainAddress`.
57 | - node.sendAllToOnChainAddress renamed to `sendAllToOnchainAddress`.
58 | - Remove node.onChainBalance.
59 |
60 | ## [0.1.1-alpha]
61 | Support `Dart 3` and `Flutter 3.10`
62 |
63 | ## [0.1.1]
64 | Support `Dart 3` and `Flutter 3.10`
65 |
66 | ### Fixed
67 | - `setEntropyBip39Mnemonic` issue resolved
68 | ## [0.1.0]
69 |
70 | This is the first release of `ldk_node`. It features support for sourcing chain data via an `Esplora` server, filesystem persistence, gossip sourcing via the `Lightning` peer-to-peer network, and configurble entropy sources for the integrated LDK & BDK-based wallets.
71 |
72 | ### Functionality Added
73 |
74 | `build`- Builds an `Node` instance according to the options previously configured.
75 |
76 | `fromConfig`- Creates a new `Builder` instance from an Config.
77 |
78 | `setEntropyBip39Mnemonic`- Configures the `Node` instance to source its wallet entropy from a BIP 39 mnemonic.
79 |
80 | `setEntropySeedBytes`- Configures the `Node` instance to source its wallet entropy from the given seed bytes.
81 |
82 | `setEntropySeedPath`- Configures the `Node` instance to source its wallet entropy from a seed file on disk.
83 |
84 | `setEsploraServerUrl`- Sets the `Esplora` server URL. Default: https://blockstream.info/api
85 |
86 | `setListeningAddress`- Sets the IP address and TCP port on which Node will listen for incoming network connections. Default: 0.0.0.0:9735
87 |
88 | `setNetwork`- Sets the `Bitcoin` network used.
89 |
90 | `setStorageDirPath`- Sets the used storage directory path.
91 |
92 | `closeChannel`- Close a previously opened channel.
93 |
94 | `connect`- Connect to a node on the peer-to-peer network. If permanently is set to true, we’ll remember the peer and reconnect to it on restart
95 |
96 | `connectOpenChannel`- Connect to a node and open a new channel. Disconnects and re-connects are handled automatically
97 |
98 | `disconnect`- Disconnects the peer with the given `node id`.
99 |
100 | `eventHandled`- Confirm the last retrieved event handled.
101 |
102 | `listChannels`- Retrieve a list of known channels.
103 |
104 | `listPaymentsWithFilter`- Retrieves all payments that match the given predicate.
105 |
106 | `listeningAddress`- Returns our own listening address.
107 |
108 | `newFundingAddress`- Retrieve a new on-chain/funding address.
109 |
110 | `nextEvent`- Blocks until the next event is available.
111 |
112 | `nodeId`- Returns our own `node id`.
113 |
114 | `onchainBalance`- Retrieve the current on-chain balance.
115 |
116 | `payment`- Retrieve the details of a specific payment with the given hash.
117 |
118 | `receivePayment`- Returns a payable invoice that can be used to request and receive a payment of the amount given.
119 |
120 | `receiveVariableAmountPayment`- Returns a payable invoice that can be used to request and receive a payment for which the amount is to be determined by the user,also known as a `zero-amount` invoice.
121 |
122 | `removePayment`- Remove the payment with the given hash from the store.
123 |
124 | `sendAllToOnchainAddress`- Send an on-chain payment to the given address, draining all the available funds.
125 |
126 | `sendPayment`- Send a payement given an invoice.
127 |
128 | `sendPaymentUsingAmount`- Send a payment given an invoice and an amount in millisatoshi.
129 |
130 | `sendSpontaneousPayment`- Send a spontaneous, aka. `keysend`, payment.
131 |
132 | `sendToOnchainAddress`- Send an on-chain payment to the given address.
133 |
134 | `start`- Starts the necessary background tasks, such as handling events coming from user input, `LDK/BDK`, and the peer-to-peer network.
135 |
136 | `stop`- Disconnects all peers, stops all running background tasks, and shuts down Node.
137 |
138 | `syncWallets`- Sync the `LDK & BDK` wallets with the current chain state.
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
2 |
3 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
4 |
5 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## LDK_Node
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 | A Flutter library for [LDK Node](https://github.com/lightningdevkit/ldk-node), a ready-to-go Lightning node library built using [LDK](https://lightningdevkit.org) and [BDK](https://bitcoindevkit.org).
28 |
29 | LDK Node is a non-custodial Lightning node. Its central goal is to provide a small, simple, and straightforward interface that enables users to easily set up and run a Lightning node with an integrated on-chain wallet. While minimalism is at its core, LDK Node aims to be sufficiently modular and configurable to be useful for a variety of use cases.
30 |
31 | The primary abstraction of the library is the Node, which can be retrieved by setting up and configuring a Builder to your liking and calling build(). Node can then be controlled via commands such as start, stop, connectOpenChannel, sendPayment, etc.:
32 |
33 | This release covers the same API from LDK Node 0.1.0 Rust. It has support for sourcing chain data via an Esplora server, filesystem persistence, gossip sourcing via the Lightning peer-to-peer network, and configurable entropy sources for the integrated LDK and BDK-based wallets.
34 |
35 | Please note: This release is considered experimental, and should not be run in production
36 | ### How to use ldk_node
37 |
38 | To use the `ldk_node` package in your project, add it as a dependency in your project's pubspec.yaml:
39 |
40 |
41 | ```dart
42 | dependencies:
43 | ldk_node: ^0.3.0
44 | ```
45 | or add from pub.dev using `pub add` command
46 |
47 | ```
48 | flutter pub add ldk_node
49 | ```
50 |
51 | ### Examples
52 |
53 | ### Build, Start & Sync the local node
54 |
55 | ```dart
56 | import 'package:ldk_node/ldk_node.dart';
57 |
58 | // ....
59 |
60 | // Path to a directory where the application may place data that is user-generated
61 | final path = "${directory.path}/alice's_node";
62 |
63 | // Your preferred `Esplora` url
64 | final esploraUrl = "https://mempool.space/testnet/api";
65 |
66 | // configuration options for the node
67 | final config = Config(
68 | probingLiquidityLimitMultiplier: 3,
69 | trustedPeers0Conf: [],
70 | storageDirPath: path,
71 | network: Network.Testnet,
72 | listeningAddresses: [
73 | SocketAddress.hostname(addr: "0.0.0.0", port: 3003)
74 | ],
75 | onchainWalletSyncIntervalSecs: 60,
76 | walletSyncIntervalSecs: 20,
77 | feeRateCacheUpdateIntervalSecs: 600,
78 | logLevel: ldk.LogLevel.Debug,
79 | defaultCltvExpiryDelta: 144
80 | );
81 | Builder builder = Builder.fromConfig(config);
82 | final node = await builder
83 | .setEntropyBip39Mnemonic(
84 | mnemonic: ldk.Mnemonic(
85 | 'certain sense kiss guide crumble hint transfer crime much stereo warm coral'))
86 | .setEsploraServer(esploraUrl)
87 | .build();
88 |
89 | // Starting the node
90 | await node.start();
91 |
92 | // Syncing the node
93 | await node.syncWallets();
94 |
95 | ```
96 |
97 | ### References:
98 | - Setting up a local Esplora instance for testing:
99 | https://bitcoin.stackexchange.com/questions/116937/how-do-i-setup-an-esplora-instance-for-local-testing/116938#116938
100 |
101 |
--------------------------------------------------------------------------------
/analysis_options.yaml:
--------------------------------------------------------------------------------
1 | include: package:lints/recommended.yaml
2 | linter:
3 | rules:
4 | prefer_single_quotes: false
5 | avoid_void_async: false
6 | prefer_interpolation_to_compose_strings: false
7 | avoid_print: false
8 | use_build_context_synchronously: false
9 | unnecessary_string_escapes: false
10 | avoid_dynamic_calls: false
11 | non_constant_identifier_names: false
12 |
13 | analyzer:
14 | exclude:
15 | - lib/src/generated/frb_generated.dart
16 | - lib/src/generated/frb_generated.io.dart
17 | - lib/src/generated/frb_generated.dart
18 | - lib/src/generated/api/types.freezed.dart
19 | - README.md
20 | - cargokit/
--------------------------------------------------------------------------------
/android/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .cxx
10 |
--------------------------------------------------------------------------------
/android/build.gradle:
--------------------------------------------------------------------------------
1 | group 'io.ldk.f.ldk_node'
2 | version '1.0-SNAPSHOT'
3 |
4 | buildscript {
5 | ext.kotlin_version = '1.6.10'
6 | repositories {
7 | google()
8 | mavenCentral()
9 | }
10 |
11 | dependencies {
12 | classpath 'com.android.tools.build:gradle:7.1.2'
13 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
14 | }
15 | }
16 |
17 | allprojects {
18 | repositories {
19 | google()
20 | mavenCentral()
21 | }
22 | }
23 |
24 | apply plugin: 'com.android.library'
25 | apply plugin: 'kotlin-android'
26 |
27 | android {
28 | compileSdkVersion 31
29 |
30 | compileOptions {
31 | sourceCompatibility JavaVersion.VERSION_1_8
32 | targetCompatibility JavaVersion.VERSION_1_8
33 | }
34 |
35 | kotlinOptions {
36 | jvmTarget = '1.8'
37 | }
38 |
39 | sourceSets {
40 | main.java.srcDirs += 'src/main/kotlin'
41 | }
42 |
43 | defaultConfig {
44 | minSdkVersion 16
45 | }
46 | }
47 | apply from: "../cargokit/gradle/plugin.gradle"
48 |
49 | cargokit {
50 | manifestDir = "../rust"
51 | libname = "ldk_node"
52 | }
--------------------------------------------------------------------------------
/android/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name = 'ldk_node'
2 |
--------------------------------------------------------------------------------
/android/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
--------------------------------------------------------------------------------
/cargokit/.github/workflows/check_and_lint.yml:
--------------------------------------------------------------------------------
1 | on:
2 | pull_request:
3 | push:
4 | branches:
5 | - main
6 |
7 | name: Check and Lint
8 |
9 | jobs:
10 | Flutter:
11 | runs-on: ubuntu-latest
12 | steps:
13 | - uses: actions/checkout@ee0669bd1cc54295c223e0bb666b733df41de1c5 #v2.7.0
14 | - uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d #1.6.0
15 | - name: Pub Get
16 | run: dart pub get --no-precompile
17 | working-directory: build_tool
18 | - name: Dart Format
19 | run: dart format . --output=none --set-exit-if-changed
20 | working-directory: build_tool
21 | - name: Analyze
22 | run: dart analyze
23 | working-directory: build_tool
24 | - name: Test
25 | run: dart test
26 | working-directory: build_tool
27 |
--------------------------------------------------------------------------------
/cargokit/.github/workflows/test_example_plugin_build.yml:
--------------------------------------------------------------------------------
1 | on:
2 | pull_request:
3 | push:
4 | branches:
5 | - main
6 |
7 | name: Test Example Plugin
8 |
9 | jobs:
10 | Build:
11 | runs-on: ${{ matrix.os }}
12 | strategy:
13 | fail-fast: false
14 | matrix:
15 | os:
16 | - ubuntu-latest
17 | - macOS-latest
18 | - windows-latest
19 | build_mode:
20 | - debug
21 | - profile
22 | - release
23 | env:
24 | EXAMPLE_DIR: "a b/hello_rust_ffi_plugin/example"
25 | CARGOKIT_VERBOSE: 1
26 | steps:
27 | - name: Extract branch name
28 | shell: bash
29 | run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
30 | id: extract_branch
31 | - name: Setup Repository
32 | shell: bash
33 | run: |
34 | mkdir "a b" # Space is intentional
35 | cd "a b"
36 | git config --global user.email "you@example.com"
37 | git config --global user.name "Your Name"
38 | # "advanced" branch has extra iOS flavor and uses rust nightly for release builds
39 | git clone -b advanced https://github.com/irondash/hello_rust_ffi_plugin
40 | cd hello_rust_ffi_plugin
41 | git subtree pull --prefix cargokit https://github.com/${{ github.event.pull_request.head.repo.full_name || github.repository }} ${{ steps.extract_branch.outputs.branch }} --squash
42 | - uses: subosito/flutter-action@cc97e1648fff6ca5cc647fa67f47e70f7895510b # 2.11.0
43 | with:
44 | channel: "stable"
45 | - name: Install GTK
46 | if: (matrix.os == 'ubuntu-latest')
47 | run: sudo apt-get update && sudo apt-get install libgtk-3-dev
48 | - name: Install ninja-build
49 | if: (matrix.os == 'ubuntu-latest')
50 | run: sudo apt-get update && sudo apt-get install ninja-build
51 | - name: Build Linux (${{ matrix.build_mode }})
52 | if: matrix.os == 'ubuntu-latest'
53 | shell: bash
54 | working-directory: ${{ env.EXAMPLE_DIR }}
55 | run: flutter build linux --${{ matrix.build_mode }} -v
56 | - name: Build macOS (${{ matrix.build_mode }})
57 | if: matrix.os == 'macos-latest'
58 | shell: bash
59 | working-directory: ${{ env.EXAMPLE_DIR }}
60 | run: flutter build macos --${{ matrix.build_mode }} -v
61 | - name: Build iOS (${{ matrix.build_mode }})
62 | if: matrix.os == 'macos-latest'
63 | shell: bash
64 | working-directory: ${{ env.EXAMPLE_DIR }}
65 | run: flutter build ios --${{ matrix.build_mode }} --no-codesign -v
66 | - name: Build iOS (${{ matrix.build_mode }}) - flavor1
67 | if: matrix.os == 'macos-latest'
68 | shell: bash
69 | working-directory: ${{ env.EXAMPLE_DIR }}
70 | run: flutter build ios --flavor flavor1 --${{ matrix.build_mode }} --no-codesign -v
71 | - name: Build Windows (${{ matrix.build_mode }})
72 | if: matrix.os == 'windows-latest'
73 | shell: bash
74 | working-directory: ${{ env.EXAMPLE_DIR }}
75 | run: flutter build windows --${{ matrix.build_mode }} -v
76 | - name: Build Android (${{ matrix.build_mode }})
77 | shell: bash
78 | working-directory: ${{ env.EXAMPLE_DIR }}
79 | run: |
80 | export JAVA_HOME=$JAVA_HOME_11_X64
81 | flutter build apk --${{ matrix.build_mode }} -v
82 |
83 |
--------------------------------------------------------------------------------
/cargokit/.gitignore:
--------------------------------------------------------------------------------
1 | target
2 | .dart_tool
3 | *.iml
4 | !pubspec.lock
5 |
--------------------------------------------------------------------------------
/cargokit/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright 2022 Matej Knopp
2 |
3 | ================================================================================
4 |
5 | MIT LICENSE
6 |
7 | Permission is hereby granted, free of charge, to any person obtaining a copy
8 | of this software and associated documentation files (the "Software"), to deal
9 | in the Software without restriction, including without limitation the rights
10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
11 | of the Software, and to permit persons to whom the Software is furnished to do
12 | so, subject to the following conditions:
13 |
14 | The above copyright notice and this permission notice shall be included in all
15 | copies or substantial portions of the Software.
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
19 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
20 | OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
22 | IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 |
24 | ================================================================================
25 |
26 | APACHE LICENSE, VERSION 2.0
27 |
28 | Licensed under the Apache License, Version 2.0 (the "License");
29 | you may not use this file except in compliance with the License.
30 | You may obtain a copy of the License at
31 |
32 | http://www.apache.org/licenses/LICENSE-2.0
33 |
34 | Unless required by applicable law or agreed to in writing, software
35 | distributed under the License is distributed on an "AS IS" BASIS,
36 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
37 | See the License for the specific language governing permissions and
38 | limitations under the License.
39 |
40 |
--------------------------------------------------------------------------------
/cargokit/README:
--------------------------------------------------------------------------------
1 | Experimental repository to provide glue for seamlessly integrating cargo build
2 | with flutter plugins and packages.
3 |
4 | See https://matejknopp.com/post/flutter_plugin_in_rust_with_no_prebuilt_binaries/
5 | for a tutorial on how to use Cargokit.
6 |
7 | Example plugin available at https://github.com/irondash/hello_rust_ffi_plugin.
8 |
9 |
--------------------------------------------------------------------------------
/cargokit/build_pod.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | set -e
3 |
4 | BASEDIR=$(dirname "$0")
5 |
6 | # Workaround for https://github.com/dart-lang/pub/issues/4010
7 | BASEDIR=$(cd "$BASEDIR" ; pwd -P)
8 |
9 | # Remove XCode SDK from path. Otherwise this breaks tool compilation when building iOS project
10 | NEW_PATH=`echo $PATH | tr ":" "\n" | grep -v "Contents/Developer/" | tr "\n" ":"`
11 |
12 | export PATH=${NEW_PATH%?} # remove trailing :
13 |
14 | env
15 |
16 | # Platform name (macosx, iphoneos, iphonesimulator)
17 | export CARGOKIT_DARWIN_PLATFORM_NAME=$PLATFORM_NAME
18 |
19 | # Arctive architectures (arm64, armv7, x86_64), space separated.
20 | export CARGOKIT_DARWIN_ARCHS=$ARCHS
21 |
22 | # Current build configuration (Debug, Release)
23 | export CARGOKIT_CONFIGURATION=$CONFIGURATION
24 |
25 | # Path to directory containing Cargo.toml.
26 | export CARGOKIT_MANIFEST_DIR=$PODS_TARGET_SRCROOT/$1
27 |
28 | # Temporary directory for build artifacts.
29 | export CARGOKIT_TARGET_TEMP_DIR=$TARGET_TEMP_DIR
30 |
31 | # Output directory for final artifacts.
32 | export CARGOKIT_OUTPUT_DIR=$PODS_CONFIGURATION_BUILD_DIR/$PRODUCT_NAME
33 |
34 | # Directory to store built tool artifacts.
35 | export CARGOKIT_TOOL_TEMP_DIR=$TARGET_TEMP_DIR/build_tool
36 |
37 | # Directory inside root project. Not necessarily the top level directory of root project.
38 | export CARGOKIT_ROOT_PROJECT_DIR=$SRCROOT
39 |
40 | FLUTTER_EXPORT_BUILD_ENVIRONMENT=(
41 | "$PODS_ROOT/../Flutter/ephemeral/flutter_export_environment.sh" # macOS
42 | "$PODS_ROOT/../Flutter/flutter_export_environment.sh" # iOS
43 | )
44 |
45 | for path in "${FLUTTER_EXPORT_BUILD_ENVIRONMENT[@]}"
46 | do
47 | if [[ -f "$path" ]]; then
48 | source "$path"
49 | fi
50 | done
51 |
52 | "$BASEDIR/run_build_tool.sh" build-pod "$@"
53 |
54 | # Make a symlink from built framework to phony file, which will be used as input to
55 | # build script. This should force rebuild (podspec currently doesn't support alwaysOutOfDate
56 | # attribute on custom build phase)
57 | ln -fs "$OBJROOT/XCBuildData/build.db" "${BUILT_PRODUCTS_DIR}/cargokit_phony"
58 | ln -fs "${BUILT_PRODUCTS_DIR}/${EXECUTABLE_PATH}" "${BUILT_PRODUCTS_DIR}/cargokit_phony_out"
59 |
--------------------------------------------------------------------------------
/cargokit/build_tool/README.md:
--------------------------------------------------------------------------------
1 | A sample command-line application with an entrypoint in `bin/`, library code
2 | in `lib/`, and example unit test in `test/`.
3 |
--------------------------------------------------------------------------------
/cargokit/build_tool/analysis_options.yaml:
--------------------------------------------------------------------------------
1 | # This file configures the static analysis results for your project (errors,
2 | # warnings, and lints).
3 | #
4 | # This enables the 'recommended' set of lints from `package:lints`.
5 | # This set helps identify many issues that may lead to problems when running
6 | # or consuming Dart code, and enforces writing Dart using a single, idiomatic
7 | # style and format.
8 | #
9 | # If you want a smaller set of lints you can change this to specify
10 | # 'package:lints/core.yaml'. These are just the most critical lints
11 | # (the recommended set includes the core lints).
12 | # The core lints are also what is used by pub.dev for scoring packages.
13 |
14 | include: package:lints/recommended.yaml
15 |
16 | # Uncomment the following section to specify additional rules.
17 |
18 | linter:
19 | rules:
20 | - prefer_relative_imports
21 | - directives_ordering
22 |
23 | # analyzer:
24 | # exclude:
25 | # - path/to/excluded/files/**
26 |
27 | # For more information about the core and recommended set of lints, see
28 | # https://dart.dev/go/core-lints
29 |
30 | # For additional information about configuring this file, see
31 | # https://dart.dev/guides/language/analysis-options
32 |
--------------------------------------------------------------------------------
/cargokit/build_tool/bin/build_tool.dart:
--------------------------------------------------------------------------------
1 | import 'package:build_tool/build_tool.dart' as build_tool;
2 |
3 | void main(List arguments) {
4 | build_tool.runMain(arguments);
5 | }
6 |
--------------------------------------------------------------------------------
/cargokit/build_tool/lib/build_tool.dart:
--------------------------------------------------------------------------------
1 | import 'src/build_tool.dart' as build_tool;
2 |
3 | Future runMain(List args) async {
4 | return build_tool.runMain(args);
5 | }
6 |
--------------------------------------------------------------------------------
/cargokit/build_tool/lib/src/android_environment.dart:
--------------------------------------------------------------------------------
1 | import 'dart:io';
2 | import 'dart:isolate';
3 | import 'dart:math' as math;
4 |
5 | import 'package:collection/collection.dart';
6 | import 'package:path/path.dart' as path;
7 | import 'package:version/version.dart';
8 |
9 | import 'target.dart';
10 | import 'util.dart';
11 |
12 | class AndroidEnvironment {
13 | AndroidEnvironment({
14 | required this.sdkPath,
15 | required this.ndkVersion,
16 | required this.minSdkVersion,
17 | required this.targetTempDir,
18 | required this.target,
19 | });
20 |
21 | static void clangLinkerWrapper(List args) {
22 | final clang = Platform.environment['_CARGOKIT_NDK_LINK_CLANG'];
23 | if (clang == null) {
24 | throw Exception(
25 | "cargo-ndk rustc linker: didn't find _CARGOKIT_NDK_LINK_CLANG env var");
26 | }
27 | final target = Platform.environment['_CARGOKIT_NDK_LINK_TARGET'];
28 | if (target == null) {
29 | throw Exception(
30 | "cargo-ndk rustc linker: didn't find _CARGOKIT_NDK_LINK_TARGET env var");
31 | }
32 |
33 | runCommand(clang, [
34 | target,
35 | ...args,
36 | ]);
37 | }
38 |
39 | /// Full path to Android SDK.
40 | final String sdkPath;
41 |
42 | /// Full version of Android NDK.
43 | final String ndkVersion;
44 |
45 | /// Minimum supported SDK version.
46 | final int minSdkVersion;
47 |
48 | /// Target directory for build artifacts.
49 | final String targetTempDir;
50 |
51 | /// Target being built.
52 | final Target target;
53 |
54 | bool ndkIsInstalled() {
55 | final ndkPath = path.join(sdkPath, 'ndk', ndkVersion);
56 | final ndkPackageXml = File(path.join(ndkPath, 'package.xml'));
57 | return ndkPackageXml.existsSync();
58 | }
59 |
60 | void installNdk({
61 | required String javaHome,
62 | }) {
63 | final sdkManagerExtension = Platform.isWindows ? '.bat' : '';
64 | final sdkManager = path.join(
65 | sdkPath,
66 | 'cmdline-tools',
67 | 'latest',
68 | 'bin',
69 | 'sdkmanager$sdkManagerExtension',
70 | );
71 |
72 | log.info('Installing NDK $ndkVersion');
73 | runCommand(sdkManager, [
74 | '--install',
75 | 'ndk;$ndkVersion',
76 | ], environment: {
77 | 'JAVA_HOME': javaHome,
78 | });
79 | }
80 |
81 | Future