mirror of
https://github.com/aljazceru/breez-sdk-docs.git
synced 2025-12-18 14:24:19 +01:00
add go example connect to lps
This commit is contained in:
@@ -58,7 +58,7 @@ Based on the API key provided to the Breez SDK, a default LSP is selected for yo
|
||||
|
||||
```python
|
||||
try:
|
||||
lsp_id = self.sdk_services.lsp_id()
|
||||
lsp_id = sdk_services.lsp_id()
|
||||
lsp_info = sdk_services.fetch_lsp_info(lsp_id)
|
||||
|
||||
except Exception as error:
|
||||
@@ -75,4 +75,31 @@ except Exception as error:
|
||||
```
|
||||
|
||||
</section>
|
||||
<div slot="title">Go</div>
|
||||
<section>
|
||||
|
||||
Based on the API key provided to the Breez SDK, a default LSP is selected for your node to provide liquidity to it. To get the information about the selected LSP you can do the following:
|
||||
|
||||
|
||||
```go
|
||||
lspId, err := sdkServices.LspId()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
}
|
||||
lspInfo, err := sdkServices.FetchLspInfo(*lspId)
|
||||
if err != nil {
|
||||
// Handle error
|
||||
}
|
||||
```
|
||||
|
||||
When you have selected an LSP you may then connect to it.
|
||||
|
||||
```go
|
||||
err = sdkServices.ConnectLsp(*lspId)
|
||||
if err != nil {
|
||||
// Handle error
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
</custom-tabs>
|
||||
@@ -236,6 +236,11 @@ func (BreezListener) OnEvent(e breez_sdk.BreezEvent) {
|
||||
}
|
||||
|
||||
// Create the default config
|
||||
seed, err := breez_sdk.MnemonicToSeed("<mnemonics words>")
|
||||
if err != nil {
|
||||
log.Fatalf("MnemonicToSeed failed: %#v", err)
|
||||
}
|
||||
|
||||
apiKey := "<your breez api key>"
|
||||
inviteCode := "<your greenlight invite code>"
|
||||
nodeConfig := breez_sdk.NodeConfigGreenlight{
|
||||
@@ -255,9 +260,8 @@ if err != nil {
|
||||
config.workingDir = "path to an existing directory"
|
||||
|
||||
sdkServices, err := breez_sdk.Connect(config, seed, BreezListener{})
|
||||
|
||||
if err != nil {
|
||||
log.Fatalf("Connect failed: %#v", err)
|
||||
log.Fatalf("Connect failed: %#v", err)
|
||||
}
|
||||
```
|
||||
At any point we can fetch our balance from the Greenlight node:
|
||||
|
||||
Reference in New Issue
Block a user