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:
{{#include ../../snippets/rust/src/connecting_lsp.rs:get-lsp-info}}
do {
let lspId = try sdk.lspId()
let lspInfo = try sdk.lspInfo()
} catch {
// Handle error
}
try {
val lspId = sdk.lspId()
if (lspId != null) {
val lspInfo = sdk.lspInfo()
} else {
// Handle no lsp id scenario
}
} catch (e: Exception) {
// Handle error
}
{{#include ../../snippets/react-native/connecting_lsp.ts:get-lsp-info}}
{{#include ../../snippets/dart_snippets/lib/connecting_lsp.dart:get-lsp-info}}
try:
lsp_id = sdk_services.lsp_id()
lsp_info = sdk_services.lsp_info()
except Exception as error:
# Handle error
{{#include ../../snippets/go/connecting_lsp.go:get-lsp-info}}
{{#include ../../snippets/csharp/ConnectingLsp.cs:get-lsp-info}}
When you have selected an LSP you may then connect to it.
{{#include ../../snippets/rust/src/connecting_lsp.rs:connect-lsp}}
do {
try sdk.connectLsp(lspId: lspId!)
} catch {
// Handle error
}
try {
sdk.connectLsp(lspId)
} catch (e: Exception) {
// Handle error
}
{{#include ../../snippets/react-native/connecting_lsp.ts:connect-lsp}}
{{#include ../../snippets/dart_snippets/lib/connecting_lsp.dart:connect-lsp}}
try:
sdk_services.connect_lsp(lsp_id)
except Exception as error:
# Handle error
{{#include ../../snippets/go/connecting_lsp.go:connect-lsp}}
{{#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
LspInformationcan 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.
-
See the service methods
receive_payment,receive_onchainorbuy_bitcoin. ↩︎ -
https://github.com/BitcoinAndLightningLayerSpecs/lsp/tree/main/LSPS2 ↩︎
-
https://breez.github.io/breez-sdk/breez_sdk_core/struct.OpeningFeeParams.html ↩︎