Skip to content

Commit

Permalink
Add bindings for backup_info() as well
Browse files Browse the repository at this point in the history
  • Loading branch information
tmalahie committed Dec 11, 2024
1 parent b54cc23 commit 74380a5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
5 changes: 5 additions & 0 deletions bindings/c-ffi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ pub extern "C" fn rgblib_backup(
backup(wallet, backup_path, password).into()
}

#[no_mangle]
pub extern "C" fn rgblib_backup_info(wallet: &COpaqueStruct) -> CResultString {
backup_info(wallet).into()
}

#[no_mangle]
pub extern "C" fn rgblib_blind_receive(
wallet: &COpaqueStruct,
Expand Down
14 changes: 10 additions & 4 deletions bindings/c-ffi/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,14 @@ pub(crate) fn backup(
let wallet = Wallet::from_opaque(wallet)?;
let backup_path = ptr_to_string(backup_path);
let password = ptr_to_string(password);
let res = wallet.backup(&backup_path, &password)?;
Ok(res)
wallet.backup(&backup_path, &password)?;
Ok(())
}

pub(crate) fn backup_info(wallet: &COpaqueStruct) -> Result<String, Error> {
let wallet = Wallet::from_opaque(wallet)?;
let res = wallet.backup_info()?;
Ok(serde_json::to_string(&res)?)
}

pub(crate) fn blind_receive(
Expand Down Expand Up @@ -424,8 +430,8 @@ pub(crate) fn restore_backup(
let backup_path = ptr_to_string(backup_path);
let password = ptr_to_string(password);
let target_dir = ptr_to_string(target_dir);
let res = rgb_lib::restore_backup(&backup_path, &password, &target_dir)?;
Ok(res)
rgb_lib::restore_backup(&backup_path, &password, &target_dir)?;
Ok(())
}

pub(crate) fn restore_keys(
Expand Down

0 comments on commit 74380a5

Please sign in to comment.