Skip to content

Commit ec87fb7

Browse files
authored
Merge pull request #72 from cakesoft-shashank/master
Add invoice_data function to C FFI bindings
2 parents 5c42b9f + 36fd57f commit ec87fb7

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

bindings/c-ffi/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,11 @@ pub extern "C" fn rgblib_inflate(
242242
.into()
243243
}
244244

245+
#[unsafe(no_mangle)]
246+
pub extern "C" fn rgblib_invoice_data(invoice_string: *const c_char) -> CResultString {
247+
invoice_data(invoice_string).into()
248+
}
249+
245250
#[unsafe(no_mangle)]
246251
pub extern "C" fn rgblib_issue_asset_cfa(
247252
wallet: &COpaqueStruct,

bindings/c-ffi/src/utils.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,12 @@ pub(crate) fn inflate(
380380
Ok(serde_json::to_string(&res)?)
381381
}
382382

383+
pub(crate) fn invoice_data(invoice_string: *const c_char) -> Result<String, Error> {
384+
let invoice_string = ptr_to_string(invoice_string);
385+
let invoice = rgb_lib::wallet::Invoice::new(invoice_string)?;
386+
Ok(serde_json::to_string(&invoice.invoice_data())?)
387+
}
388+
383389
pub(crate) fn issue_asset_cfa(
384390
wallet: &COpaqueStruct,
385391
name: *const c_char,

0 commit comments

Comments
 (0)