Skip to content

Commit 280e1c4

Browse files
Merge pull request #56 from LtbLightning/upgrade-v7
Upgrade v7
2 parents 22eef0d + 5a312e2 commit 280e1c4

File tree

80 files changed

+28065
-46358
lines changed

Some content is hidden

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

80 files changed

+28065
-46358
lines changed

.fvmrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"flutter": "3.32.7"
3+
}

.github/workflows/precompile_binaries.yml

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,52 @@ jobs:
3030
- uses: subosito/flutter-action@v2
3131
with:
3232
channel: 'stable'
33+
architecture: x64
34+
- name: Set up Java
35+
if: (matrix.os == 'ubuntu-latest')
36+
uses: actions/setup-java@v4
37+
with:
38+
distribution: 'temurin'
39+
java-version: '17'
3340
- name: Set up Android SDK
3441
if: (matrix.os == 'ubuntu-latest')
3542
uses: android-actions/setup-android@v2
3643
- name: Install Specific NDK
3744
if: (matrix.os == 'ubuntu-latest')
38-
run: sdkmanager --install "ndk;25.1.8937393"
45+
run: sdkmanager --install "ndk;25.1.8937393"
46+
- name: Install bindgen-cli
47+
run: cargo install --force --locked bindgen-cli
48+
- name: Set iOS SDK environment
49+
if: matrix.os == 'macOS-latest'
50+
run: |
51+
IPHONEOS_SDK=$(xcrun --sdk iphoneos --show-sdk-path)
52+
IPHONESIMULATOR_SDK=$(xcrun --sdk iphonesimulator --show-sdk-path)
53+
echo "IPHONEOS_SDK=$IPHONEOS_SDK" >> $GITHUB_ENV
54+
echo "IPHONESIMULATOR_SDK=$IPHONESIMULATOR_SDK" >> $GITHUB_ENV
3955
- name: Precompile (with iOS)
4056
if: matrix.os == 'macOS-latest'
4157
run: dart run build_tool precompile-binaries -v --manifest-dir=../../rust --repository=LtbLightning/ldk-node-flutter
4258
working-directory: cargokit/build_tool
4359
env:
4460
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
4561
PRIVATE_KEY: ${{ secrets.CARGOKIT_PRIVATE_KEY }}
62+
BINDGEN_EXTRA_CLANG_ARGS: "--sysroot=${{ env.IPHONEOS_SDK }} -I${{ env.IPHONEOS_SDK }}/usr/include"
63+
CFLAGS: "--sysroot=${{ env.IPHONEOS_SDK }}"
64+
- name: Set Android NDK environment
65+
if: matrix.os == 'ubuntu-latest'
66+
run: |
67+
NDK_HOME=/usr/local/lib/android/sdk/ndk/25.1.8937393
68+
SYSROOT=$NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/sysroot
69+
echo "ANDROID_NDK_HOME=$NDK_HOME" >> $GITHUB_ENV
70+
echo "ANDROID_NDK_SYSROOT=$SYSROOT" >> $GITHUB_ENV
4671
- name: Precompile (with Android)
4772
if: matrix.os == 'ubuntu-latest'
4873
run: dart run build_tool precompile-binaries -v --target=aarch64-linux-android,armv7-linux-androideabi,x86_64-linux-android --manifest-dir=../../rust --repository=LtbLightning/ldk-node-flutter --android-sdk-location=/usr/local/lib/android/sdk --android-ndk-version=25.1.8937393 --android-min-sdk-version=23
4974
working-directory: cargokit/build_tool
5075
env:
5176
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
5277
PRIVATE_KEY: ${{ secrets.CARGOKIT_PRIVATE_KEY }}
78+
BINDGEN_EXTRA_CLANG_ARGS_aarch64_linux_android: "--sysroot=${{ env.ANDROID_NDK_SYSROOT }} -I${{ env.ANDROID_NDK_SYSROOT }}/usr/include -I${{ env.ANDROID_NDK_SYSROOT }}/usr/include/aarch64-linux-android"
79+
BINDGEN_EXTRA_CLANG_ARGS_armv7_linux_androideabi: "--sysroot=${{ env.ANDROID_NDK_SYSROOT }} -I${{ env.ANDROID_NDK_SYSROOT }}/usr/include -I${{ env.ANDROID_NDK_SYSROOT }}/usr/include/arm-linux-androideabi"
80+
BINDGEN_EXTRA_CLANG_ARGS_x86_64_linux_android: "--sysroot=${{ env.ANDROID_NDK_SYSROOT }} -I${{ env.ANDROID_NDK_SYSROOT }}/usr/include -I${{ env.ANDROID_NDK_SYSROOT }}/usr/include/x86_64-linux-android"
81+
CFLAGS: "--sysroot=${{ env.ANDROID_NDK_SYSROOT }}"

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ migrate_working_dir/
2020
# VS Code which you may wish to be included in version control, so this line
2121
# is commented out by default.
2222
.vscode/
23+
temp/
2324

2425
# Flutter/Dart/Pub related
2526
# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock.
@@ -31,3 +32,7 @@ build/
3132
rust/target/
3233
rust/wallets/
3334
rust/ldk.0.2.1/
35+
reference/
36+
37+
# FVM Version Cache
38+
.fvm/

CHANGELOG.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,90 @@
1+
## [0.7.0]
2+
Updated `ldk-node` to `0.7.0`.
3+
4+
### APIs added
5+
6+
- **Channel Splicing**: Experimental support for channel splicing via `spliceIn()` and `spliceOut()` methods
7+
- **Async Payments**: Static invoice support with `receiveStaticInvoice()` and `sendStaticInvoice()` methods
8+
- **Bitcoin Core REST**: New chain data source via `ChainDataSourceConfig.bitcoindRest()`
9+
- **Esplora with Headers**: `ChainDataSourceConfig.esploraWithHeaders()` for custom HTTP headers
10+
- **Pathfinding Scores**: `importPathfindingScores()` and `mergePathfindingScores()` methods
11+
- **Custom Preimage**: `sendWithPreimage()` for spontaneous payments with custom preimage
12+
- **Route Parameters**: `RouteParametersConfig` support for BOLT12 payments and refunds
13+
- **Mnemonic Word Count**: `Mnemonic.generateWithWordCount()` for configurable entropy
14+
15+
### Notes
16+
- Splicing-related transactions may still get misclassified in the payment store
17+
- Liquidity service data is now persisted across restarts
18+
- Improved shutdown robustness and reduced IO load via differential channel monitor updates
19+
20+
## [0.6.2]
21+
Updated `ldk-node` to `0.6.2`.
22+
23+
### Notes
24+
- No breaking changes and no new functions exposed.
25+
- Bug fixes.
26+
- Fix node going into a unrecoverable state when previously generated transaction accepted first, fixed on `rust bdk_wallet 2.0.0`
27+
- refer to [ldk-node rust](https://github.com/lightningdevkit/ldk-node/releases) for misc fixes (rust, uniffi, etc).
28+
29+
30+
## [0.5.0]
31+
32+
Updated `flutter_rust_bridge` to `2.11.1`.
33+
Updated `ldk-node` to `0.5.0`.
34+
Updated `freezed` to `3.2.0`
35+
Updated `freezed-anotation` to `3.1.0`
36+
37+
### APIs added
38+
39+
- **FeeRate Class**: Added comprehensive Dart-native `FeeRate` class with utilities for fee rate conversion and common constants
40+
- Constants: `zero`, `min`, `max`, `broadcastMin`, `dust`
41+
- Constructors: `fromSatPerKwu()`, `fromSatPerVb()`, `fromSatPerVbUnchecked()`
42+
- Converters: `toSatPerVbFloor()`, `toSatPerVbCeil()`, `toSatPerKwu()`
43+
- Enhanced `OnChainPayment` methods to support `FeeRate` parameter
44+
45+
- **Chain Data Sources**: Added Electrum backend support as alternative to Esplora for chain and fee rate data
46+
- `ChainDataSourceConfig.electrum()` constructor with `ElectrumSyncConfig` support
47+
- Full FFI integration for Electrum chain data source configuration
48+
- Background sync configuration options with customizable sync intervals
49+
50+
- **Enhanced Payment Events**:
51+
- Added `payment_preimage` field to `PaymentSuccessful` events for better payment verification and tracking
52+
- Added `PaymentForwarded` events for tracking payment forwarding through the node with detailed fee and routing information
53+
- Custom TLV (Type-Length-Value) record support in payment events (`PaymentClaimable`, `PaymentReceived`) allowing additional metadata to be received with payments
54+
55+
- **LSP Integration**: Enhanced Lightning Service Provider support
56+
- LSPS2 service integration with `receiveViaJitChannel()` and `receiveVariableAmountViaJitChannel()` methods
57+
- `Bolt11Jit` payment variant with LSP fee limits and counterparty skimmed fee tracking
58+
- Enhanced JIT channel support for improved liquidity management
59+
60+
- **Payment Store Integration**: On-chain transactions now included in internal payment store and exposed via payment APIs
61+
62+
### Breaking Changes
63+
64+
- **flutter_rust_bridge**: Updated from `2.6.0` to `2.11.1` - this major update may require code changes in applications using low-level FFI bindings
65+
- **freezed**: Updated from previous version to `3.2.0` - may affect generated code and require regeneration of freezed classes
66+
- **ldk-node**: Updated to `0.5.0` with significant internal changes that may affect behavior in edge cases
67+
- **Event Structure Changes**: Payment events now include additional fields (`preimage`, `customRecords`) which may affect existing event handling code
68+
- **Chain Data Source Configuration**: Applications using manual chain source configuration may need to update to new `ChainDataSourceConfig.electrum()` syntax
69+
70+
### API changed
71+
72+
- Enhanced on-chain payment methods to optionally accept `FeeRate` parameters for custom fee control
73+
- `ChainDataSourceConfig` now supports Electrum as a chain data source option alongside Esplora and Bitcoin Core RPC via `ChainDataSourceConfig.electrum()`
74+
- Payment events enhanced with preimage information in `PaymentSuccessful` events for better payment tracking and verification
75+
- Payment events (`PaymentClaimable`, `PaymentReceived`) now include `customRecords` field for Custom TLV record support
76+
- Added `PaymentForwarded` event type for tracking payment forwarding through the node
77+
78+
### Fixed
79+
80+
- Resolved FeeRate FFI type conflicts by implementing native Dart solution
81+
- Improved type safety and developer experience for fee rate handling
82+
- Enhanced payment tracking with better event handling and preimage support
83+
84+
### Notes
85+
86+
- Custom TLV support is available for receiving payments via event `customRecords`, but `sendWithCustomTlvs` for spontaneous payments is not yet exposed in the public API
87+
188
## [0.4.3]
289

390
Updated `flutter_rust_bridge` to `2.6.0`.

README.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,28 @@ A Flutter library for [LDK Node](https://github.com/lightningdevkit/ldk-node), a
2828

2929
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.
3030

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.:
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, openChannel, sendPayment, etc.
3232

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.
33+
This release covers the API from LDK Node 0.7.0 Rust. It has support for sourcing chain data via Esplora, Electrum, or Bitcoin Core RPC/REST backends, filesystem persistence, gossip sourcing via the Lightning peer-to-peer network, and configurable entropy sources for the integrated LDK and BDK-based wallets.
3434

35-
Please note: This release is considered experimental, and should not be run in production
35+
### Key Features
36+
37+
- **Multiple Chain Data Sources**: Esplora, Electrum, and Bitcoin Core (RPC & REST) backends
38+
- **Channel Splicing**: Experimental support via `spliceIn()` and `spliceOut()` methods
39+
- **Async Payments**: Static invoice support with `receiveStaticInvoice()` and `sendStaticInvoice()`
40+
- **BOLT11 & BOLT12**: Full support for Lightning invoices, offers, and refunds
41+
- **LSP Integration**: LSPS2 just-in-time (JIT) channel support for inbound liquidity
42+
- **Unified QR Payments**: Generate and pay unified QR codes
43+
- **Custom Fee Rates**: Comprehensive `FeeRate` class for fine-grained fee control
44+
- **Pathfinding Scores**: Import and merge pathfinding scores for optimized routing
3645
### How to use ldk_node
3746

3847
To use the `ldk_node` package in your project, add it as a dependency in your project's pubspec.yaml:
3948

4049

4150
```dart
4251
dependencies:
43-
ldk_node: ^0.4.2
52+
ldk_node: ^0.7.0
4453
```
4554
or add from pub.dev using `pub add` command
4655

cargokit/gradle/plugin.gradle

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class CargoKitPlugin implements Plugin<Project> {
8686
private Plugin _findFlutterPlugin(Map projects) {
8787
for (project in projects) {
8888
for (plugin in project.value.getPlugins()) {
89-
if (plugin.class.name == "FlutterPlugin") {
89+
if (plugin.class.name == "com.flutter.gradle.FlutterPlugin") {
9090
return plugin;
9191
}
9292
}
@@ -119,12 +119,29 @@ class CargoKitPlugin implements Plugin<Project> {
119119
def jniLibs = project.android.sourceSets.maybeCreate(buildType).jniLibs;
120120
jniLibs.srcDir(new File(cargoOutputDir))
121121

122-
def platforms = plugin.getTargetPlatforms().collect()
122+
def platforms = ["android-arm", "android-arm64", "android-x64"]
123+
124+
// Respect NDK ABI filters if set
125+
def abiFilters = plugin.project.android.defaultConfig.ndk?.abiFilters
126+
if (abiFilters != null && !abiFilters.isEmpty()) {
127+
// Filter platforms based on ABI filters
128+
platforms = platforms.findAll { platform ->
129+
if (platform == "android-arm" && abiFilters.contains("armeabi-v7a")) return true
130+
if (platform == "android-arm64" && abiFilters.contains("arm64-v8a")) return true
131+
// if (platform == "android-x86" && abiFilters.contains("x86")) return true
132+
if (platform == "android-x64" && abiFilters.contains("x86_64")) return true
133+
return false
134+
}
135+
}
123136

124137
// Same thing addFlutterDependencies does in flutter.gradle
125138
if (buildType == "debug") {
126-
// platforms.add("android-x86")
127-
platforms.add("android-x64")
139+
// Only add x64 if it's in ABI filters or no filters are set
140+
if (abiFilters == null || abiFilters.isEmpty() || abiFilters.contains("x86_64")) {
141+
if (!platforms.contains("android-x64")) {
142+
platforms.add("android-x64")
143+
}
144+
}
128145
}
129146

130147
// The task name depends on plugin properties, which are not available

example/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,4 @@ app.*.map.json
4444
/android/app/debug
4545
/android/app/profile
4646
/android/app/release
47+
/android/app/.cxx/

example/README_CONFIGURATION.md

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# Lightning Wallet Configuration System
2+
3+
This app now supports user-configurable node settings with persistent storage.
4+
5+
## Features
6+
7+
### 🔐 **User-Generated Mnemonics**
8+
- Users can generate their own secure mnemonics
9+
- Mnemonics are stored securely using SharedPreferences
10+
- Option to generate new mnemonics (creates new wallet)
11+
12+
### 🏷️ **Custom Node Names**
13+
- Users can set their own node name
14+
- Node name is displayed in the app title
15+
- Stored persistently for future sessions
16+
17+
### 🔌 **Configurable Ports**
18+
- Users can choose from available ports (9735-9740)
19+
- Prevents port conflicts when running multiple emulators
20+
- Port selection is stored and remembered
21+
22+
### 💾 **Persistent Storage**
23+
- All settings are saved using SharedPreferences
24+
- Settings persist across app restarts
25+
- No hardcoded values for production use
26+
27+
## First Run Experience
28+
29+
When users first launch the app, they'll see a beautiful onboarding flow:
30+
31+
1. **Step 1: Generate Mnemonic**
32+
- Tap "Generate Mnemonic" to create a new wallet
33+
- Copy the mnemonic to clipboard
34+
- Warning about keeping it safe
35+
36+
2. **Step 2: Set Node Name**
37+
- Enter a custom node name
38+
- This will be visible to other Lightning Network participants
39+
40+
3. **Step 3: Choose Port**
41+
- Select from available ports (9735-9740)
42+
- Different ports allow multiple emulators on same machine
43+
44+
## Settings Management
45+
46+
Users can access settings via the settings icon in the app bar:
47+
48+
- **View Current Settings**: See current mnemonic, node name, and port
49+
- **Update Settings**: Change node name or port
50+
- **Generate New Mnemonic**: Create a new wallet (warning about data loss)
51+
- **Copy Mnemonic**: Copy current mnemonic to clipboard
52+
53+
## Multiple Emulator Support
54+
55+
To run multiple emulators on the same machine:
56+
57+
1. **First Emulator**: Use default settings (port 9735)
58+
2. **Second Emulator**: Go to Settings → Change Port to 9736
59+
3. **Additional Emulators**: Use ports 9737, 9738, etc.
60+
61+
Each emulator will have its own:
62+
- Unique port
63+
- Separate storage directory
64+
- Independent wallet
65+
66+
## Technical Implementation
67+
68+
### Files Created/Modified:
69+
70+
- `lib/services/settings_service.dart` - Persistent storage service
71+
- `lib/screens/onboarding_screen.dart` - First-run setup flow
72+
- `lib/screens/settings_screen.dart` - Settings management UI
73+
- `lib/config/node_config.dart` - Updated to use user settings
74+
- `lib/main.dart` - Added startup flow and routing
75+
- `lib/screens/dashboard_screen.dart` - Added settings button
76+
77+
### Dependencies:
78+
- `shared_preferences: ^2.2.3` - For persistent storage
79+
- `google_fonts: ^6.2.1` - For beautiful typography
80+
- `qr_flutter: ^4.1.0` - For QR code display
81+
82+
## Security Notes
83+
84+
- Mnemonics are stored in SharedPreferences (device storage)
85+
- Consider implementing encryption for production use
86+
- Users are warned about keeping mnemonics safe
87+
- Option to generate new mnemonics creates completely new wallets
88+
89+
## Testing Multiple Emulators
90+
91+
1. Start first emulator with default settings
92+
2. Start second emulator and go through onboarding
93+
3. Choose different port (e.g., 9736)
94+
4. Both emulators can run simultaneously without conflicts
95+
5. Each has its own wallet and can connect to each other
96+
97+
## Future Enhancements
98+
99+
- [ ] Encrypt stored mnemonics
100+
- [ ] Add mnemonic validation
101+
- [ ] Support for custom port ranges
102+
- [ ] Backup/restore settings
103+
- [ ] Import existing mnemonics

example/android/app/build.gradle

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ plugins {
88

99
android {
1010
compileSdk = flutter.compileSdkVersion
11-
ndkVersion = "25.1.8937393"
11+
ndkVersion = "26.3.11579264"
1212
namespace = "io.ldk.f.ldk_node_example"
1313
compileOptions {
1414
sourceCompatibility JavaVersion.VERSION_17
@@ -28,6 +28,11 @@ android {
2828
targetSdk = flutter.targetSdkVersion
2929
versionCode = flutter.versionCode
3030
versionName = flutter.versionName
31+
32+
ndk {
33+
// Filter out 32-bit architectures to avoid lightning crate compilation issues
34+
abiFilters 'arm64-v8a', 'x86_64'
35+
}
3136
}
3237

3338
buildTypes {

example/cargokit_options.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
verbose_logging: false
2-
use_precompiled_binaries: true
1+
verbose_logging: true
2+
use_precompiled_binaries: false

0 commit comments

Comments
 (0)