mirror of
https://github.com/aljazceru/breez-sdk-docs.git
synced 2025-12-17 13:54:20 +01:00
Add list-lsps snippets
This commit is contained in:
@@ -17,6 +17,20 @@ public class ConnectingLspSnippets
|
|||||||
// ANCHOR_END: get-lsp-info
|
// ANCHOR_END: get-lsp-info
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ListLsps(BlockingBreezServices sdk)
|
||||||
|
{
|
||||||
|
// ANCHOR: list-lsps
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var availableLsps = sdk.ListLsps();
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
// Handle error
|
||||||
|
}
|
||||||
|
// ANCHOR_END: list-lsps
|
||||||
|
}
|
||||||
|
|
||||||
public void ConnectLsp(BlockingBreezServices sdk, string? lspId)
|
public void ConnectLsp(BlockingBreezServices sdk, string? lspId)
|
||||||
{
|
{
|
||||||
// ANCHOR: connect-lsp
|
// ANCHOR: connect-lsp
|
||||||
|
|||||||
@@ -10,6 +10,12 @@ Future<void> getLspInfo() async {
|
|||||||
// ANCHOR_END: get-lsp-info
|
// ANCHOR_END: get-lsp-info
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> listLsps() async {
|
||||||
|
// ANCHOR: list-lsps
|
||||||
|
List<LspInformation> availableLsps = await BreezSDK().listLsps();
|
||||||
|
// ANCHOR_END: list-lsps
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> connectLsp(String lspId) async {
|
Future<void> connectLsp(String lspId) async {
|
||||||
// ANCHOR: connect-lsp
|
// ANCHOR: connect-lsp
|
||||||
await BreezSDK().connectLSP(lspId);
|
await BreezSDK().connectLSP(lspId);
|
||||||
|
|||||||
@@ -16,6 +16,14 @@ func GetLspInfo() {
|
|||||||
// ANCHOR_END: get-lsp-info
|
// ANCHOR_END: get-lsp-info
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ListLsps() {
|
||||||
|
// ANCHOR: list-lsps
|
||||||
|
if err := sdk.ListLsps(); err != nil {
|
||||||
|
log.Printf("%#v", err)
|
||||||
|
}
|
||||||
|
// ANCHOR_END: list-lsps
|
||||||
|
}
|
||||||
|
|
||||||
func ConnectLsp() {
|
func ConnectLsp() {
|
||||||
// ANCHOR: connect-lsp
|
// ANCHOR: connect-lsp
|
||||||
lspId := "your selected lsp id"
|
lspId := "your selected lsp id"
|
||||||
|
|||||||
@@ -17,6 +17,15 @@ class ConnectingLsp {
|
|||||||
// ANCHOR_END: get-lsp-info
|
// ANCHOR_END: get-lsp-info
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun list_lsps(sdk: BlockingBreezServices) {
|
||||||
|
// ANCHOR: list-lsps
|
||||||
|
try {
|
||||||
|
let availableLsps = sdk.listLsps()
|
||||||
|
} catch (e: Exception) {
|
||||||
|
// Handle error
|
||||||
|
}
|
||||||
|
// ANCHOR_END: list-lsps
|
||||||
|
}
|
||||||
fun connect_lsp(sdk: BlockingBreezServices, lspId: String) {
|
fun connect_lsp(sdk: BlockingBreezServices, lspId: String) {
|
||||||
// ANCHOR: connect-lsp
|
// ANCHOR: connect-lsp
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -10,6 +10,15 @@ def get_lsp_info(sdk_services):
|
|||||||
print(error)
|
print(error)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
def list_lsps(sdk_services):
|
||||||
|
try:
|
||||||
|
# ANCHOR: list-lsps
|
||||||
|
available_lsps = sdk_services.list_lsps()
|
||||||
|
# ANCHOR_END: list-lsps
|
||||||
|
except Exception as error:
|
||||||
|
print(error)
|
||||||
|
raise
|
||||||
|
|
||||||
def connect_lsp(sdk_services,lsp_id):
|
def connect_lsp(sdk_services,lsp_id):
|
||||||
try:
|
try:
|
||||||
# ANCHOR: connect-lsp
|
# ANCHOR: connect-lsp
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { connectLsp, lspId, lspInfo } from '@breeztech/react-native-breez-sdk'
|
import { connectLsp, listLsps, lspId, lspInfo } from '@breeztech/react-native-breez-sdk'
|
||||||
|
|
||||||
const exampleAutoConnect = async () => {
|
const exampleAutoConnect = async () => {
|
||||||
// ANCHOR: get-lsp-info
|
// ANCHOR: get-lsp-info
|
||||||
@@ -7,6 +7,12 @@ const exampleAutoConnect = async () => {
|
|||||||
// ANCHOR_END: get-lsp-info
|
// ANCHOR_END: get-lsp-info
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const exampleListLsps = async () => {
|
||||||
|
// ANCHOR: list-lsps
|
||||||
|
const availableLsps = await listLsps()
|
||||||
|
// ANCHOR_END: list-lsps
|
||||||
|
}
|
||||||
|
|
||||||
const exampleManualConnect = async () => {
|
const exampleManualConnect = async () => {
|
||||||
// ANCHOR: connect-lsp
|
// ANCHOR: connect-lsp
|
||||||
const id = 'your selected lsp id'
|
const id = 'your selected lsp id'
|
||||||
|
|||||||
@@ -12,6 +12,14 @@ async fn get_lsp_info(sdk: Arc<BreezServices>) -> Result<LspInformation> {
|
|||||||
Ok(lsp_info)
|
Ok(lsp_info)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn list_lsps(sdk: Arc<BreezServices>) -> Result<()> {
|
||||||
|
// ANCHOR: list-lsps
|
||||||
|
let available_lsps = sdk.list_lsps().await?;
|
||||||
|
// ANCHOR_END: list-lsps
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
async fn connect_lsp(sdk: Arc<BreezServices>, lsp_id: String) -> Result<()> {
|
async fn connect_lsp(sdk: Arc<BreezServices>, lsp_id: String) -> Result<()> {
|
||||||
// ANCHOR: connect-lsp
|
// ANCHOR: connect-lsp
|
||||||
sdk.connect_lsp(lsp_id).await?;
|
sdk.connect_lsp(lsp_id).await?;
|
||||||
|
|||||||
@@ -16,10 +16,14 @@ func getLspInfo(sdk: BlockingBreezServices) -> LspInformation?{
|
|||||||
return lspInfo
|
return lspInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func listLsps(sdk: BlockingBreezServices) {
|
||||||
|
// ANCHOR: list-lsps
|
||||||
|
let availableLsps = try? sdk.listLsps()
|
||||||
|
// ANCHOR_END: list-lsps
|
||||||
|
}
|
||||||
|
|
||||||
func connectLsp(sdk: BlockingBreezServices, lspId: String) {
|
func connectLsp(sdk: BlockingBreezServices, lspId: String) {
|
||||||
// ANCHOR: connect-lsp
|
// ANCHOR: connect-lsp
|
||||||
try? sdk.connectLsp(lspId: lspId)
|
try? sdk.connectLsp(lspId: lspId)
|
||||||
// ANCHOR_END: connect-lsp
|
// ANCHOR_END: connect-lsp
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,7 +68,75 @@ Based on the API key provided to the Breez SDK, a default LSP is selected for yo
|
|||||||
</section>
|
</section>
|
||||||
</custom-tabs>
|
</custom-tabs>
|
||||||
|
|
||||||
When you have selected an LSP you may then connect to it.
|
In order to list all available LSPs you may connect to, you may do the following:
|
||||||
|
|
||||||
|
<custom-tabs category="lang">
|
||||||
|
<div slot="title">Rust</div>
|
||||||
|
<section>
|
||||||
|
|
||||||
|
```rust,ignore
|
||||||
|
{{#include ../../snippets/rust/src/connecting_lsp.rs:list-lsps}}
|
||||||
|
```
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<div slot="title">Swift</div>
|
||||||
|
<section>
|
||||||
|
|
||||||
|
```swift,ignore
|
||||||
|
{{#include ../../snippets/swift/BreezSDKExamples/Sources/ConnectingLsp.swift:list-lsps}}
|
||||||
|
```
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<div slot="title">Kotlin</div>
|
||||||
|
<section>
|
||||||
|
|
||||||
|
```kotlin,ignore
|
||||||
|
{{#include ../../snippets/kotlin_mpp_lib/shared/src/commonMain/kotlin/com/example/kotlinmpplib/ConnectingLsp.kt:list-lsps}}
|
||||||
|
```
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<div slot="title">React Native</div>
|
||||||
|
<section>
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
{{#include ../../snippets/react-native/connecting_lsp.ts:list-lsps}}
|
||||||
|
```
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<div slot="title">Dart</div>
|
||||||
|
<section>
|
||||||
|
|
||||||
|
```dart,ignore
|
||||||
|
{{#include ../../snippets/dart_snippets/lib/connecting_lsp.dart:list-lsps}}
|
||||||
|
```
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<div slot="title">Python</div>
|
||||||
|
<section>
|
||||||
|
|
||||||
|
```python,ignore
|
||||||
|
{{#include ../../snippets/python/src/connecting_lsp.py:list-lsps}}
|
||||||
|
```
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<div slot="title">Go</div>
|
||||||
|
<section>
|
||||||
|
|
||||||
|
```go,ignore
|
||||||
|
{{#include ../../snippets/go/connecting_lsp.go:list-lsps}}
|
||||||
|
```
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<div slot="title">C#</div>
|
||||||
|
<section>
|
||||||
|
|
||||||
|
```cs,ignore
|
||||||
|
{{#include ../../snippets/csharp/ConnectingLsp.cs:list-lsps}}
|
||||||
|
```
|
||||||
|
</section>
|
||||||
|
</custom-tabs>
|
||||||
|
|
||||||
|
When you have selected an LSP you may then connect to it:
|
||||||
|
|
||||||
<custom-tabs category="lang">
|
<custom-tabs category="lang">
|
||||||
<div slot="title">Rust</div>
|
<div slot="title">Rust</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user