diff --git a/bindings/c-ffi/src/lib.rs b/bindings/c-ffi/src/lib.rs index 09cb657..3cf5218 100644 --- a/bindings/c-ffi/src/lib.rs +++ b/bindings/c-ffi/src/lib.rs @@ -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, diff --git a/bindings/c-ffi/src/utils.rs b/bindings/c-ffi/src/utils.rs index b5d7b65..bbd7167 100644 --- a/bindings/c-ffi/src/utils.rs +++ b/bindings/c-ffi/src/utils.rs @@ -106,6 +106,24 @@ where } } +impl From> for CResultString +where + Error: std::fmt::Debug, +{ + fn from(other: Result) -> 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(ptr: *const c_char) -> Result, Error> { let str_array: Vec = serde_json::from_str(&ptr_to_string(ptr))?; str_array @@ -178,6 +196,12 @@ pub(crate) fn backup( Ok(res) } +pub(crate) fn backup_info(wallet: &COpaqueStruct) -> Result { + 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,