Create Dart snippets and reference them

Co-Authored-By: ok300 <106775972+ok300@users.noreply.github.com>
This commit is contained in:
Erdem Yerebasmaz
2023-10-24 21:25:46 +03:00
parent c29cad2bd2
commit ec4955c488
35 changed files with 1039 additions and 272 deletions

View File

@@ -122,32 +122,7 @@ try {
<section>
```dart
// SDK events listener
breezEventsStream().listen((event) {
print("Received Breez event: $event");
}
// SDK logs listener
breezLogStream().listen((log) {
print("Received Breez log entry: $log");
}
// Create the default config
Uint8List seed = await mnemonicToSeed(phrase: "<mnemonic words>");
String inviteCode = "<invite code>";
String apiKey = "<api key>"
NodeConfg nodeConfig = NodeConfig.greenlight(config: GreenlightNodeConfig(partnerCredentials: null, inviteCode: inviteCode));
Config config = await defaultConfig(configType: EnvironmentType.Production, apiKey: apiKey, nodeConfig: nodeConfig);
// Customize the config object according to your needs
config.workingDir = "path to an existing directory";
try {
// Connect to the Breez SDK make it ready for use
await connect(config: config, seed: seed);
} catch (error) {
// handle error
}
{{#include ../../snippets/dart_snippets/lib/getting_started.dart:init-sdk}}
```
</section>
@@ -315,13 +290,7 @@ try {
<section>
```dart
try {
NodeState? nodeInfo = await nodeInfo();
int lnBalance = nodeInfo?.channelsBalanceMsat;
int onchainBalance = nodeInfo?.onchainBalanceMsat;
} catch (error) {
// handle error
}
{{#include ../../snippets/dart_snippets/lib/getting_started.dart:fetch-balance}}
```
</section>