Skip to content

Commit 11271b8

Browse files
Merge pull request #26 from LtbLightning/v0.1.2-fixes
V0.1.2 fixes
2 parents 5061c9e + 2417479 commit 11271b8

28 files changed

+9411
-3482
lines changed

.githooks/pre-commit

Lines changed: 0 additions & 24 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
## [0.1.2]
22
#### APIs added
33
- Expose `generateEntropyMnemonic` function - a utility method for generating a BIP39 mnemonic.
4-
- Expose `Node` class's `updateChannelConfig` method.
4+
- Expose `Node` class's `updateChannelConfig`, `verifySignature`, `signMessage`, `sendPaymentProbe`, `sendSpontaneousPaymentProbe` methods.
55
- Add `ChannelConfig?` to node.connectOpenChannel() params - a `ChannelConfig` may now be specified on channel open or updated afterwards.
6-
- Expose `counterpartyNodeId` & `channelValueSats` in `ChannelDetails`.
7-
- Expose `trustedPeers0Conf` in `Config` - allowing inbound trusted 0conf channels.
6+
- Expose `counterpartyNodeId`, `funding_txo` & `channelValueSats` in `ChannelDetails`.
7+
- Expose `trustedPeers0Conf` `probingLiquidityLimitMultiplier`, `logDirPath`, `onchainWalletSyncInterval_secs`, `walletSyncIntervalSecs`, &
8+
`feeRateCacheUpdateIntervalSecs` in `Config` - allowing inbound trusted 0conf channels.
89
- Non-permanently connected peers are now included in node.listPeers().
910

1011
#### API changed

README.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,20 +57,22 @@ import 'package:ldk_node/ldk_node.dart';
5757
// ....
5858
5959
// Path to a directory where the application may place data that is user-generated
60-
final path = "${directory.path}alice's_node";
60+
final path = "${directory.path}/alice's_node";
6161
6262
// Your preferred `Esplora` url
6363
final esploraUrl = https://blockstream.info/testnet/api;
6464
6565
// configuration options for the node
6666
final config = Config(
67-
storageDirPath: nodePath,
68-
network: ldk.Network.regtest,
67+
probingLiquidityLimitMultiplier: 3,
68+
trustedPeers0Conf: [],
69+
storageDirPath: path,
70+
network: Network.Testnet,
6971
listeningAddress: NetAddress.iPv4(addr: "0.0.0.0", port: 3006),
70-
onchainWalletSyncIntervalSecs: 30,
71-
walletSyncIntervalSecs: 30,
72-
feeRateCacheUpdateIntervalSecs: 100,
73-
logLevel: ldk.LogLevel.info,
72+
onchainWalletSyncIntervalSecs: 60,
73+
walletSyncIntervalSecs: 20,
74+
feeRateCacheUpdateIntervalSecs: 600,
75+
logLevel: ldk.LogLevel.Debug,
7476
defaultCltvExpiryDelta: 144
7577
);
7678
Builder builder = Builder.fromConfig(config);
@@ -81,6 +83,7 @@ Builder builder = Builder.fromConfig(config);
8183
'certain sense kiss guide crumble hint transfer crime much stereo warm coral'))
8284
.setEsploraServer(
8385
esploraServerUrl: esploraUrl)
86+
.setEsploraServer(esploraServerUrl: esploraUrl)
8487
.build();
8588
8689
// Starting the node
472 KB
Binary file not shown.
396 KB
Binary file not shown.
349 KB
Binary file not shown.

example/ios/Podfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ EXTERNAL SOURCES:
2222
SPEC CHECKSUMS:
2323
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
2424
ldk_node: ab40477d6647d63d24fccd3431ccc7672bf79a25
25-
path_provider_foundation: eaf5b3e458fc0e5fbb9940fb09980e853fe058b8
25+
path_provider_foundation: 29f094ae23ebbca9d3d0cec13889cd9060c0e943
2626

2727
PODFILE CHECKSUM: ef19549a9bc3046e7bb7d2fab4d021637c0c58a3
2828

29-
COCOAPODS: 1.11.3
29+
COCOAPODS: 1.13.0

example/lib/main.dart

Lines changed: 35 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import 'dart:io';
2+
13
import 'package:flutter/foundation.dart';
24
import 'package:flutter/material.dart';
35
import 'package:google_fonts/google_fonts.dart';
@@ -23,9 +25,15 @@ class _MyAppState extends State<MyApp> {
2325
int aliceBalance = 0;
2426
String displayText = "";
2527
ldk.NetAddress? bobAddr;
26-
ldk.Invoice? invoice;
28+
ldk.Bolt11Invoice? invoice;
2729
ldk.ChannelId? channelId;
2830

31+
// Replace this with your local esplora url
32+
String esploraUrl = Platform.isAndroid
33+
?
34+
//10.0.2.2 to access the AVD
35+
'http://10.0.2.2:30000'
36+
: 'http://127.0.0.1:30000';
2937
@override
3038
void initState() {
3139
initAliceNode();
@@ -36,14 +44,15 @@ class _MyAppState extends State<MyApp> {
3644
final directory = await getApplicationDocumentsDirectory();
3745
final nodePath = "${directory.path}/ldk_cache/$path";
3846
final config = ldk.Config(
47+
probingLiquidityLimitMultiplier: 3,
3948
trustedPeers0Conf: [],
4049
storageDirPath: nodePath,
41-
network: ldk.Network.testnet,
50+
network: ldk.Network.Regtest,
4251
listeningAddress: address,
4352
onchainWalletSyncIntervalSecs: 60,
4453
walletSyncIntervalSecs: 20,
4554
feeRateCacheUpdateIntervalSecs: 600,
46-
logLevel: ldk.LogLevel.debug,
55+
logLevel: ldk.LogLevel.Debug,
4756
defaultCltvExpiryDelta: 144);
4857
return config;
4958
}
@@ -55,37 +64,41 @@ class _MyAppState extends State<MyApp> {
5564

5665
initAliceNode() async {
5766
final aliceConfig = await initLdkConfig(
58-
'alice', ldk.NetAddress.iPv4(addr: "0.0.0.0", port: 3006));
67+
'alice_regtest', ldk.NetAddress.iPv4(addr: "0.0.0.0", port: 3006));
5968
ldk.Builder aliceBuilder = ldk.Builder.fromConfig(config: aliceConfig);
6069
aliceNode = await aliceBuilder
6170
.setEntropyBip39Mnemonic(
6271
mnemonic: ldk.Mnemonic(
63-
internal:
64-
'cart super leaf clinic pistol plug replace close super tooth wealth usage'))
65-
.setEsploraServer(
66-
esploraServerUrl: 'https://blockstream.info/testnet/api')
72+
'cart super leaf clinic pistol plug replace close super tooth wealth usage'))
73+
.setEsploraServer(esploraServerUrl: esploraUrl)
6774
.build();
68-
await aliceNode.start();
75+
await startNode(aliceNode);
6976
final res = await aliceNode.nodeId();
7077
setState(() {
7178
aliceNodeId = res;
7279
displayText = "${aliceNodeId?.internal} started successfully";
7380
});
7481
}
7582

83+
startNode(ldk.Node node) async {
84+
try {
85+
node.start();
86+
} on ldk.NodeException catch (e) {
87+
print(e.toString());
88+
}
89+
}
90+
7691
initBobNode() async {
7792
final bobConfig = await initLdkConfig(
78-
"bob", ldk.NetAddress.iPv4(addr: "0.0.0.0", port: 3008));
93+
"bob_regtest", ldk.NetAddress.iPv4(addr: "0.0.0.0", port: 3008));
7994
ldk.Builder bobBuilder = ldk.Builder.fromConfig(config: bobConfig);
8095
bobNode = await bobBuilder
8196
.setEntropyBip39Mnemonic(
8297
mnemonic: ldk.Mnemonic(
83-
internal:
84-
'puppy interest whip tonight dad never sudden response push zone pig patch'))
85-
.setEsploraServer(
86-
esploraServerUrl: 'https://blockstream.info/testnet/api')
98+
'puppy interest whip tonight dad never sudden response push zone pig patch'))
99+
.setEsploraServer(esploraServerUrl: esploraUrl)
87100
.build();
88-
await bobNode.start();
101+
await startNode(bobNode);
89102
final res = await bobNode.nodeId();
90103
setState(() {
91104
bobNodeId = res;
@@ -129,9 +142,9 @@ class _MyAppState extends State<MyApp> {
129142
}
130143
}
131144

132-
Future<ldk.PaymentDetails?> listPaymentsWithFilter(bool printPayments) async {
145+
listPaymentsWithFilter(bool printPayments) async {
133146
final res = await aliceNode.listPaymentsWithFilter(
134-
paymentDirection: ldk.PaymentDirection.outbound);
147+
paymentDirection: ldk.PaymentDirection.Outbound);
135148
if (res.isNotEmpty) {
136149
if (printPayments) {
137150
if (kDebugMode) {
@@ -153,14 +166,10 @@ class _MyAppState extends State<MyApp> {
153166
removeLastPayment() async {
154167
final lastPayment = await listPaymentsWithFilter(false);
155168
if (lastPayment != null) {
156-
final res = await aliceNode.removePayment(paymentHash: lastPayment.hash);
157-
if (res) {
158-
setState(() {
159-
displayText = "${lastPayment.hash.internal} removed";
160-
});
161-
} else {
162-
displayText = "payment not found";
163-
}
169+
final _ = await aliceNode.removePayment(paymentHash: lastPayment.hash);
170+
setState(() {
171+
displayText = "${lastPayment.hash.internal} removed";
172+
});
164173
}
165174
}
166175

@@ -193,7 +202,7 @@ class _MyAppState extends State<MyApp> {
193202
await aliceNode.connectOpenChannel(
194203
channelAmountSats: 5000000,
195204
announceChannel: true,
196-
address: bobAddr!,
205+
netaddress: bobAddr!,
197206
pushToCounterpartyMsat: 50000,
198207
nodeId: bobNodeId!);
199208
}

0 commit comments

Comments
 (0)