add documentation for C#

This commit is contained in:
Jesse de Wit
2023-07-15 16:29:10 +02:00
parent 675a57ad5e
commit fd501e4407
10 changed files with 426 additions and 1 deletions

View File

@@ -271,6 +271,63 @@ if nodeInfo, err := sdkServices.NodeInfo(); err != nil {
lnBalance := nodeInfo.ChannelsBalanceMsat
onchainBalance := nodeInfo.OnchainBalanceMsat
}
```
</section>
<div slot="title">C#</div>
<section>
## Connecting
```cs
using Breez.Sdk;
// Create the default config
var seed = BreezSdkMethods.MnemonicToSeed("<mnemonics words>");
var inviteCode = "<invite code>";
var apiKey = "<api key>";
var nodeConfig = new NodeConfig.Greenlight(
new GreenlightNodeConfig(null, inviteCode)
);
var config = BreezSdkMethods.DefaultConfig(
EnvironmentType.PRODUCTION,
apiKey,
nodeConfig
) with {
// Customize the config object according to your needs
workingDir = "path to an existing directory"
};
BlockingBreezServices sdk;
try
{
// Connect to the Breez SDK make it ready for use
sdk = BreezSdkMethods.Connect(config, seed, new SdkListener());
} catch (Exception)
{
// Handle error
}
// SDK event listener
class SdkListener : EventListener
{
public void OnEvent(BreezEvent e)
{
Console.WriteLine($"Received Breez event type {e.GetType().Name}");
}
}
```
At any point we can fetch our balance from the Greenlight node:
```cs
try
{
var nodeInfo = sdk.NodeInfo();
var lnBalance = nodeInfo?.channelsBalanceMsat;
var onchainBalance = nodeInfo?.onchainBalanceMsat;
}
catch (Exception) {
// Handle error
}
```
</section>
</custom-tabs>