Files
breez-sdk-docs/src/guide/static_channel_backup.md
2023-11-03 13:26:22 +01:00

2.5 KiB

Static Channel Backup

A static channel backup is automatically saved by the Breez SDK in the background. More specifically, the static backup is updated each time a new channel is opened.

The static channel backup can be used as a last resort to recover funds in case the Greenlight node becomes inaccessible. Recovering the funds is currently not part of the Breez SDK. In order to recover the funds, the user can initialize a new core lightning node with its HSM secret using their seed. Then trigger a channel recovery through the recoverchannel method provided by CLN.

In order to use the recoverchannel method, the user needs to provide the static channel backup file. It can be retrieved from the SDK's working directory as follows:

Rust
{{#include ../../snippets/rust/src/static_channel_backup.rs:static-channel-backup}}
Swift
do {
    let backupData = breez_sdk.staticBackup(request: StaticBackupRequest(workingDir: "<working directory>"));
} catch{
    // handle error
}
Kotlin
try {
    val backupData = staticBackup(StaticBackupRequest("<working directory>"))
} catch (e: Exception) {
    // handle error
}
React Native
{{#include ../../snippets/react-native/static_channel_backup.ts:static-channel-backup}}
Dart
{{#include ../../snippets/dart_snippets/lib/static_channel_backup.dart:static-channel-backup}}
Python
try:
    backup_data = breez_sdk.static_backup(breez_sdk.StaticBackupRequest(working_dir="<working directory>"))
except Exception as error:
    # Handle error
Go
workingDir := "<working directory>"
if staticBackupResponse, err := breez_sdk.StaticBackup(breez_sdk.StaticBackupRequest{WorkingDir: workingDir}); err == nil {
    log.Printf("%#v", staticBackupResponse)
}
C#
using Breez.Sdk;

try 
{
    var backupData = BreezSdkMethods.StaticBackup(new StaticBackupRequest("<working directory>"));  
} catch (Exception) 
{
   // Handle error
}