Files
breez-sdk-docs/src/guide/connecting_lsp.md

4.0 KiB

Connecting to an LSP

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:

Rust
{{#include ../../snippets/rust/src/connecting_lsp.rs:get-lsp-info}}
Swift
do {
    let lspId = try sdk.lspId() 
    let lspInfo = try sdk.lspInfo()
} catch {
    // Handle error
}
Kotlin
try {
    val lspId = sdk.lspId()
    if (lspId != null) {
        val lspInfo = sdk.lspInfo()
    } else {
        // Handle no lsp id scenario
    }
} catch (e: Exception) {
    // Handle error
}
React Native
{{#include ../../snippets/react-native/connecting_lsp.ts:get-lsp-info}}
Dart
{{#include ../../snippets/dart_snippets/lib/connecting_lsp.dart:get-lsp-info}}
Python
try: 
    lsp_id = sdk_services.lsp_id()
    lsp_info = sdk_services.lsp_info()
   
except Exception as error:
    # Handle error
Go
{{#include ../../snippets/go/connecting_lsp.go:get-lsp-info}}
C#
{{#include ../../snippets/csharp/ConnectingLsp.cs:get-lsp-info}}

When you have selected an LSP you may then connect to it.

Rust
{{#include ../../snippets/rust/src/connecting_lsp.rs:connect-lsp}}
Swift
do {
    try sdk.connectLsp(lspId: lspId!)
} catch {
    // Handle error
}
Kotlin
try {
    sdk.connectLsp(lspId)
} catch (e: Exception) {
    // Handle error
}
React Native
{{#include ../../snippets/react-native/connecting_lsp.ts:connect-lsp}}
Dart
{{#include ../../snippets/dart_snippets/lib/connecting_lsp.dart:connect-lsp}}
Python
try: 
    sdk_services.connect_lsp(lsp_id)
except Exception as error:
    # Handle error
Go
{{#include ../../snippets/go/connecting_lsp.go:connect-lsp}}
C#
{{#include ../../snippets/csharp/ConnectingLsp.cs:connect-lsp}}

Channel Opening Fees

Some Breez SDK operations1 may need opening a new channel with the LSP. The SDK supports the LSP2 dynamic fees spec2 , which describes how these channel opening fees are handled.

For the client, the key points are:

  • The LspInformation can be fetched at any point and includes a list of channel opening fees and the duration for which they are valid. The fees are sorted from cheapest to most expensive. The higher fees are typically also valid for longer.
  • Depending on the application and use-case, the client may choose an appropriate fee and give it as an argument in the relevant Breez SDK method. If this fee argument is not provided, Breez SDK will choose an appropriate one instead.

The channel opening fees are provided in a structure3 that includes the conditions associated with these fees, like the minimum invoice amount or the date and time until when this opening fee is valid.