Exporting channels backup

A Static Channel Backup (SCB) file is automatically generated by the Breez SDK in the background. More specifically, the SCB file is updated whenever a new channel is opened.

The SCB file can be used as a last resort to recover funds in case the Greenlight node becomes inaccessible ("doomsday" scenario). In order to recover the funds using the SCB information, users 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 SCB file. It can be retrieved from the SDK's working directory as follows:

Rust
let backup_data = BreezServices::static_backup(StaticBackupRequest {
    working_dir: "<working directory>".into(),
})?;
Swift
let backupData = try? staticBackup(req: StaticBackupRequest(workingDir: "<working directory>"))
Kotlin
try {
    val backupData = staticBackup(StaticBackupRequest("<working directory>"))
} catch (e: Exception) {
    // handle error
}
React Native
try {
  const backupData = await staticBackup({ workingDir: '<working directory>' })
} catch (err) {
  console.error(err)
}
Dart
StaticBackupRequest req = StaticBackupRequest(workingDir: workingDir);
StaticBackupResponse resp = await breezSDK.staticBackup(req: req);
Python
req = breez_sdk.StaticBackupRequest(working_dir=working_dir)
backup_data = breez_sdk.static_backup(req)
Go
workingDir := "<working directory>"
if staticBackupResponse, err := breez_sdk.StaticBackup(breez_sdk.StaticBackupRequest{WorkingDir: workingDir}); err == nil {
    log.Printf("%#v", staticBackupResponse)
}
C#
try
{
    var backupData = BreezSdkMethods.StaticBackup(
        new StaticBackupRequest("<working directory>"));
}
catch (Exception)
{
    // Handle error
}