diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fca4001..4267011 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -25,8 +25,8 @@ jobs: name: setup runs-on: ubuntu-latest outputs: - sdk-ref: ${{ inputs.sdk-ref || '0.2.9' }} - package-version: '0.2.9' + sdk-ref: ${{ inputs.sdk-ref || '0.2.10' }} + package-version: '0.2.10' steps: - run: echo "set pre-setup output variables" diff --git a/snippets/csharp/ServiceStatus.cs b/snippets/csharp/ServiceStatus.cs new file mode 100644 index 0000000..839131d --- /dev/null +++ b/snippets/csharp/ServiceStatus.cs @@ -0,0 +1,36 @@ +using Breez.Sdk; + +public class ServiceStatusSnippets +{ + public void HealthCheckStatus(BlockingBreezServices sdk) + { + // ANCHOR: health-check-status + try + { + var healthCheck = sdk.ServiceHealthCheck(); + Console.WriteLine($"Current service status is: {healthCheck.status}"); + } + catch (Exception) + { + // Handle error + } + // ANCHOR_END: health-check-status + } + + public void ReportPaymentFailure(BlockingBreezServices sdk) + { + // ANCHOR: report-payment-failure + var paymentHash = "..."; + try + { + sdk.ReportIssue(new ReportIssueRequest.PaymentFailure( + new ReportPaymentFailureDetails(paymentHash) + )); + } + catch (Exception) + { + // Handle error + } + // ANCHOR_END: report-payment-failure + } +} diff --git a/snippets/dart_snippets/lib/service_status.dart b/snippets/dart_snippets/lib/service_status.dart new file mode 100644 index 0000000..e7f2ee8 --- /dev/null +++ b/snippets/dart_snippets/lib/service_status.dart @@ -0,0 +1,18 @@ +import 'package:breez_sdk/breez_sdk.dart'; +import 'package:breez_sdk/bridge_generated.dart'; + +Future healthCheckStatus() async { + // ANCHOR: health-check-status + ServiceHealthCheckResponse healthCheck = await BreezSDK().serviceHealthCheck(); + print("Current service status is: ${healthCheck.status}"); + // ANCHOR_END: health-check-status +} + +Future reportPaymentFailure() async { + // ANCHOR: report-payment-failure + String paymentHash = "..."; + await BreezSDK().reportIssue( + req: ReportIssueRequest.paymentFailure( + data: ReportPaymentFailureDetails(paymentHash: paymentHash))); + // ANCHOR_END: report-payment-failure +} diff --git a/snippets/dart_snippets/pubspec.lock b/snippets/dart_snippets/pubspec.lock index 9ab37dc..2e91c21 100644 --- a/snippets/dart_snippets/pubspec.lock +++ b/snippets/dart_snippets/pubspec.lock @@ -52,12 +52,10 @@ packages: breez_sdk: dependency: "direct main" description: - path: "." - ref: HEAD - resolved-ref: "9629def110a9dd03413850a05e9709d3c9794b0d" - url: "https://github.com/breez/breez-sdk-flutter" - source: git - version: "0.2.9" + path: "packages/breez-sdk-flutter" + relative: true + source: path + version: "0.2.10" build: dependency: transitive description: @@ -106,14 +104,6 @@ packages: url: "https://pub.dev" source: hosted version: "1.17.2" - colorize: - dependency: transitive - description: - name: colorize - sha256: "584746cd6ba1cba0633b6720f494fe6f9601c4170f0666c1579d2aa2a61071ba" - url: "https://pub.dev" - source: hosted - version: "3.0.0" convert: dependency: transitive description: @@ -171,10 +161,10 @@ packages: dependency: transitive description: name: flutter_rust_bridge - sha256: "8dcfeff9dcf0db9c76578c8805a337c0e5e21b4d96887eb1007b6fe141e15ea9" + sha256: ff90d5ddd0cda6d94ed048cc9c4a4d993d1a4bb11605d60a1282fc1bbf173c77 url: "https://pub.dev" source: hosted - version: "1.75.2" + version: "1.80.1" freezed: dependency: transitive description: @@ -331,10 +321,10 @@ packages: dependency: transitive description: name: petitparser - sha256: cb3798bef7fc021ac45b308f4b51208a152792445cce0448c9a4ba5879dd8750 + sha256: eeb2d1428ee7f4170e2bd498827296a18d4e7fc462b71727d111c0ac7707cfa6 url: "https://pub.dev" source: hosted - version: "5.4.0" + version: "6.0.1" pointycastle: dependency: transitive description: @@ -371,10 +361,10 @@ packages: dependency: transitive description: name: puppeteer - sha256: dd49117259867d0ce0de33ddd95628fb70cff94581a6432c08272447b8dd1d27 + sha256: eedeaae6ec5d2e54f9ae22ab4d6b3dda2e8791c356cc783046d06c287ffe11d8 url: "https://pub.dev" source: hosted - version: "2.24.0" + version: "3.6.0" rxdart: dependency: transitive description: @@ -589,5 +579,5 @@ packages: source: hosted version: "3.1.2" sdks: - dart: ">=3.1.0-185.0.dev <4.0.0" - flutter: ">=3.7.12" + dart: ">=3.1.0 <4.0.0" + flutter: ">=3.10.0" diff --git a/snippets/go/go.mod b/snippets/go/go.mod index ebdc98e..dfe8a58 100644 --- a/snippets/go/go.mod +++ b/snippets/go/go.mod @@ -2,6 +2,6 @@ module main go 1.19 -require github.com/breez/breez-sdk-go v0.2.9 +require github.com/breez/breez-sdk-go v0.2.10 replace github.com/breez/breez-sdk-go => ./packages/breez-sdk-go diff --git a/snippets/go/service_status.go b/snippets/go/service_status.go new file mode 100644 index 0000000..1d41408 --- /dev/null +++ b/snippets/go/service_status.go @@ -0,0 +1,29 @@ +package example + +import ( + "log" + + "github.com/breez/breez-sdk-go/breez_sdk" +) + +func HealthCheckStatus() { + // ANCHOR: health-check-status + if healthCheck, err := sdk.ServiceHealthCheck(); err != nil { + log.Printf("Current service status is: %v", healthCheck.Status) + } + // ANCHOR_END: health-check-status +} + +func ReportPaymentFailure() { + // ANCHOR: report-payment-failure + paymentHash := "..." + reportIssueRequest := breez_sdk.ReportIssueRequestPaymentFailure{ + Data: breez_sdk.ReportPaymentFailureDetails{ + PaymentHash: paymentHash, + }, + } + if err := sdk.ReportIssue(reportIssueRequest); err != nil { + log.Printf("%#v", err) + } + // ANCHOR_END: report-payment-failure +} diff --git a/snippets/kotlin_mpp_lib/shared/build.gradle.kts b/snippets/kotlin_mpp_lib/shared/build.gradle.kts index 38e3a84..a5a045a 100644 --- a/snippets/kotlin_mpp_lib/shared/build.gradle.kts +++ b/snippets/kotlin_mpp_lib/shared/build.gradle.kts @@ -34,7 +34,7 @@ kotlin { } val commonMain by getting { dependencies { - implementation("technology.breez:breez-sdk-kmp:0.2.9") + implementation("technology.breez:breez-sdk-kmp:0.2.10") } } } diff --git a/snippets/kotlin_mpp_lib/shared/src/commonMain/kotlin/com/example/kotlinmpplib/ServiceStatus.kt b/snippets/kotlin_mpp_lib/shared/src/commonMain/kotlin/com/example/kotlinmpplib/ServiceStatus.kt new file mode 100644 index 0000000..1ed5f33 --- /dev/null +++ b/snippets/kotlin_mpp_lib/shared/src/commonMain/kotlin/com/example/kotlinmpplib/ServiceStatus.kt @@ -0,0 +1,27 @@ +package com.example.kotlinmpplib + +import breez_sdk.* +class ServiceStatus { + fun HealthCheckStatus(sdk: BlockingBreezServices) { + // ANCHOR: health-check-status + try { + val healthCheck = sdk.serviceHealthCheck() + // Log.v("Breez", "Current service status is: ${healthCheck.status}") + } catch (e: Exception) { + // Handle error + } + // ANCHOR_END: health-check-status + } + + fun reportPaymentFailure(sdk: BlockingBreezServices) { + // ANCHOR: report-payment-failure + val paymentHash = "..." + try { + sdk.reportIssue(ReportIssueRequest.PaymentFailure( + ReportPaymentFailureDetails(paymentHash))) + } catch (e: Exception) { + // Handle error + } + // ANCHOR_END: report-payment-failure + } +} \ No newline at end of file diff --git a/snippets/python/src/service_status.py b/snippets/python/src/service_status.py new file mode 100644 index 0000000..18e1187 --- /dev/null +++ b/snippets/python/src/service_status.py @@ -0,0 +1,23 @@ +import breez_sdk + +def health_check_status(sdk_services): + try: + # ANCHOR: health-check-status + health_check = sdk_services.service_health_check() + print("Current service status is: ", health_check.status) + # ANCHOR_END: health-check-status + except Exception as error: + print(error) + raise + +def report_payment_failure(sdk_services): + try: + # ANCHOR: report-payment-failure + payment_hash = "..." + sdk_services.report_issue( + breez_sdk.ReportIssueRequest.PAYMENT_FAILURE( + breez_sdk.ReportPaymentFailureDetails(payment_hash))) + # ANCHOR_END: report-payment-failure + except Exception as error: + print(error) + raise diff --git a/snippets/react-native/service_status.ts b/snippets/react-native/service_status.ts new file mode 100644 index 0000000..9862a53 --- /dev/null +++ b/snippets/react-native/service_status.ts @@ -0,0 +1,18 @@ +import { serviceHealthCheck, reportIssue, ReportIssueRequestVariant } from '@breeztech/react-native-breez-sdk' + +const healthCheckStatus = async () => { + // ANCHOR: health-check-status + const healthCheck = await serviceHealthCheck() + console.log(`Current service status is: ${healthCheck.status}`) + // ANCHOR_END: health-check-status +} + +const reportPaymentFailure = async () => { + // ANCHOR: report-payment-failure + const paymentHash = '...' + await reportIssue({ + type: ReportIssueRequestVariant.PAYMENT_FAILURE, + data: { paymentHash } + }) + // ANCHOR_END: report-payment-failure +} diff --git a/snippets/react-native/yarn.lock b/snippets/react-native/yarn.lock index 3127472..844c090 100644 --- a/snippets/react-native/yarn.lock +++ b/snippets/react-native/yarn.lock @@ -714,10 +714,10 @@ "@babel/helper-validator-identifier" "^7.22.20" to-fast-properties "^2.0.0" -"@breeztech/react-native-breez-sdk@0.2.9": - version "0.2.9" - resolved "https://registry.yarnpkg.com/@breeztech/react-native-breez-sdk/-/react-native-breez-sdk-0.2.9.tgz#e1bcd37f16b92ac5792fedf7c4afa481322dac80" - integrity sha512-4mziuxCa8hpDGtMFD4VWK7tj+z3F/48x5NsKwxIYMkfLxxYP+6ZvD0ucEbyqr3P0Lwn0Cj4/iCnwM2gIL8UFcw== +"@breeztech/react-native-breez-sdk@0.2.10": + version "0.2.10" + resolved "https://registry.yarnpkg.com/@breeztech/react-native-breez-sdk/-/react-native-breez-sdk-0.2.10.tgz#072b00f57028b5276c600a462cbcaac93d3dee22" + integrity sha512-81wtbkKGxhDaIweIQkD+LLDUL7WTtbI3qEb9vx4Itiu1hGzM8Q2RlYNF5R1jh2m4wdYKUKMWSBd3O4VRnywf1Q== "@esbuild/android-arm64@0.18.20": version "0.18.20" diff --git a/snippets/rust/Cargo.lock b/snippets/rust/Cargo.lock index 77f66ec..e8d7560 100644 --- a/snippets/rust/Cargo.lock +++ b/snippets/rust/Cargo.lock @@ -458,8 +458,8 @@ dependencies = [ [[package]] name = "breez-sdk-core" -version = "0.2.9" -source = "git+https://github.com/breez/breez-sdk?tag=0.2.9#82fdc4f7d2de354fc299cc4fbf8691492d4bc642" +version = "0.2.10" +source = "git+https://github.com/breez/breez-sdk?tag=0.2.10#d18529988eb7b1038473161e44c88225c7a0236d" dependencies = [ "aes", "anyhow", @@ -605,9 +605,8 @@ dependencies = [ [[package]] name = "cln-grpc" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57af6eff15ee3fd7a0e09d0baeab8d33c892a73d97b87248e5f94f4749eacfe1" +version = "0.1.7" +source = "git+https://github.com/cdecker/lightning.git?tag=gl-20231113#075927b2c5f38fdbde4c0764135be58340b0ce08" dependencies = [ "anyhow", "bitcoin 0.30.1", @@ -1132,7 +1131,7 @@ checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" [[package]] name = "gl-client" version = "0.1.9" -source = "git+https://github.com/Blockstream/greenlight.git?rev=c7ff67eb062c021105f5601df3ac8699ecbeb51c#c7ff67eb062c021105f5601df3ac8699ecbeb51c" +source = "git+https://github.com/Blockstream/greenlight.git?rev=84a66ac3c467569365285814ef5a691b5b97f60d#84a66ac3c467569365285814ef5a691b5b97f60d" dependencies = [ "anyhow", "async-trait", @@ -1160,7 +1159,6 @@ dependencies = [ "serde", "serde_bolt 0.2.6", "serde_json", - "serde_with 2.3.3", "sha256", "tempfile", "thiserror", @@ -2583,7 +2581,6 @@ dependencies = [ "base64 0.13.1", "chrono", "hex", - "indexmap 1.9.3", "serde", "serde_json", "serde_with_macros 2.3.3", diff --git a/snippets/rust/Cargo.toml b/snippets/rust/Cargo.toml index a721f79..ff6a3f1 100644 --- a/snippets/rust/Cargo.toml +++ b/snippets/rust/Cargo.toml @@ -6,6 +6,6 @@ edition = "2021" [dependencies] anyhow = "1" bip39 = { version = "2", features = ["rand"] } -breez-sdk-core = { git = "https://github.com/breez/breez-sdk", tag = "0.2.9" } +breez-sdk-core = { git = "https://github.com/breez/breez-sdk", tag = "0.2.10" } log = "0.4" tokio = "1.29" \ No newline at end of file diff --git a/snippets/rust/src/main.rs b/snippets/rust/src/main.rs index 9c0d04e..5df75ef 100644 --- a/snippets/rust/src/main.rs +++ b/snippets/rust/src/main.rs @@ -11,6 +11,7 @@ mod receive_payment; mod send_onchain; mod send_payment; mod send_spontaneous_payment; +mod service_status; mod static_channel_backup; use anyhow::Result; diff --git a/snippets/rust/src/service_status.rs b/snippets/rust/src/service_status.rs new file mode 100644 index 0000000..afe6eb5 --- /dev/null +++ b/snippets/rust/src/service_status.rs @@ -0,0 +1,30 @@ +use std::sync::Arc; + +use anyhow::Result; +use breez_sdk_core::*; +use log::info; + +async fn health_check_status(sdk: Arc) -> Result<()> { + // ANCHOR: health-check-status + let health_check = sdk.service_health_check().await?; + info!("Current service status is: {:?}", health_check.status); + // ANCHOR_END: health-check-status + + Ok(()) +} + +async fn report_payment_failure(sdk: Arc) -> Result<()> { + // ANCHOR: report-payment-failure + let payment_hash = String::from("..."); + + sdk.report_issue(ReportIssueRequest::PaymentFailure { + data: ReportPaymentFailureDetails { + payment_hash, + comment: None, + }, + }) + .await?; + // ANCHOR_END: report-payment-failure + + Ok(()) +} diff --git a/snippets/swift/BreezSDKExamples/Package.resolved b/snippets/swift/BreezSDKExamples/Package.resolved index 3952624..2079673 100644 --- a/snippets/swift/BreezSDKExamples/Package.resolved +++ b/snippets/swift/BreezSDKExamples/Package.resolved @@ -5,8 +5,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/breez/breez-sdk-swift", "state" : { - "revision" : "dcbb39d45bc6797447bf20f52bc22344026d0662", - "version" : "0.2.9" + "revision" : "74402afba8218ff84a0f32d1bc0d4ddc7698f576", + "version" : "0.2.10" } }, { diff --git a/snippets/swift/BreezSDKExamples/Package.swift b/snippets/swift/BreezSDKExamples/Package.swift index 27e6c84..86f6df7 100644 --- a/snippets/swift/BreezSDKExamples/Package.swift +++ b/snippets/swift/BreezSDKExamples/Package.swift @@ -8,7 +8,7 @@ let package = Package( platforms: [.macOS(.v12)], dependencies: [ .package(url: "https://github.com/apple/swift-argument-parser", from: "1.2.3"), - .package(url: "https://github.com/breez/breez-sdk-swift", from:"0.2.9") + .package(url: "https://github.com/breez/breez-sdk-swift", from:"0.2.10") ], targets: [ // Targets are the basic building blocks of a package, defining a module or a test suite. diff --git a/snippets/swift/BreezSDKExamples/Sources/ServiceStatus.swift b/snippets/swift/BreezSDKExamples/Sources/ServiceStatus.swift new file mode 100644 index 0000000..67aea0d --- /dev/null +++ b/snippets/swift/BreezSDKExamples/Sources/ServiceStatus.swift @@ -0,0 +1,27 @@ +// +// ServiceStatus.swift +// +// +// Created by dangeross on 27/11/2023. +// + +import Foundation +import BreezSDK + +func getServiceStatus(sdk: BlockingBreezServices) -> ServiceHealthCheckResponse? { + // ANCHOR: health-check-status + let healthCheck = try? sdk.serviceHealthCheck() + print("Current service status is: \(healthCheck?.status)") + // ANCHOR_END: health-check-status + return healthCheck +} + +func reportPaymentFailure(sdk: BlockingBreezServices) { + // ANCHOR: report-payment-failure + let paymentHash = "..." + + try? sdk.reportIssue( + req: ReportIssueRequest.paymentFailure( + data: ReportPaymentFailureDetails(paymentHash: paymentHash))) + // ANCHOR_END: report-payment-failure +} diff --git a/src/SUMMARY.md b/src/SUMMARY.md index 9d2fbb7..1949dc8 100644 --- a/src/SUMMARY.md +++ b/src/SUMMARY.md @@ -20,4 +20,5 @@ - [Supporting fiat currencies](guide/fiat_currencies.md) - [Buy Bitcoin](guide/buy_btc.md) - [Static Channel Backup](guide/static_channel_backup.md) +- [Service status](guide/service_status.md) - [Moving to production](guide/production.md) diff --git a/src/guide/service_status.md b/src/guide/service_status.md new file mode 100644 index 0000000..11099ef --- /dev/null +++ b/src/guide/service_status.md @@ -0,0 +1,140 @@ +# Health Check Status + +You can check the general health status of the services provided by the Breez SDK. +The response status will inform you if there is maintenance occurring, a service distruption or the services are operational. + + +
Rust
+
+ +```rust,ignore +{{#include ../../snippets/rust/src/service_status.rs:health-check-status}} +``` +
+ +
Swift
+
+ +```swift,ignore +{{#include ../../snippets/swift/BreezSDKExamples/Sources/ServiceStatus.swift:health-check-status}} +``` +
+ +
Kotlin
+
+ +```kotlin,ignore +{{#include ../../snippets/kotlin_mpp_lib/shared/src/commonMain/kotlin/com/example/kotlinmpplib/ServiceStatus.kt:health-check-status}} +``` +
+ +
React Native
+
+ +```typescript +{{#include ../../snippets/react-native/service_status.ts:health-check-status}} +``` +
+ +
Dart
+
+ +```dart,ignore +{{#include ../../snippets/dart_snippets/lib/service_status.dart:health-check-status}} +``` +
+ +
Python
+
+ +```python,ignore +{{#include ../../snippets/python/src/service_status.py:health-check-status}} +``` +
+ +
Go
+
+ +```go,ignore +{{#include ../../snippets/go/service_status.go:health-check-status}} +``` +
+ +
C#
+
+ +```cs,ignore +{{#include ../../snippets/csharp/ServiceStatus.cs:health-check-status}} +``` +
+
+ +# Reporting a Payment Failure + +While attempting to send payments it may be that sometimes payment failures occur. Reporting these issues through the Breez SDK will help us to improve LSP routing. + + +
Rust
+
+ +```rust,ignore +{{#include ../../snippets/rust/src/service_status.rs:report-payment-failure}} +``` +
+ +
Swift
+
+ +```swift,ignore +{{#include ../../snippets/swift/BreezSDKExamples/Sources/ServiceStatus.swift:report-payment-failure}} +``` +
+ +
Kotlin
+
+ +```kotlin,ignore +{{#include ../../snippets/kotlin_mpp_lib/shared/src/commonMain/kotlin/com/example/kotlinmpplib/ServiceStatus.kt:report-payment-failure}} +``` +
+ +
React Native
+
+ +```typescript +{{#include ../../snippets/react-native/service_status.ts:report-payment-failure}} +``` +
+ +
Dart
+
+ +```dart,ignore +{{#include ../../snippets/dart_snippets/lib/service_status.dart:report-payment-failure}} +``` +
+ +
Python
+
+ +```python,ignore +{{#include ../../snippets/python/src/service_status.py:report-payment-failure}} +``` +
+ +
Go
+
+ +```go,ignore +{{#include ../../snippets/go/service_status.go:report-payment-failure}} +``` +
+ +
C#
+
+ +```cs,ignore +{{#include ../../snippets/csharp/ServiceStatus.cs:report-payment-failure}} +``` +
+