mirror of
https://github.com/aljazceru/breez-sdk-docs.git
synced 2025-12-19 14:54: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
|
```python
|
||||||
try:
|
try:
|
||||||
lsp_id = self.sdk_services.lsp_id()
|
lsp_id = sdk_services.lsp_id()
|
||||||
lsp_info = sdk_services.fetch_lsp_info(lsp_id)
|
lsp_info = sdk_services.fetch_lsp_info(lsp_id)
|
||||||
|
|
||||||
except Exception as error:
|
except Exception as error:
|
||||||
@@ -75,4 +75,31 @@ except Exception as error:
|
|||||||
```
|
```
|
||||||
|
|
||||||
</section>
|
</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>
|
</custom-tabs>
|
||||||
@@ -236,6 +236,11 @@ func (BreezListener) OnEvent(e breez_sdk.BreezEvent) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create the default config
|
// 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>"
|
apiKey := "<your breez api key>"
|
||||||
inviteCode := "<your greenlight invite code>"
|
inviteCode := "<your greenlight invite code>"
|
||||||
nodeConfig := breez_sdk.NodeConfigGreenlight{
|
nodeConfig := breez_sdk.NodeConfigGreenlight{
|
||||||
@@ -255,7 +260,6 @@ if err != nil {
|
|||||||
config.workingDir = "path to an existing directory"
|
config.workingDir = "path to an existing directory"
|
||||||
|
|
||||||
sdkServices, err := breez_sdk.Connect(config, seed, BreezListener{})
|
sdkServices, err := breez_sdk.Connect(config, seed, BreezListener{})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Connect failed: %#v", err)
|
log.Fatalf("Connect failed: %#v", err)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user