Skip to content

Commit

Permalink
Merge pull request #46 from LtbLightning/upgrade-v0.3.0
Browse files Browse the repository at this point in the history
Upgrade v0.3.0
  • Loading branch information
BitcoinZavior authored Jul 8, 2024
2 parents a6b9be7 + 0fd8885 commit 85eac29
Show file tree
Hide file tree
Showing 55 changed files with 62,995 additions and 10,166 deletions.
26 changes: 7 additions & 19 deletions .github/workflows/precompile_binaries.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
on:
push:
branches: [v0.2.2-dev, main]
branches: [main, v0.3.0]

name: Precompile Binaries

jobs:
Precompile:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
fail-fast: true
matrix:
os:
- ubuntu-20.04
- macOS-latest
- windows-latest
os: [ubuntu-20.04, macOS-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
Expand All @@ -25,32 +22,23 @@ jobs:
run: |
mkdir -p .cargo
echo "[profile.release]" >> .cargo/config.toml
echo "opt-level = 'z'" >> .cargo/config.toml
echo "opt-level = 3" >> .cargo/config.toml
echo "lto = true" >> .cargo/config.toml
echo "codegen-units = 1" >> .cargo/config.toml
echo "panic = 'abort'" >> .cargo/config.toml
- uses: dart-lang/setup-dart@v1
- uses: subosito/flutter-action@v2
with:
channel: 'stable'
- name: Configure git with access token
run: |
git config --global url."https://x-access-token:${GITHUB_TOKEN}@github.com/".insteadOf "https://github.com/"
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.CARGOKIT_PRIVATE_KEY }}
- name: Install GTK
if: (matrix.os == 'ubuntu-20.04')
run: sudo apt-get update && sudo apt-get install libgtk-3-dev
- name: Precompile (with iOS)
if: (matrix.os == 'macOS-latest') || (matrix.os == 'windows-latest')
if: matrix.os == 'macOS-latest'
run: dart run build_tool precompile-binaries -v --manifest-dir=../../rust --repository=LtbLightning/ldk-node-flutter
working-directory: cargokit/build_tool
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
PRIVATE_KEY: ${{ secrets.CARGOKIT_PRIVATE_KEY }}
- name: Precompile (with Android)
if: (matrix.os == 'ubuntu-20.04')
if: matrix.os == 'ubuntu-20.04'
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
working-directory: cargokit/build_tool
env:
Expand Down
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
## [0.3.0]

## [0.2.2-dev]
Updated Rust and Flutter dependencies.
#### APIs added
Expand Down Expand Up @@ -117,4 +119,4 @@ This is the first release of `ldk_node`. It features support for sourcing chain

`stop`- Disconnects all peers, stops all running background tasks, and shuts down Node.

`syncWallets`- Sync the `LDK & BDK` wallets with the current chain state.
`syncWallets`- Sync the `LDK & BDK` wallets with the current chain state.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ To use the `ldk_node` package in your project, add it as a dependency in your pr

```dart
dependencies:
ldk_node: ^0.2.2-dev
ldk_node: ^0.3.0
```
or add from pub.dev using `pub add` command

```
flutter pub add ldk_node@0.2.2-dev
flutter pub add ldk_node
```

### Examples
Expand Down
75 changes: 75 additions & 0 deletions example/integration_test/bolt11_and_12_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
import 'package:ldk_node/ldk_node.dart' as ldk;
import 'package:path_provider/path_provider.dart';

void main() {
BigInt satsToMsats(int sats) => BigInt.from(sats * 1000);
String mSatsToSats(BigInt mSats) => '${mSats.toInt() ~/ 1000}sats';
IntegrationTestWidgetsFlutterBinding.ensureInitialized();

group('bolt11_&_bolt12', () {
setUp(() async {});
testWidgets('bolt11_full_cycle', (WidgetTester tester) async {
final directory = await getApplicationDocumentsDirectory();
final ldkCache = "${directory.path}/ldk_cache";
final aliceStoragePath = "$ldkCache/integration/alice";
debugPrint('Alice Storage Path: $aliceStoragePath');
final alice_builder = ldk.Builder.mutinynet()
.setEntropyBip39Mnemonic(
mnemonic: ldk.Mnemonic(
seedPhrase:
"replace force spring cruise nothing select glass erupt medal raise consider pull"))
.setStorageDirPath(aliceStoragePath);
final aliceNode = await alice_builder.build();
await aliceNode.start();
final bobStoragePath = "$ldkCache/integration/bob";
final bob_builder = ldk.Builder.mutinynet()
.setEntropyBip39Mnemonic(
mnemonic: ldk.Mnemonic(
seedPhrase:
"skin hospital fee risk health theory actor kiwi solution desert unhappy hello"))
.setStorageDirPath(bobStoragePath);
debugPrint('Bob Storage Path: $bobStoragePath');
final bobNode = await bob_builder.build();
await bobNode.start();
debugPrint("Manually syncing Alice's node");
await aliceNode.syncWallets();
debugPrint("Manually syncing Bob's node");
final aliceBalance =
(await aliceNode.listBalances()).spendableOnchainBalanceSats;
await bobNode.syncWallets();
expect(aliceBalance, 0);
debugPrint("Alice's onChain balance ${aliceBalance.toString()}");
final bobBalance =
(await bobNode.listBalances()).spendableOnchainBalanceSats;
debugPrint("Bob's onChain balance ${bobBalance.toString()}");

final bobBolt11PaymentHandler = await bobNode.bolt11Payment();
final bobJitInvoice = await bobBolt11PaymentHandler.receiveViaJitChannel(
amountMsat: satsToMsats(10000),
description: 'test',
expirySecs: 9000,
);
debugPrint("Bob's onChain balance ${bobBalance.toString()}");
final aliceBolt11PaymentHandler = await aliceNode.bolt11Payment();
final aliceJitInvoice =
await aliceBolt11PaymentHandler.receiveViaJitChannel(
amountMsat: satsToMsats(10000),
description: 'test',
expirySecs: 9000,
);
final aliceLBalance =
(await aliceNode.listBalances()).totalLightningBalanceSats;
debugPrint("Alice's Lightning balance ${aliceLBalance.toString()}");
final bobInvoice = await bobBolt11PaymentHandler.receive(
amountMsat: satsToMsats(10000),
description: 'test',
expirySecs: 9000);
final paymentId =
await aliceBolt11PaymentHandler.send(invoice: bobInvoice);
debugPrint("Alice's payment id ${paymentId.field0}");
});
});
}
74 changes: 74 additions & 0 deletions example/integration_test/bolt11_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
import 'package:ldk_node/ldk_node.dart' as ldk;
import 'package:path_provider/path_provider.dart';

void main() {
BigInt satsToMsats(int sats) => BigInt.from(sats * 1000);
IntegrationTestWidgetsFlutterBinding.ensureInitialized();

group('bolt11_integration', () {
setUp(() async {});
testWidgets('full_cycle', (WidgetTester tester) async {
final directory = await getApplicationDocumentsDirectory();
final ldkCache = "${directory.path}/ldk_cache";
final aliceStoragePath = "$ldkCache/integration/alice";
debugPrint('Alice Storage Path: $aliceStoragePath');
final alice_builder = ldk.Builder.mutinynet()
.setEntropyBip39Mnemonic(
mnemonic: ldk.Mnemonic(
seedPhrase:
"replace force spring cruise nothing select glass erupt medal raise consider pull"))
.setStorageDirPath(aliceStoragePath);
final aliceNode = await alice_builder.build();
await aliceNode.start();
final bobStoragePath = "$ldkCache/integration/bob";
final bob_builder = ldk.Builder.mutinynet()
.setEntropyBip39Mnemonic(
mnemonic: ldk.Mnemonic(
seedPhrase:
"skin hospital fee risk health theory actor kiwi solution desert unhappy hello"))
.setStorageDirPath(bobStoragePath);
debugPrint('Bob Storage Path: $bobStoragePath');
final bobNode = await bob_builder.build();
await bobNode.start();
debugPrint("Manually syncing Alice's node");
await aliceNode.syncWallets();
debugPrint("Manually syncing Bob's node");
final aliceBalance =
(await aliceNode.listBalances()).spendableOnchainBalanceSats;
await bobNode.syncWallets();
expect(aliceBalance, 0);
debugPrint("Alice's onChain balance ${aliceBalance.toString()}");
final bobBalance =
(await bobNode.listBalances()).spendableOnchainBalanceSats;
debugPrint("Bob's onChain balance ${bobBalance.toString()}");

final bobBolt11PaymentHandler = await bobNode.bolt11Payment();
final bobJitInvoice = await bobBolt11PaymentHandler.receiveViaJitChannel(
amountMsat: satsToMsats(10000),
description: 'test',
expirySecs: 9000,
);
debugPrint("Bob's onChain balance ${bobBalance.toString()}");
final aliceBolt11PaymentHandler = await aliceNode.bolt11Payment();
final aliceJitInvoice =
await aliceBolt11PaymentHandler.receiveViaJitChannel(
amountMsat: satsToMsats(10000),
description: 'test',
expirySecs: 9000,
);
final aliceLBalance =
(await aliceNode.listBalances()).totalLightningBalanceSats;
debugPrint("Alice's Lightning balance ${aliceLBalance.toString()}");
final bobInvoice = await bobBolt11PaymentHandler.receive(
amountMsat: satsToMsats(10000),
description: 'test',
expirySecs: 9000);
final paymentId =
await aliceBolt11PaymentHandler.send(invoice: bobInvoice);
debugPrint("Alice's payment id ${paymentId.field0}");
});
});
}
Loading

0 comments on commit 85eac29

Please sign in to comment.