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 10, 2024
1 parent 038045d commit 5df3ee7
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 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
24 changes: 24 additions & 0 deletions bindings/c-ffi/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,24 @@ where
}
}

impl From<Result<bool, Error>> for CResultString
where
Error: std::fmt::Debug,
{
fn from(other: Result<bool, Error>) -> Self {
match other {
Ok(d) => CResultString {
result: CResultValue::Ok,
inner: string_to_ptr(d.to_string()),
},
Err(e) => CResultString {
result: CResultValue::Err,
inner: string_to_ptr(format!("{:?}", e)),
},
}
}
}

fn convert_strings_array<T: FromStr>(ptr: *const c_char) -> Result<Vec<T>, Error> {
let str_array: Vec<String> = serde_json::from_str(&ptr_to_string(ptr))?;
str_array
Expand Down Expand Up @@ -178,6 +196,12 @@ pub(crate) fn backup(
Ok(res)
}

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

pub(crate) fn blind_receive(
wallet: &COpaqueStruct,
asset_id_opt: *const c_char,
Expand Down

0 comments on commit 5df3ee7

Please sign in to comment.