diff --git a/lib/core/src/frb/bridge.io.rs b/lib/core/src/frb/bridge.io.rs new file mode 100644 index 0000000..d46288f --- /dev/null +++ b/lib/core/src/frb/bridge.io.rs @@ -0,0 +1,581 @@ +// This file is automatically generated, so please do not edit it. +// Generated by `flutter_rust_bridge`@ 2.0.0-dev.32. + +// Section: imports + +use super::*; +use crate::bindings::*; +use flutter_rust_bridge::for_generated::byteorder::{NativeEndian, ReadBytesExt, WriteBytesExt}; +use flutter_rust_bridge::for_generated::transform_result_dco; +use flutter_rust_bridge::{Handler, IntoIntoDart}; + +// Section: boilerplate + +flutter_rust_bridge::frb_generated_boilerplate_io!(); + +// Section: dart2rust + +impl CstDecode + for *mut wire_cst_list_prim_u_8_strict +{ + // Codec=Cst (C-struct based), see doc to use other codecs + fn cst_decode(self) -> flutter_rust_bridge::for_generated::anyhow::Error { + unimplemented!() + } +} +impl CstDecode for usize { + // Codec=Cst (C-struct based), see doc to use other codecs + fn cst_decode(self) -> LBtcReverseRecovery { + CstDecode::< + RustOpaqueNom< + flutter_rust_bridge::for_generated::rust_async::RwLock, + >, + >::cst_decode(self) + .rust_auto_opaque_decode_owned() + } +} +impl + CstDecode< + RustOpaqueNom>, + > for usize +{ + // Codec=Cst (C-struct based), see doc to use other codecs + fn cst_decode( + self, + ) -> RustOpaqueNom> + { + unsafe { decode_rust_opaque_nom(self as _) } + } +} +impl CstDecode for *mut wire_cst_list_prim_u_8_strict { + // Codec=Cst (C-struct based), see doc to use other codecs + fn cst_decode(self) -> String { + let vec: Vec = self.cst_decode(); + String::from_utf8(vec).unwrap() + } +} +impl CstDecode for *mut wire_cst_prepare_receive_request { + // Codec=Cst (C-struct based), see doc to use other codecs + fn cst_decode(self) -> crate::model::PrepareReceiveRequest { + let wrap = unsafe { flutter_rust_bridge::for_generated::box_from_leak_ptr(self) }; + CstDecode::::cst_decode(*wrap).into() + } +} +impl CstDecode for *mut wire_cst_prepare_receive_response { + // Codec=Cst (C-struct based), see doc to use other codecs + fn cst_decode(self) -> crate::model::PrepareReceiveResponse { + let wrap = unsafe { flutter_rust_bridge::for_generated::box_from_leak_ptr(self) }; + CstDecode::::cst_decode(*wrap).into() + } +} +impl CstDecode for *mut wire_cst_prepare_send_response { + // Codec=Cst (C-struct based), see doc to use other codecs + fn cst_decode(self) -> crate::model::PrepareSendResponse { + let wrap = unsafe { flutter_rust_bridge::for_generated::box_from_leak_ptr(self) }; + CstDecode::::cst_decode(*wrap).into() + } +} +impl CstDecode for *mut u32 { + // Codec=Cst (C-struct based), see doc to use other codecs + fn cst_decode(self) -> u32 { + unsafe { *flutter_rust_bridge::for_generated::box_from_leak_ptr(self) } + } +} +impl CstDecode for *mut u64 { + // Codec=Cst (C-struct based), see doc to use other codecs + fn cst_decode(self) -> u64 { + unsafe { *flutter_rust_bridge::for_generated::box_from_leak_ptr(self) } + } +} +impl CstDecode> for *mut wire_cst_list_payment { + // Codec=Cst (C-struct based), see doc to use other codecs + fn cst_decode(self) -> Vec { + let vec = unsafe { + let wrap = flutter_rust_bridge::for_generated::box_from_leak_ptr(self); + flutter_rust_bridge::for_generated::vec_from_leak_ptr(wrap.ptr, wrap.len) + }; + vec.into_iter().map(CstDecode::cst_decode).collect() + } +} +impl CstDecode> for *mut wire_cst_list_prim_u_8_strict { + // Codec=Cst (C-struct based), see doc to use other codecs + fn cst_decode(self) -> Vec { + unsafe { + let wrap = flutter_rust_bridge::for_generated::box_from_leak_ptr(self); + flutter_rust_bridge::for_generated::vec_from_leak_ptr(wrap.ptr, wrap.len) + } + } +} +impl CstDecode for wire_cst_payment { + // Codec=Cst (C-struct based), see doc to use other codecs + fn cst_decode(self) -> crate::model::Payment { + crate::model::Payment { + id: self.id.cst_decode(), + timestamp: self.timestamp.cst_decode(), + amount_sat: self.amount_sat.cst_decode(), + fees_sat: self.fees_sat.cst_decode(), + payment_type: self.payment_type.cst_decode(), + invoice: self.invoice.cst_decode(), + } + } +} +impl CstDecode for wire_cst_payment_error { + // Codec=Cst (C-struct based), see doc to use other codecs + fn cst_decode(self) -> crate::error::PaymentError { + match self.tag { + 0 => crate::error::PaymentError::AmountOutOfRange, + 1 => crate::error::PaymentError::AlreadyClaimed, + 2 => { + let ans = unsafe { self.kind.Generic }; + crate::error::PaymentError::Generic { + err: ans.err.cst_decode(), + } + } + 3 => crate::error::PaymentError::InvalidInvoice, + 4 => crate::error::PaymentError::InvalidPreimage, + 5 => { + let ans = unsafe { self.kind.LwkError }; + crate::error::PaymentError::LwkError { + err: ans.err.cst_decode(), + } + } + 6 => crate::error::PaymentError::PairsNotFound, + 7 => crate::error::PaymentError::PersistError, + 8 => { + let ans = unsafe { self.kind.SendError }; + crate::error::PaymentError::SendError { + err: ans.err.cst_decode(), + } + } + 9 => { + let ans = unsafe { self.kind.SignerError }; + crate::error::PaymentError::SignerError { + err: ans.err.cst_decode(), + } + } + _ => unreachable!(), + } + } +} +impl CstDecode for wire_cst_prepare_receive_request { + // Codec=Cst (C-struct based), see doc to use other codecs + fn cst_decode(self) -> crate::model::PrepareReceiveRequest { + crate::model::PrepareReceiveRequest { + payer_amount_sat: self.payer_amount_sat.cst_decode(), + receiver_amount_sat: self.receiver_amount_sat.cst_decode(), + } + } +} +impl CstDecode for wire_cst_prepare_receive_response { + // Codec=Cst (C-struct based), see doc to use other codecs + fn cst_decode(self) -> crate::model::PrepareReceiveResponse { + crate::model::PrepareReceiveResponse { + pair_hash: self.pair_hash.cst_decode(), + payer_amount_sat: self.payer_amount_sat.cst_decode(), + fees_sat: self.fees_sat.cst_decode(), + } + } +} +impl CstDecode for wire_cst_prepare_send_response { + // Codec=Cst (C-struct based), see doc to use other codecs + fn cst_decode(self) -> crate::model::PrepareSendResponse { + crate::model::PrepareSendResponse { + id: self.id.cst_decode(), + payer_amount_sat: self.payer_amount_sat.cst_decode(), + receiver_amount_sat: self.receiver_amount_sat.cst_decode(), + total_fees: self.total_fees.cst_decode(), + funding_address: self.funding_address.cst_decode(), + invoice: self.invoice.cst_decode(), + } + } +} +impl CstDecode for wire_cst_receive_payment_response { + // Codec=Cst (C-struct based), see doc to use other codecs + fn cst_decode(self) -> crate::model::ReceivePaymentResponse { + crate::model::ReceivePaymentResponse { + id: self.id.cst_decode(), + invoice: self.invoice.cst_decode(), + } + } +} +impl CstDecode for wire_cst_send_payment_response { + // Codec=Cst (C-struct based), see doc to use other codecs + fn cst_decode(self) -> crate::model::SendPaymentResponse { + crate::model::SendPaymentResponse { + txid: self.txid.cst_decode(), + } + } +} +impl CstDecode for wire_cst_wallet_info { + // Codec=Cst (C-struct based), see doc to use other codecs + fn cst_decode(self) -> crate::model::WalletInfo { + crate::model::WalletInfo { + balance_sat: self.balance_sat.cst_decode(), + pubkey: self.pubkey.cst_decode(), + } + } +} +impl NewWithNullPtr for wire_cst_payment { + fn new_with_null_ptr() -> Self { + Self { + id: core::ptr::null_mut(), + timestamp: core::ptr::null_mut(), + amount_sat: Default::default(), + fees_sat: core::ptr::null_mut(), + payment_type: Default::default(), + invoice: core::ptr::null_mut(), + } + } +} +impl Default for wire_cst_payment { + fn default() -> Self { + Self::new_with_null_ptr() + } +} +impl NewWithNullPtr for wire_cst_payment_error { + fn new_with_null_ptr() -> Self { + Self { + tag: -1, + kind: PaymentErrorKind { nil__: () }, + } + } +} +impl Default for wire_cst_payment_error { + fn default() -> Self { + Self::new_with_null_ptr() + } +} +impl NewWithNullPtr for wire_cst_prepare_receive_request { + fn new_with_null_ptr() -> Self { + Self { + payer_amount_sat: core::ptr::null_mut(), + receiver_amount_sat: core::ptr::null_mut(), + } + } +} +impl Default for wire_cst_prepare_receive_request { + fn default() -> Self { + Self::new_with_null_ptr() + } +} +impl NewWithNullPtr for wire_cst_prepare_receive_response { + fn new_with_null_ptr() -> Self { + Self { + pair_hash: core::ptr::null_mut(), + payer_amount_sat: Default::default(), + fees_sat: Default::default(), + } + } +} +impl Default for wire_cst_prepare_receive_response { + fn default() -> Self { + Self::new_with_null_ptr() + } +} +impl NewWithNullPtr for wire_cst_prepare_send_response { + fn new_with_null_ptr() -> Self { + Self { + id: core::ptr::null_mut(), + payer_amount_sat: Default::default(), + receiver_amount_sat: Default::default(), + total_fees: Default::default(), + funding_address: core::ptr::null_mut(), + invoice: core::ptr::null_mut(), + } + } +} +impl Default for wire_cst_prepare_send_response { + fn default() -> Self { + Self::new_with_null_ptr() + } +} +impl NewWithNullPtr for wire_cst_receive_payment_response { + fn new_with_null_ptr() -> Self { + Self { + id: core::ptr::null_mut(), + invoice: core::ptr::null_mut(), + } + } +} +impl Default for wire_cst_receive_payment_response { + fn default() -> Self { + Self::new_with_null_ptr() + } +} +impl NewWithNullPtr for wire_cst_send_payment_response { + fn new_with_null_ptr() -> Self { + Self { + txid: core::ptr::null_mut(), + } + } +} +impl Default for wire_cst_send_payment_response { + fn default() -> Self { + Self::new_with_null_ptr() + } +} +impl NewWithNullPtr for wire_cst_wallet_info { + fn new_with_null_ptr() -> Self { + Self { + balance_sat: Default::default(), + pubkey: core::ptr::null_mut(), + } + } +} +impl Default for wire_cst_wallet_info { + fn default() -> Self { + Self::new_with_null_ptr() + } +} + +#[no_mangle] +pub extern "C" fn frbgen_breez_liquid_wire_backup(port_: i64) { + wire_backup_impl(port_) +} + +#[no_mangle] +pub extern "C" fn frbgen_breez_liquid_wire_connect( + port_: i64, + mnemonic: *mut wire_cst_list_prim_u_8_strict, + data_dir: *mut wire_cst_list_prim_u_8_strict, + network: i32, +) { + wire_connect_impl(port_, mnemonic, data_dir, network) +} + +#[no_mangle] +pub extern "C" fn frbgen_breez_liquid_wire_empty_wallet_cache(port_: i64) { + wire_empty_wallet_cache_impl(port_) +} + +#[no_mangle] +pub extern "C" fn frbgen_breez_liquid_wire_get_info(port_: i64, with_scan: bool) { + wire_get_info_impl(port_, with_scan) +} + +#[no_mangle] +pub extern "C" fn frbgen_breez_liquid_wire_list_payments( + port_: i64, + with_scan: bool, + include_pending: bool, +) { + wire_list_payments_impl(port_, with_scan, include_pending) +} + +#[no_mangle] +pub extern "C" fn frbgen_breez_liquid_wire_prepare_receive_payment( + port_: i64, + req: *mut wire_cst_prepare_receive_request, +) { + wire_prepare_receive_payment_impl(port_, req) +} + +#[no_mangle] +pub extern "C" fn frbgen_breez_liquid_wire_prepare_send_payment( + port_: i64, + invoice: *mut wire_cst_list_prim_u_8_strict, +) { + wire_prepare_send_payment_impl(port_, invoice) +} + +#[no_mangle] +pub extern "C" fn frbgen_breez_liquid_wire_receive_payment( + port_: i64, + req: *mut wire_cst_prepare_receive_response, +) { + wire_receive_payment_impl(port_, req) +} + +#[no_mangle] +pub extern "C" fn frbgen_breez_liquid_wire_recover_funds(port_: i64, recovery: usize) { + wire_recover_funds_impl(port_, recovery) +} + +#[no_mangle] +pub extern "C" fn frbgen_breez_liquid_wire_restore( + port_: i64, + backup_path: *mut wire_cst_list_prim_u_8_strict, +) { + wire_restore_impl(port_, backup_path) +} + +#[no_mangle] +pub extern "C" fn frbgen_breez_liquid_wire_send_payment( + port_: i64, + req: *mut wire_cst_prepare_send_response, +) { + wire_send_payment_impl(port_, req) +} + +#[no_mangle] +pub extern "C" fn frbgen_breez_liquid_rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockLBtcReverseRecovery( + ptr: *const std::ffi::c_void, +) { + unsafe { + StdArc::>::increment_strong_count(ptr as _); + } +} + +#[no_mangle] +pub extern "C" fn frbgen_breez_liquid_rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockLBtcReverseRecovery( + ptr: *const std::ffi::c_void, +) { + unsafe { + StdArc::>::decrement_strong_count(ptr as _); + } +} + +#[no_mangle] +pub extern "C" fn frbgen_breez_liquid_cst_new_box_autoadd_prepare_receive_request( +) -> *mut wire_cst_prepare_receive_request { + flutter_rust_bridge::for_generated::new_leak_box_ptr( + wire_cst_prepare_receive_request::new_with_null_ptr(), + ) +} + +#[no_mangle] +pub extern "C" fn frbgen_breez_liquid_cst_new_box_autoadd_prepare_receive_response( +) -> *mut wire_cst_prepare_receive_response { + flutter_rust_bridge::for_generated::new_leak_box_ptr( + wire_cst_prepare_receive_response::new_with_null_ptr(), + ) +} + +#[no_mangle] +pub extern "C" fn frbgen_breez_liquid_cst_new_box_autoadd_prepare_send_response( +) -> *mut wire_cst_prepare_send_response { + flutter_rust_bridge::for_generated::new_leak_box_ptr( + wire_cst_prepare_send_response::new_with_null_ptr(), + ) +} + +#[no_mangle] +pub extern "C" fn frbgen_breez_liquid_cst_new_box_autoadd_u_32(value: u32) -> *mut u32 { + flutter_rust_bridge::for_generated::new_leak_box_ptr(value) +} + +#[no_mangle] +pub extern "C" fn frbgen_breez_liquid_cst_new_box_autoadd_u_64(value: u64) -> *mut u64 { + flutter_rust_bridge::for_generated::new_leak_box_ptr(value) +} + +#[no_mangle] +pub extern "C" fn frbgen_breez_liquid_cst_new_list_payment(len: i32) -> *mut wire_cst_list_payment { + let wrap = wire_cst_list_payment { + ptr: flutter_rust_bridge::for_generated::new_leak_vec_ptr( + ::new_with_null_ptr(), + len, + ), + len, + }; + flutter_rust_bridge::for_generated::new_leak_box_ptr(wrap) +} + +#[no_mangle] +pub extern "C" fn frbgen_breez_liquid_cst_new_list_prim_u_8_strict( + len: i32, +) -> *mut wire_cst_list_prim_u_8_strict { + let ans = wire_cst_list_prim_u_8_strict { + ptr: flutter_rust_bridge::for_generated::new_leak_vec_ptr(Default::default(), len), + len, + }; + flutter_rust_bridge::for_generated::new_leak_box_ptr(ans) +} + +#[repr(C)] +#[derive(Clone, Copy)] +pub struct wire_cst_list_payment { + ptr: *mut wire_cst_payment, + len: i32, +} +#[repr(C)] +#[derive(Clone, Copy)] +pub struct wire_cst_list_prim_u_8_strict { + ptr: *mut u8, + len: i32, +} +#[repr(C)] +#[derive(Clone, Copy)] +pub struct wire_cst_payment { + id: *mut wire_cst_list_prim_u_8_strict, + timestamp: *mut u32, + amount_sat: u64, + fees_sat: *mut u64, + payment_type: i32, + invoice: *mut wire_cst_list_prim_u_8_strict, +} +#[repr(C)] +#[derive(Clone, Copy)] +pub struct wire_cst_payment_error { + tag: i32, + kind: PaymentErrorKind, +} +#[repr(C)] +#[derive(Clone, Copy)] +pub union PaymentErrorKind { + Generic: wire_cst_PaymentError_Generic, + LwkError: wire_cst_PaymentError_LwkError, + SendError: wire_cst_PaymentError_SendError, + SignerError: wire_cst_PaymentError_SignerError, + nil__: (), +} +#[repr(C)] +#[derive(Clone, Copy)] +pub struct wire_cst_PaymentError_Generic { + err: *mut wire_cst_list_prim_u_8_strict, +} +#[repr(C)] +#[derive(Clone, Copy)] +pub struct wire_cst_PaymentError_LwkError { + err: *mut wire_cst_list_prim_u_8_strict, +} +#[repr(C)] +#[derive(Clone, Copy)] +pub struct wire_cst_PaymentError_SendError { + err: *mut wire_cst_list_prim_u_8_strict, +} +#[repr(C)] +#[derive(Clone, Copy)] +pub struct wire_cst_PaymentError_SignerError { + err: *mut wire_cst_list_prim_u_8_strict, +} +#[repr(C)] +#[derive(Clone, Copy)] +pub struct wire_cst_prepare_receive_request { + payer_amount_sat: *mut u64, + receiver_amount_sat: *mut u64, +} +#[repr(C)] +#[derive(Clone, Copy)] +pub struct wire_cst_prepare_receive_response { + pair_hash: *mut wire_cst_list_prim_u_8_strict, + payer_amount_sat: u64, + fees_sat: u64, +} +#[repr(C)] +#[derive(Clone, Copy)] +pub struct wire_cst_prepare_send_response { + id: *mut wire_cst_list_prim_u_8_strict, + payer_amount_sat: u64, + receiver_amount_sat: u64, + total_fees: u64, + funding_address: *mut wire_cst_list_prim_u_8_strict, + invoice: *mut wire_cst_list_prim_u_8_strict, +} +#[repr(C)] +#[derive(Clone, Copy)] +pub struct wire_cst_receive_payment_response { + id: *mut wire_cst_list_prim_u_8_strict, + invoice: *mut wire_cst_list_prim_u_8_strict, +} +#[repr(C)] +#[derive(Clone, Copy)] +pub struct wire_cst_send_payment_response { + txid: *mut wire_cst_list_prim_u_8_strict, +} +#[repr(C)] +#[derive(Clone, Copy)] +pub struct wire_cst_wallet_info { + balance_sat: u64, + pubkey: *mut wire_cst_list_prim_u_8_strict, +} diff --git a/lib/core/src/frb/bridge.rs b/lib/core/src/frb/bridge.rs index 8b13789..52304e2 100644 --- a/lib/core/src/frb/bridge.rs +++ b/lib/core/src/frb/bridge.rs @@ -1 +1,1124 @@ +// This file is automatically generated, so please do not edit it. +// Generated by `flutter_rust_bridge`@ 2.0.0-dev.32. +#![allow( + non_camel_case_types, + unused, + non_snake_case, + clippy::needless_return, + clippy::redundant_closure_call, + clippy::redundant_closure, + clippy::useless_conversion, + clippy::unit_arg, + clippy::unused_unit, + clippy::double_parens, + clippy::let_and_return, + clippy::too_many_arguments, + clippy::match_single_binding +)] + +// Section: imports + +use crate::bindings::*; +use flutter_rust_bridge::for_generated::byteorder::{NativeEndian, ReadBytesExt, WriteBytesExt}; +use flutter_rust_bridge::for_generated::transform_result_dco; +use flutter_rust_bridge::{Handler, IntoIntoDart}; + +// Section: boilerplate + +flutter_rust_bridge::frb_generated_boilerplate!( + default_stream_sink_codec = DcoCodec, + default_rust_opaque = RustOpaqueNom, + default_rust_auto_opaque = RustAutoOpaqueNom, +); +pub(crate) const FLUTTER_RUST_BRIDGE_CODEGEN_VERSION: &str = "2.0.0-dev.32"; +pub(crate) const FLUTTER_RUST_BRIDGE_CODEGEN_CONTENT_HASH: i32 = -1225779344; + +// Section: executor + +flutter_rust_bridge::frb_generated_default_handler!(); + +// Section: wire_funcs + +fn wire_backup_impl(port_: flutter_rust_bridge::for_generated::MessagePort) { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_normal::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "backup", + port: Some(port_), + mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal, + }, + move || move |context| transform_result_dco((move || crate::bindings::backup())()), + ) +} +fn wire_connect_impl( + port_: flutter_rust_bridge::for_generated::MessagePort, + mnemonic: impl CstDecode, + data_dir: impl CstDecode>, + network: impl CstDecode, +) { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_normal::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "connect", + port: Some(port_), + mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal, + }, + move || { + let api_mnemonic = mnemonic.cst_decode(); + let api_data_dir = data_dir.cst_decode(); + let api_network = network.cst_decode(); + move |context| { + transform_result_dco((move || { + crate::bindings::connect(api_mnemonic, api_data_dir, api_network) + })()) + } + }, + ) +} +fn wire_empty_wallet_cache_impl(port_: flutter_rust_bridge::for_generated::MessagePort) { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_normal::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "empty_wallet_cache", + port: Some(port_), + mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal, + }, + move || { + move |context| transform_result_dco((move || crate::bindings::empty_wallet_cache())()) + }, + ) +} +fn wire_get_info_impl( + port_: flutter_rust_bridge::for_generated::MessagePort, + with_scan: impl CstDecode, +) { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_normal::(flutter_rust_bridge::for_generated::TaskInfo{ debug_name: "get_info", port: Some(port_), mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal }, move || { let api_with_scan = with_scan.cst_decode(); move |context| { + transform_result_dco((move || { + crate::bindings::get_info(api_with_scan) + })()) + } }) +} +fn wire_list_payments_impl( + port_: flutter_rust_bridge::for_generated::MessagePort, + with_scan: impl CstDecode, + include_pending: impl CstDecode, +) { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_normal::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "list_payments", + port: Some(port_), + mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal, + }, + move || { + let api_with_scan = with_scan.cst_decode(); + let api_include_pending = include_pending.cst_decode(); + move |context| { + transform_result_dco((move || { + crate::bindings::list_payments(api_with_scan, api_include_pending) + })()) + } + }, + ) +} +fn wire_prepare_receive_payment_impl( + port_: flutter_rust_bridge::for_generated::MessagePort, + req: impl CstDecode, +) { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_normal::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "prepare_receive_payment", + port: Some(port_), + mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal, + }, + move || { + let api_req = req.cst_decode(); + move |context| { + transform_result_dco((move || crate::bindings::prepare_receive_payment(api_req))()) + } + }, + ) +} +fn wire_prepare_send_payment_impl( + port_: flutter_rust_bridge::for_generated::MessagePort, + invoice: impl CstDecode, +) { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_normal::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "prepare_send_payment", + port: Some(port_), + mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal, + }, + move || { + let api_invoice = invoice.cst_decode(); + move |context| { + transform_result_dco((move || crate::bindings::prepare_send_payment(api_invoice))()) + } + }, + ) +} +fn wire_receive_payment_impl( + port_: flutter_rust_bridge::for_generated::MessagePort, + req: impl CstDecode, +) { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_normal::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "receive_payment", + port: Some(port_), + mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal, + }, + move || { + let api_req = req.cst_decode(); + move |context| { + transform_result_dco((move || crate::bindings::receive_payment(api_req))()) + } + }, + ) +} +fn wire_recover_funds_impl( + port_: flutter_rust_bridge::for_generated::MessagePort, + recovery: impl CstDecode, +) { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_normal::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "recover_funds", + port: Some(port_), + mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal, + }, + move || { + let api_recovery = recovery.cst_decode(); + move |context| { + transform_result_dco((move || crate::bindings::recover_funds(api_recovery))()) + } + }, + ) +} +fn wire_restore_impl( + port_: flutter_rust_bridge::for_generated::MessagePort, + backup_path: impl CstDecode>, +) { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_normal::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "restore", + port: Some(port_), + mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal, + }, + move || { + let api_backup_path = backup_path.cst_decode(); + move |context| { + transform_result_dco((move || crate::bindings::restore(api_backup_path))()) + } + }, + ) +} +fn wire_send_payment_impl( + port_: flutter_rust_bridge::for_generated::MessagePort, + req: impl CstDecode, +) { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_normal::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "send_payment", + port: Some(port_), + mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal, + }, + move || { + let api_req = req.cst_decode(); + move |context| transform_result_dco((move || crate::bindings::send_payment(api_req))()) + }, + ) +} + +// Section: dart2rust + +impl CstDecode for bool { + // Codec=Cst (C-struct based), see doc to use other codecs + fn cst_decode(self) -> bool { + self + } +} +impl CstDecode for i32 { + // Codec=Cst (C-struct based), see doc to use other codecs + fn cst_decode(self) -> i32 { + self + } +} +impl CstDecode for i32 { + // Codec=Cst (C-struct based), see doc to use other codecs + fn cst_decode(self) -> crate::model::Network { + match self { + 0 => crate::model::Network::Liquid, + 1 => crate::model::Network::LiquidTestnet, + _ => unreachable!("Invalid variant for Network: {}", self), + } + } +} +impl CstDecode for i32 { + // Codec=Cst (C-struct based), see doc to use other codecs + fn cst_decode(self) -> crate::model::PaymentType { + match self { + 0 => crate::model::PaymentType::Sent, + 1 => crate::model::PaymentType::Received, + 2 => crate::model::PaymentType::PendingReceive, + 3 => crate::model::PaymentType::PendingSend, + _ => unreachable!("Invalid variant for PaymentType: {}", self), + } + } +} +impl CstDecode for u32 { + // Codec=Cst (C-struct based), see doc to use other codecs + fn cst_decode(self) -> u32 { + self + } +} +impl CstDecode for u64 { + // Codec=Cst (C-struct based), see doc to use other codecs + fn cst_decode(self) -> u64 { + self + } +} +impl CstDecode for u8 { + // Codec=Cst (C-struct based), see doc to use other codecs + fn cst_decode(self) -> u8 { + self + } +} +impl CstDecode for usize { + // Codec=Cst (C-struct based), see doc to use other codecs + fn cst_decode(self) -> usize { + self + } +} +impl SseDecode for flutter_rust_bridge::for_generated::anyhow::Error { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + unreachable!(""); + } +} + +impl SseDecode for LBtcReverseRecovery { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + let mut inner = , + >>::sse_decode(deserializer); + return inner.rust_auto_opaque_decode_owned(); + } +} + +impl SseDecode + for RustOpaqueNom> +{ + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + let mut inner = ::sse_decode(deserializer); + return unsafe { decode_rust_opaque_nom(inner) }; + } +} + +impl SseDecode for String { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + let mut inner = >::sse_decode(deserializer); + return String::from_utf8(inner).unwrap(); + } +} + +impl SseDecode for bool { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + deserializer.cursor.read_u8().unwrap() != 0 + } +} + +impl SseDecode for i32 { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + deserializer.cursor.read_i32::().unwrap() + } +} + +impl SseDecode for Vec { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + let mut len_ = ::sse_decode(deserializer); + let mut ans_ = vec![]; + for idx_ in 0..len_ { + ans_.push(::sse_decode(deserializer)); + } + return ans_; + } +} + +impl SseDecode for Vec { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + let mut len_ = ::sse_decode(deserializer); + let mut ans_ = vec![]; + for idx_ in 0..len_ { + ans_.push(::sse_decode(deserializer)); + } + return ans_; + } +} + +impl SseDecode for crate::model::Network { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + let mut inner = ::sse_decode(deserializer); + return match inner { + 0 => crate::model::Network::Liquid, + 1 => crate::model::Network::LiquidTestnet, + _ => unreachable!("Invalid variant for Network: {}", inner), + }; + } +} + +impl SseDecode for Option { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + if (::sse_decode(deserializer)) { + return Some(::sse_decode(deserializer)); + } else { + return None; + } + } +} + +impl SseDecode for Option { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + if (::sse_decode(deserializer)) { + return Some(::sse_decode(deserializer)); + } else { + return None; + } + } +} + +impl SseDecode for Option { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + if (::sse_decode(deserializer)) { + return Some(::sse_decode(deserializer)); + } else { + return None; + } + } +} + +impl SseDecode for crate::model::Payment { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + let mut var_id = >::sse_decode(deserializer); + let mut var_timestamp = >::sse_decode(deserializer); + let mut var_amountSat = ::sse_decode(deserializer); + let mut var_feesSat = >::sse_decode(deserializer); + let mut var_paymentType = ::sse_decode(deserializer); + let mut var_invoice = >::sse_decode(deserializer); + return crate::model::Payment { + id: var_id, + timestamp: var_timestamp, + amount_sat: var_amountSat, + fees_sat: var_feesSat, + payment_type: var_paymentType, + invoice: var_invoice, + }; + } +} + +impl SseDecode for crate::error::PaymentError { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + let mut tag_ = ::sse_decode(deserializer); + match tag_ { + 0 => { + return crate::error::PaymentError::AmountOutOfRange; + } + 1 => { + return crate::error::PaymentError::AlreadyClaimed; + } + 2 => { + let mut var_err = ::sse_decode(deserializer); + return crate::error::PaymentError::Generic { err: var_err }; + } + 3 => { + return crate::error::PaymentError::InvalidInvoice; + } + 4 => { + return crate::error::PaymentError::InvalidPreimage; + } + 5 => { + let mut var_err = ::sse_decode(deserializer); + return crate::error::PaymentError::LwkError { err: var_err }; + } + 6 => { + return crate::error::PaymentError::PairsNotFound; + } + 7 => { + return crate::error::PaymentError::PersistError; + } + 8 => { + let mut var_err = ::sse_decode(deserializer); + return crate::error::PaymentError::SendError { err: var_err }; + } + 9 => { + let mut var_err = ::sse_decode(deserializer); + return crate::error::PaymentError::SignerError { err: var_err }; + } + _ => { + unimplemented!(""); + } + } + } +} + +impl SseDecode for crate::model::PaymentType { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + let mut inner = ::sse_decode(deserializer); + return match inner { + 0 => crate::model::PaymentType::Sent, + 1 => crate::model::PaymentType::Received, + 2 => crate::model::PaymentType::PendingReceive, + 3 => crate::model::PaymentType::PendingSend, + _ => unreachable!("Invalid variant for PaymentType: {}", inner), + }; + } +} + +impl SseDecode for crate::model::PrepareReceiveRequest { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + let mut var_payerAmountSat = >::sse_decode(deserializer); + let mut var_receiverAmountSat = >::sse_decode(deserializer); + return crate::model::PrepareReceiveRequest { + payer_amount_sat: var_payerAmountSat, + receiver_amount_sat: var_receiverAmountSat, + }; + } +} + +impl SseDecode for crate::model::PrepareReceiveResponse { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + let mut var_pairHash = ::sse_decode(deserializer); + let mut var_payerAmountSat = ::sse_decode(deserializer); + let mut var_feesSat = ::sse_decode(deserializer); + return crate::model::PrepareReceiveResponse { + pair_hash: var_pairHash, + payer_amount_sat: var_payerAmountSat, + fees_sat: var_feesSat, + }; + } +} + +impl SseDecode for crate::model::PrepareSendResponse { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + let mut var_id = ::sse_decode(deserializer); + let mut var_payerAmountSat = ::sse_decode(deserializer); + let mut var_receiverAmountSat = ::sse_decode(deserializer); + let mut var_totalFees = ::sse_decode(deserializer); + let mut var_fundingAddress = ::sse_decode(deserializer); + let mut var_invoice = ::sse_decode(deserializer); + return crate::model::PrepareSendResponse { + id: var_id, + payer_amount_sat: var_payerAmountSat, + receiver_amount_sat: var_receiverAmountSat, + total_fees: var_totalFees, + funding_address: var_fundingAddress, + invoice: var_invoice, + }; + } +} + +impl SseDecode for crate::model::ReceivePaymentResponse { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + let mut var_id = ::sse_decode(deserializer); + let mut var_invoice = ::sse_decode(deserializer); + return crate::model::ReceivePaymentResponse { + id: var_id, + invoice: var_invoice, + }; + } +} + +impl SseDecode for crate::model::SendPaymentResponse { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + let mut var_txid = ::sse_decode(deserializer); + return crate::model::SendPaymentResponse { txid: var_txid }; + } +} + +impl SseDecode for u32 { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + deserializer.cursor.read_u32::().unwrap() + } +} + +impl SseDecode for u64 { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + deserializer.cursor.read_u64::().unwrap() + } +} + +impl SseDecode for u8 { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + deserializer.cursor.read_u8().unwrap() + } +} + +impl SseDecode for () { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self {} +} + +impl SseDecode for usize { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + deserializer.cursor.read_u64::().unwrap() as _ + } +} + +impl SseDecode for crate::model::WalletInfo { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + let mut var_balanceSat = ::sse_decode(deserializer); + let mut var_pubkey = ::sse_decode(deserializer); + return crate::model::WalletInfo { + balance_sat: var_balanceSat, + pubkey: var_pubkey, + }; + } +} + +fn pde_ffi_dispatcher_primary_impl( + func_id: i32, + port: flutter_rust_bridge::for_generated::MessagePort, + ptr: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len: i32, + data_len: i32, +) { + // Codec=Pde (Serialization + dispatch), see doc to use other codecs + match func_id { + _ => unreachable!(), + } +} + +fn pde_ffi_dispatcher_sync_impl( + func_id: i32, + ptr: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len: i32, + data_len: i32, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartSse { + // Codec=Pde (Serialization + dispatch), see doc to use other codecs + match func_id { + _ => unreachable!(), + } +} + +// Section: rust2dart + +// Codec=Dco (DartCObject based), see doc to use other codecs +impl flutter_rust_bridge::IntoDart for FrbWrapper { + fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi { + flutter_rust_bridge::for_generated::rust_auto_opaque_encode::<_, StdArc<_>>(self.0) + .into_dart() + } +} +impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive + for FrbWrapper +{ +} + +impl flutter_rust_bridge::IntoIntoDart> for LBtcReverseRecovery { + fn into_into_dart(self) -> FrbWrapper { + self.into() + } +} + +// Codec=Dco (DartCObject based), see doc to use other codecs +impl flutter_rust_bridge::IntoDart for crate::model::Network { + fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi { + match self { + Self::Liquid => 0.into_dart(), + Self::LiquidTestnet => 1.into_dart(), + } + } +} +impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive for crate::model::Network {} +impl flutter_rust_bridge::IntoIntoDart for crate::model::Network { + fn into_into_dart(self) -> crate::model::Network { + self + } +} +// Codec=Dco (DartCObject based), see doc to use other codecs +impl flutter_rust_bridge::IntoDart for crate::model::Payment { + fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi { + [ + self.id.into_into_dart().into_dart(), + self.timestamp.into_into_dart().into_dart(), + self.amount_sat.into_into_dart().into_dart(), + self.fees_sat.into_into_dart().into_dart(), + self.payment_type.into_into_dart().into_dart(), + self.invoice.into_into_dart().into_dart(), + ] + .into_dart() + } +} +impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive for crate::model::Payment {} +impl flutter_rust_bridge::IntoIntoDart for crate::model::Payment { + fn into_into_dart(self) -> crate::model::Payment { + self + } +} +// Codec=Dco (DartCObject based), see doc to use other codecs +impl flutter_rust_bridge::IntoDart for crate::error::PaymentError { + fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi { + match self { + crate::error::PaymentError::AmountOutOfRange => [0.into_dart()].into_dart(), + crate::error::PaymentError::AlreadyClaimed => [1.into_dart()].into_dart(), + crate::error::PaymentError::Generic { err } => { + [2.into_dart(), err.into_into_dart().into_dart()].into_dart() + } + crate::error::PaymentError::InvalidInvoice => [3.into_dart()].into_dart(), + crate::error::PaymentError::InvalidPreimage => [4.into_dart()].into_dart(), + crate::error::PaymentError::LwkError { err } => { + [5.into_dart(), err.into_into_dart().into_dart()].into_dart() + } + crate::error::PaymentError::PairsNotFound => [6.into_dart()].into_dart(), + crate::error::PaymentError::PersistError => [7.into_dart()].into_dart(), + crate::error::PaymentError::SendError { err } => { + [8.into_dart(), err.into_into_dart().into_dart()].into_dart() + } + crate::error::PaymentError::SignerError { err } => { + [9.into_dart(), err.into_into_dart().into_dart()].into_dart() + } + } + } +} +impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive for crate::error::PaymentError {} +impl flutter_rust_bridge::IntoIntoDart for crate::error::PaymentError { + fn into_into_dart(self) -> crate::error::PaymentError { + self + } +} +// Codec=Dco (DartCObject based), see doc to use other codecs +impl flutter_rust_bridge::IntoDart for crate::model::PaymentType { + fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi { + match self { + Self::Sent => 0.into_dart(), + Self::Received => 1.into_dart(), + Self::PendingReceive => 2.into_dart(), + Self::PendingSend => 3.into_dart(), + } + } +} +impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive for crate::model::PaymentType {} +impl flutter_rust_bridge::IntoIntoDart for crate::model::PaymentType { + fn into_into_dart(self) -> crate::model::PaymentType { + self + } +} +// Codec=Dco (DartCObject based), see doc to use other codecs +impl flutter_rust_bridge::IntoDart for crate::model::PrepareReceiveRequest { + fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi { + [ + self.payer_amount_sat.into_into_dart().into_dart(), + self.receiver_amount_sat.into_into_dart().into_dart(), + ] + .into_dart() + } +} +impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive + for crate::model::PrepareReceiveRequest +{ +} +impl flutter_rust_bridge::IntoIntoDart + for crate::model::PrepareReceiveRequest +{ + fn into_into_dart(self) -> crate::model::PrepareReceiveRequest { + self + } +} +// Codec=Dco (DartCObject based), see doc to use other codecs +impl flutter_rust_bridge::IntoDart for crate::model::PrepareReceiveResponse { + fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi { + [ + self.pair_hash.into_into_dart().into_dart(), + self.payer_amount_sat.into_into_dart().into_dart(), + self.fees_sat.into_into_dart().into_dart(), + ] + .into_dart() + } +} +impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive + for crate::model::PrepareReceiveResponse +{ +} +impl flutter_rust_bridge::IntoIntoDart + for crate::model::PrepareReceiveResponse +{ + fn into_into_dart(self) -> crate::model::PrepareReceiveResponse { + self + } +} +// Codec=Dco (DartCObject based), see doc to use other codecs +impl flutter_rust_bridge::IntoDart for crate::model::PrepareSendResponse { + fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi { + [ + self.id.into_into_dart().into_dart(), + self.payer_amount_sat.into_into_dart().into_dart(), + self.receiver_amount_sat.into_into_dart().into_dart(), + self.total_fees.into_into_dart().into_dart(), + self.funding_address.into_into_dart().into_dart(), + self.invoice.into_into_dart().into_dart(), + ] + .into_dart() + } +} +impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive + for crate::model::PrepareSendResponse +{ +} +impl flutter_rust_bridge::IntoIntoDart + for crate::model::PrepareSendResponse +{ + fn into_into_dart(self) -> crate::model::PrepareSendResponse { + self + } +} +// Codec=Dco (DartCObject based), see doc to use other codecs +impl flutter_rust_bridge::IntoDart for crate::model::ReceivePaymentResponse { + fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi { + [ + self.id.into_into_dart().into_dart(), + self.invoice.into_into_dart().into_dart(), + ] + .into_dart() + } +} +impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive + for crate::model::ReceivePaymentResponse +{ +} +impl flutter_rust_bridge::IntoIntoDart + for crate::model::ReceivePaymentResponse +{ + fn into_into_dart(self) -> crate::model::ReceivePaymentResponse { + self + } +} +// Codec=Dco (DartCObject based), see doc to use other codecs +impl flutter_rust_bridge::IntoDart for crate::model::SendPaymentResponse { + fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi { + [self.txid.into_into_dart().into_dart()].into_dart() + } +} +impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive + for crate::model::SendPaymentResponse +{ +} +impl flutter_rust_bridge::IntoIntoDart + for crate::model::SendPaymentResponse +{ + fn into_into_dart(self) -> crate::model::SendPaymentResponse { + self + } +} +// Codec=Dco (DartCObject based), see doc to use other codecs +impl flutter_rust_bridge::IntoDart for crate::model::WalletInfo { + fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi { + [ + self.balance_sat.into_into_dart().into_dart(), + self.pubkey.into_into_dart().into_dart(), + ] + .into_dart() + } +} +impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive for crate::model::WalletInfo {} +impl flutter_rust_bridge::IntoIntoDart for crate::model::WalletInfo { + fn into_into_dart(self) -> crate::model::WalletInfo { + self + } +} + +impl SseEncode for flutter_rust_bridge::for_generated::anyhow::Error { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + ::sse_encode(format!("{:?}", self), serializer); + } +} + +impl SseEncode for LBtcReverseRecovery { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + >>::sse_encode(flutter_rust_bridge::for_generated::rust_auto_opaque_encode::<_, StdArc<_>>(self), serializer); + } +} + +impl SseEncode + for RustOpaqueNom> +{ + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + let (ptr, size) = self.sse_encode_raw(); + ::sse_encode(ptr, serializer); + ::sse_encode(size, serializer); + } +} + +impl SseEncode for String { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + >::sse_encode(self.into_bytes(), serializer); + } +} + +impl SseEncode for bool { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + serializer.cursor.write_u8(self as _).unwrap(); + } +} + +impl SseEncode for i32 { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + serializer.cursor.write_i32::(self).unwrap(); + } +} + +impl SseEncode for Vec { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + ::sse_encode(self.len() as _, serializer); + for item in self { + ::sse_encode(item, serializer); + } + } +} + +impl SseEncode for Vec { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + ::sse_encode(self.len() as _, serializer); + for item in self { + ::sse_encode(item, serializer); + } + } +} + +impl SseEncode for crate::model::Network { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + ::sse_encode( + match self { + crate::model::Network::Liquid => 0, + crate::model::Network::LiquidTestnet => 1, + _ => { + unimplemented!(""); + } + }, + serializer, + ); + } +} + +impl SseEncode for Option { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + ::sse_encode(self.is_some(), serializer); + if let Some(value) = self { + ::sse_encode(value, serializer); + } + } +} + +impl SseEncode for Option { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + ::sse_encode(self.is_some(), serializer); + if let Some(value) = self { + ::sse_encode(value, serializer); + } + } +} + +impl SseEncode for Option { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + ::sse_encode(self.is_some(), serializer); + if let Some(value) = self { + ::sse_encode(value, serializer); + } + } +} + +impl SseEncode for crate::model::Payment { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + >::sse_encode(self.id, serializer); + >::sse_encode(self.timestamp, serializer); + ::sse_encode(self.amount_sat, serializer); + >::sse_encode(self.fees_sat, serializer); + ::sse_encode(self.payment_type, serializer); + >::sse_encode(self.invoice, serializer); + } +} + +impl SseEncode for crate::error::PaymentError { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + match self { + crate::error::PaymentError::AmountOutOfRange => { + ::sse_encode(0, serializer); + } + crate::error::PaymentError::AlreadyClaimed => { + ::sse_encode(1, serializer); + } + crate::error::PaymentError::Generic { err } => { + ::sse_encode(2, serializer); + ::sse_encode(err, serializer); + } + crate::error::PaymentError::InvalidInvoice => { + ::sse_encode(3, serializer); + } + crate::error::PaymentError::InvalidPreimage => { + ::sse_encode(4, serializer); + } + crate::error::PaymentError::LwkError { err } => { + ::sse_encode(5, serializer); + ::sse_encode(err, serializer); + } + crate::error::PaymentError::PairsNotFound => { + ::sse_encode(6, serializer); + } + crate::error::PaymentError::PersistError => { + ::sse_encode(7, serializer); + } + crate::error::PaymentError::SendError { err } => { + ::sse_encode(8, serializer); + ::sse_encode(err, serializer); + } + crate::error::PaymentError::SignerError { err } => { + ::sse_encode(9, serializer); + ::sse_encode(err, serializer); + } + } + } +} + +impl SseEncode for crate::model::PaymentType { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + ::sse_encode( + match self { + crate::model::PaymentType::Sent => 0, + crate::model::PaymentType::Received => 1, + crate::model::PaymentType::PendingReceive => 2, + crate::model::PaymentType::PendingSend => 3, + _ => { + unimplemented!(""); + } + }, + serializer, + ); + } +} + +impl SseEncode for crate::model::PrepareReceiveRequest { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + >::sse_encode(self.payer_amount_sat, serializer); + >::sse_encode(self.receiver_amount_sat, serializer); + } +} + +impl SseEncode for crate::model::PrepareReceiveResponse { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + ::sse_encode(self.pair_hash, serializer); + ::sse_encode(self.payer_amount_sat, serializer); + ::sse_encode(self.fees_sat, serializer); + } +} + +impl SseEncode for crate::model::PrepareSendResponse { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + ::sse_encode(self.id, serializer); + ::sse_encode(self.payer_amount_sat, serializer); + ::sse_encode(self.receiver_amount_sat, serializer); + ::sse_encode(self.total_fees, serializer); + ::sse_encode(self.funding_address, serializer); + ::sse_encode(self.invoice, serializer); + } +} + +impl SseEncode for crate::model::ReceivePaymentResponse { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + ::sse_encode(self.id, serializer); + ::sse_encode(self.invoice, serializer); + } +} + +impl SseEncode for crate::model::SendPaymentResponse { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + ::sse_encode(self.txid, serializer); + } +} + +impl SseEncode for u32 { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + serializer.cursor.write_u32::(self).unwrap(); + } +} + +impl SseEncode for u64 { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + serializer.cursor.write_u64::(self).unwrap(); + } +} + +impl SseEncode for u8 { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + serializer.cursor.write_u8(self).unwrap(); + } +} + +impl SseEncode for () { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) {} +} + +impl SseEncode for usize { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + serializer + .cursor + .write_u64::(self as _) + .unwrap(); + } +} + +impl SseEncode for crate::model::WalletInfo { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + ::sse_encode(self.balance_sat, serializer); + ::sse_encode(self.pubkey, serializer); + } +} + +#[cfg(not(target_family = "wasm"))] +#[path = "bridge.io.rs"] +mod io; +#[cfg(not(target_family = "wasm"))] +pub use io::*; diff --git a/lib/ls-sdk-flutter/flutter_rust_bridge.yml b/lib/ls-sdk-flutter/flutter_rust_bridge.yml index d0c4113..82e5f3e 100644 --- a/lib/ls-sdk-flutter/flutter_rust_bridge.yml +++ b/lib/ls-sdk-flutter/flutter_rust_bridge.yml @@ -4,6 +4,6 @@ rust_output: ../ls-sdk-core/src/frb/bridge.rs c_output: ls_sdk/include/ls_sdk.h duplicated_c_output: [packages/flutter_breez_liquid/macos/Classes/ls_sdk.h, packages/flutter_breez_liquid/ios/Classes/ls_sdk.h] web: false -full_dep: false +full_dep: true add_mod_to_lib: false deps_check: false \ No newline at end of file diff --git a/lib/ls-sdk-flutter/ls_sdk/include/ls_sdk.h b/lib/ls-sdk-flutter/ls_sdk/include/ls_sdk.h new file mode 100644 index 0000000..d59f50a --- /dev/null +++ b/lib/ls-sdk-flutter/ls_sdk/include/ls_sdk.h @@ -0,0 +1,175 @@ +#include +#include +#include +// EXTRA BEGIN +typedef struct DartCObject *WireSyncRust2DartDco; +typedef struct WireSyncRust2DartSse { + uint8_t *ptr; + int32_t len; +} WireSyncRust2DartSse; + +typedef int64_t DartPort; +typedef bool (*DartPostCObjectFnType)(DartPort port_id, void *message); +void store_dart_post_cobject(DartPostCObjectFnType ptr); +// EXTRA END +typedef struct _Dart_Handle* Dart_Handle; + +/** + * Claim tx feerate for Receive, in sats per vbyte. + * Since the Liquid blocks are consistently empty for now, we hardcode the minimum feerate. + */ +#define LIQUID_CLAIM_TX_FEERATE 0.1 + +typedef struct wire_cst_list_prim_u_8_strict { + uint8_t *ptr; + int32_t len; +} wire_cst_list_prim_u_8_strict; + +typedef struct wire_cst_prepare_receive_request { + uint64_t *payer_amount_sat; + uint64_t *receiver_amount_sat; +} wire_cst_prepare_receive_request; + +typedef struct wire_cst_prepare_receive_response { + struct wire_cst_list_prim_u_8_strict *pair_hash; + uint64_t payer_amount_sat; + uint64_t fees_sat; +} wire_cst_prepare_receive_response; + +typedef struct wire_cst_prepare_send_response { + struct wire_cst_list_prim_u_8_strict *id; + uint64_t payer_amount_sat; + uint64_t receiver_amount_sat; + uint64_t total_fees; + struct wire_cst_list_prim_u_8_strict *funding_address; + struct wire_cst_list_prim_u_8_strict *invoice; +} wire_cst_prepare_send_response; + +typedef struct wire_cst_payment { + struct wire_cst_list_prim_u_8_strict *id; + uint32_t *timestamp; + uint64_t amount_sat; + uint64_t *fees_sat; + int32_t payment_type; + struct wire_cst_list_prim_u_8_strict *invoice; +} wire_cst_payment; + +typedef struct wire_cst_list_payment { + struct wire_cst_payment *ptr; + int32_t len; +} wire_cst_list_payment; + +typedef struct wire_cst_PaymentError_Generic { + struct wire_cst_list_prim_u_8_strict *err; +} wire_cst_PaymentError_Generic; + +typedef struct wire_cst_PaymentError_LwkError { + struct wire_cst_list_prim_u_8_strict *err; +} wire_cst_PaymentError_LwkError; + +typedef struct wire_cst_PaymentError_SendError { + struct wire_cst_list_prim_u_8_strict *err; +} wire_cst_PaymentError_SendError; + +typedef struct wire_cst_PaymentError_SignerError { + struct wire_cst_list_prim_u_8_strict *err; +} wire_cst_PaymentError_SignerError; + +typedef union PaymentErrorKind { + struct wire_cst_PaymentError_Generic Generic; + struct wire_cst_PaymentError_LwkError LwkError; + struct wire_cst_PaymentError_SendError SendError; + struct wire_cst_PaymentError_SignerError SignerError; +} PaymentErrorKind; + +typedef struct wire_cst_payment_error { + int32_t tag; + union PaymentErrorKind kind; +} wire_cst_payment_error; + +typedef struct wire_cst_receive_payment_response { + struct wire_cst_list_prim_u_8_strict *id; + struct wire_cst_list_prim_u_8_strict *invoice; +} wire_cst_receive_payment_response; + +typedef struct wire_cst_send_payment_response { + struct wire_cst_list_prim_u_8_strict *txid; +} wire_cst_send_payment_response; + +typedef struct wire_cst_wallet_info { + uint64_t balance_sat; + struct wire_cst_list_prim_u_8_strict *pubkey; +} wire_cst_wallet_info; + +void frbgen_breez_liquid_wire_backup(int64_t port_); + +void frbgen_breez_liquid_wire_connect(int64_t port_, + struct wire_cst_list_prim_u_8_strict *mnemonic, + struct wire_cst_list_prim_u_8_strict *data_dir, + int32_t network); + +void frbgen_breez_liquid_wire_empty_wallet_cache(int64_t port_); + +void frbgen_breez_liquid_wire_get_info(int64_t port_, bool with_scan); + +void frbgen_breez_liquid_wire_list_payments(int64_t port_, bool with_scan, bool include_pending); + +void frbgen_breez_liquid_wire_prepare_receive_payment(int64_t port_, + struct wire_cst_prepare_receive_request *req); + +void frbgen_breez_liquid_wire_prepare_send_payment(int64_t port_, + struct wire_cst_list_prim_u_8_strict *invoice); + +void frbgen_breez_liquid_wire_receive_payment(int64_t port_, + struct wire_cst_prepare_receive_response *req); + +void frbgen_breez_liquid_wire_recover_funds(int64_t port_, uintptr_t recovery); + +void frbgen_breez_liquid_wire_restore(int64_t port_, + struct wire_cst_list_prim_u_8_strict *backup_path); + +void frbgen_breez_liquid_wire_send_payment(int64_t port_, + struct wire_cst_prepare_send_response *req); + +void frbgen_breez_liquid_rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockLBtcReverseRecovery(const void *ptr); + +void frbgen_breez_liquid_rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockLBtcReverseRecovery(const void *ptr); + +struct wire_cst_prepare_receive_request *frbgen_breez_liquid_cst_new_box_autoadd_prepare_receive_request(void); + +struct wire_cst_prepare_receive_response *frbgen_breez_liquid_cst_new_box_autoadd_prepare_receive_response(void); + +struct wire_cst_prepare_send_response *frbgen_breez_liquid_cst_new_box_autoadd_prepare_send_response(void); + +uint32_t *frbgen_breez_liquid_cst_new_box_autoadd_u_32(uint32_t value); + +uint64_t *frbgen_breez_liquid_cst_new_box_autoadd_u_64(uint64_t value); + +struct wire_cst_list_payment *frbgen_breez_liquid_cst_new_list_payment(int32_t len); + +struct wire_cst_list_prim_u_8_strict *frbgen_breez_liquid_cst_new_list_prim_u_8_strict(int32_t len); +static int64_t dummy_method_to_enforce_bundling(void) { + int64_t dummy_var = 0; + dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_prepare_receive_request); + dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_prepare_receive_response); + dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_prepare_send_response); + dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_u_32); + dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_u_64); + dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_list_payment); + dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_list_prim_u_8_strict); + dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockLBtcReverseRecovery); + dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockLBtcReverseRecovery); + dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_wire_backup); + dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_wire_connect); + dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_wire_empty_wallet_cache); + dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_wire_get_info); + dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_wire_list_payments); + dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_wire_prepare_receive_payment); + dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_wire_prepare_send_payment); + dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_wire_receive_payment); + dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_wire_recover_funds); + dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_wire_restore); + dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_wire_send_payment); + dummy_var ^= ((int64_t) (void*) store_dart_post_cobject); + return dummy_var; +} diff --git a/lib/ls-sdk-flutter/packages/breez_liquid/lib/src/bindings.dart b/lib/ls-sdk-flutter/packages/breez_liquid/lib/src/bindings.dart new file mode 100644 index 0000000..075090e --- /dev/null +++ b/lib/ls-sdk-flutter/packages/breez_liquid/lib/src/bindings.dart @@ -0,0 +1,72 @@ +// This file is automatically generated, so please do not edit it. +// Generated by `flutter_rust_bridge`@ 2.0.0-dev.32. + +// ignore_for_file: invalid_use_of_internal_member, unused_import, unnecessary_import + +import 'error.dart'; +import 'frb_generated.dart'; +import 'model.dart'; +import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart'; + +Future connect( + {required String mnemonic, + String? dataDir, + required Network network, + dynamic hint}) => + RustLib.instance.api.connect( + mnemonic: mnemonic, dataDir: dataDir, network: network, hint: hint); + +Future getInfo({required bool withScan, dynamic hint}) => + RustLib.instance.api.getInfo(withScan: withScan, hint: hint); + +Future prepareSendPayment( + {required String invoice, dynamic hint}) => + RustLib.instance.api.prepareSendPayment(invoice: invoice, hint: hint); + +Future sendPayment( + {required PrepareSendResponse req, dynamic hint}) => + RustLib.instance.api.sendPayment(req: req, hint: hint); + +Future prepareReceivePayment( + {required PrepareReceiveRequest req, dynamic hint}) => + RustLib.instance.api.prepareReceivePayment(req: req, hint: hint); + +Future receivePayment( + {required PrepareReceiveResponse req, dynamic hint}) => + RustLib.instance.api.receivePayment(req: req, hint: hint); + +Future> listPayments( + {required bool withScan, required bool includePending, dynamic hint}) => + RustLib.instance.api.listPayments( + withScan: withScan, includePending: includePending, hint: hint); + +Future recoverFunds( + {required LBtcReverseRecovery recovery, dynamic hint}) => + RustLib.instance.api.recoverFunds(recovery: recovery, hint: hint); + +Future emptyWalletCache({dynamic hint}) => + RustLib.instance.api.emptyWalletCache(hint: hint); + +Future backup({dynamic hint}) => RustLib.instance.api.backup(hint: hint); + +Future restore({String? backupPath, dynamic hint}) => + RustLib.instance.api.restore(backupPath: backupPath, hint: hint); + +// Rust type: RustOpaqueNom> +@sealed +class LBtcReverseRecovery extends RustOpaque { + LBtcReverseRecovery.dcoDecode(List wire) + : super.dcoDecode(wire, _kStaticData); + + LBtcReverseRecovery.sseDecode(int ptr, int externalSizeOnNative) + : super.sseDecode(ptr, externalSizeOnNative, _kStaticData); + + static final _kStaticData = RustArcStaticData( + rustArcIncrementStrongCount: RustLib + .instance.api.rust_arc_increment_strong_count_LBtcReverseRecovery, + rustArcDecrementStrongCount: RustLib + .instance.api.rust_arc_decrement_strong_count_LBtcReverseRecovery, + rustArcDecrementStrongCountPtr: RustLib + .instance.api.rust_arc_decrement_strong_count_LBtcReverseRecoveryPtr, + ); +} diff --git a/lib/ls-sdk-flutter/packages/breez_liquid/lib/src/error.dart b/lib/ls-sdk-flutter/packages/breez_liquid/lib/src/error.dart new file mode 100644 index 0000000..e1cbea9 --- /dev/null +++ b/lib/ls-sdk-flutter/packages/breez_liquid/lib/src/error.dart @@ -0,0 +1,33 @@ +// This file is automatically generated, so please do not edit it. +// Generated by `flutter_rust_bridge`@ 2.0.0-dev.32. + +// ignore_for_file: invalid_use_of_internal_member, unused_import, unnecessary_import + +import 'frb_generated.dart'; +import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart'; +import 'package:freezed_annotation/freezed_annotation.dart' hide protected; +part 'error.freezed.dart'; + +@freezed +sealed class PaymentError with _$PaymentError implements FrbException { + const PaymentError._(); + + const factory PaymentError.amountOutOfRange() = PaymentError_AmountOutOfRange; + const factory PaymentError.alreadyClaimed() = PaymentError_AlreadyClaimed; + const factory PaymentError.generic({ + required String err, + }) = PaymentError_Generic; + const factory PaymentError.invalidInvoice() = PaymentError_InvalidInvoice; + const factory PaymentError.invalidPreimage() = PaymentError_InvalidPreimage; + const factory PaymentError.lwkError({ + required String err, + }) = PaymentError_LwkError; + const factory PaymentError.pairsNotFound() = PaymentError_PairsNotFound; + const factory PaymentError.persistError() = PaymentError_PersistError; + const factory PaymentError.sendError({ + required String err, + }) = PaymentError_SendError; + const factory PaymentError.signerError({ + required String err, + }) = PaymentError_SignerError; +} diff --git a/lib/ls-sdk-flutter/packages/breez_liquid/lib/src/error.freezed.dart b/lib/ls-sdk-flutter/packages/breez_liquid/lib/src/error.freezed.dart new file mode 100644 index 0000000..a11ce68 --- /dev/null +++ b/lib/ls-sdk-flutter/packages/breez_liquid/lib/src/error.freezed.dart @@ -0,0 +1,608 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'error.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); + +/// @nodoc +mixin _$PaymentError {} + +/// @nodoc +abstract class $PaymentErrorCopyWith<$Res> { + factory $PaymentErrorCopyWith( + PaymentError value, $Res Function(PaymentError) then) = + _$PaymentErrorCopyWithImpl<$Res, PaymentError>; +} + +/// @nodoc +class _$PaymentErrorCopyWithImpl<$Res, $Val extends PaymentError> + implements $PaymentErrorCopyWith<$Res> { + _$PaymentErrorCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; +} + +/// @nodoc +abstract class _$$PaymentError_AmountOutOfRangeImplCopyWith<$Res> { + factory _$$PaymentError_AmountOutOfRangeImplCopyWith( + _$PaymentError_AmountOutOfRangeImpl value, + $Res Function(_$PaymentError_AmountOutOfRangeImpl) then) = + __$$PaymentError_AmountOutOfRangeImplCopyWithImpl<$Res>; +} + +/// @nodoc +class __$$PaymentError_AmountOutOfRangeImplCopyWithImpl<$Res> + extends _$PaymentErrorCopyWithImpl<$Res, + _$PaymentError_AmountOutOfRangeImpl> + implements _$$PaymentError_AmountOutOfRangeImplCopyWith<$Res> { + __$$PaymentError_AmountOutOfRangeImplCopyWithImpl( + _$PaymentError_AmountOutOfRangeImpl _value, + $Res Function(_$PaymentError_AmountOutOfRangeImpl) _then) + : super(_value, _then); +} + +/// @nodoc + +class _$PaymentError_AmountOutOfRangeImpl + extends PaymentError_AmountOutOfRange { + const _$PaymentError_AmountOutOfRangeImpl() : super._(); + + @override + String toString() { + return 'PaymentError.amountOutOfRange()'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$PaymentError_AmountOutOfRangeImpl); + } + + @override + int get hashCode => runtimeType.hashCode; +} + +abstract class PaymentError_AmountOutOfRange extends PaymentError { + const factory PaymentError_AmountOutOfRange() = + _$PaymentError_AmountOutOfRangeImpl; + const PaymentError_AmountOutOfRange._() : super._(); +} + +/// @nodoc +abstract class _$$PaymentError_AlreadyClaimedImplCopyWith<$Res> { + factory _$$PaymentError_AlreadyClaimedImplCopyWith( + _$PaymentError_AlreadyClaimedImpl value, + $Res Function(_$PaymentError_AlreadyClaimedImpl) then) = + __$$PaymentError_AlreadyClaimedImplCopyWithImpl<$Res>; +} + +/// @nodoc +class __$$PaymentError_AlreadyClaimedImplCopyWithImpl<$Res> + extends _$PaymentErrorCopyWithImpl<$Res, _$PaymentError_AlreadyClaimedImpl> + implements _$$PaymentError_AlreadyClaimedImplCopyWith<$Res> { + __$$PaymentError_AlreadyClaimedImplCopyWithImpl( + _$PaymentError_AlreadyClaimedImpl _value, + $Res Function(_$PaymentError_AlreadyClaimedImpl) _then) + : super(_value, _then); +} + +/// @nodoc + +class _$PaymentError_AlreadyClaimedImpl extends PaymentError_AlreadyClaimed { + const _$PaymentError_AlreadyClaimedImpl() : super._(); + + @override + String toString() { + return 'PaymentError.alreadyClaimed()'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$PaymentError_AlreadyClaimedImpl); + } + + @override + int get hashCode => runtimeType.hashCode; +} + +abstract class PaymentError_AlreadyClaimed extends PaymentError { + const factory PaymentError_AlreadyClaimed() = + _$PaymentError_AlreadyClaimedImpl; + const PaymentError_AlreadyClaimed._() : super._(); +} + +/// @nodoc +abstract class _$$PaymentError_GenericImplCopyWith<$Res> { + factory _$$PaymentError_GenericImplCopyWith(_$PaymentError_GenericImpl value, + $Res Function(_$PaymentError_GenericImpl) then) = + __$$PaymentError_GenericImplCopyWithImpl<$Res>; + @useResult + $Res call({String err}); +} + +/// @nodoc +class __$$PaymentError_GenericImplCopyWithImpl<$Res> + extends _$PaymentErrorCopyWithImpl<$Res, _$PaymentError_GenericImpl> + implements _$$PaymentError_GenericImplCopyWith<$Res> { + __$$PaymentError_GenericImplCopyWithImpl(_$PaymentError_GenericImpl _value, + $Res Function(_$PaymentError_GenericImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? err = null, + }) { + return _then(_$PaymentError_GenericImpl( + err: null == err + ? _value.err + : err // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +/// @nodoc + +class _$PaymentError_GenericImpl extends PaymentError_Generic { + const _$PaymentError_GenericImpl({required this.err}) : super._(); + + @override + final String err; + + @override + String toString() { + return 'PaymentError.generic(err: $err)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$PaymentError_GenericImpl && + (identical(other.err, err) || other.err == err)); + } + + @override + int get hashCode => Object.hash(runtimeType, err); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$PaymentError_GenericImplCopyWith<_$PaymentError_GenericImpl> + get copyWith => + __$$PaymentError_GenericImplCopyWithImpl<_$PaymentError_GenericImpl>( + this, _$identity); +} + +abstract class PaymentError_Generic extends PaymentError { + const factory PaymentError_Generic({required final String err}) = + _$PaymentError_GenericImpl; + const PaymentError_Generic._() : super._(); + + String get err; + @JsonKey(ignore: true) + _$$PaymentError_GenericImplCopyWith<_$PaymentError_GenericImpl> + get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$PaymentError_InvalidInvoiceImplCopyWith<$Res> { + factory _$$PaymentError_InvalidInvoiceImplCopyWith( + _$PaymentError_InvalidInvoiceImpl value, + $Res Function(_$PaymentError_InvalidInvoiceImpl) then) = + __$$PaymentError_InvalidInvoiceImplCopyWithImpl<$Res>; +} + +/// @nodoc +class __$$PaymentError_InvalidInvoiceImplCopyWithImpl<$Res> + extends _$PaymentErrorCopyWithImpl<$Res, _$PaymentError_InvalidInvoiceImpl> + implements _$$PaymentError_InvalidInvoiceImplCopyWith<$Res> { + __$$PaymentError_InvalidInvoiceImplCopyWithImpl( + _$PaymentError_InvalidInvoiceImpl _value, + $Res Function(_$PaymentError_InvalidInvoiceImpl) _then) + : super(_value, _then); +} + +/// @nodoc + +class _$PaymentError_InvalidInvoiceImpl extends PaymentError_InvalidInvoice { + const _$PaymentError_InvalidInvoiceImpl() : super._(); + + @override + String toString() { + return 'PaymentError.invalidInvoice()'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$PaymentError_InvalidInvoiceImpl); + } + + @override + int get hashCode => runtimeType.hashCode; +} + +abstract class PaymentError_InvalidInvoice extends PaymentError { + const factory PaymentError_InvalidInvoice() = + _$PaymentError_InvalidInvoiceImpl; + const PaymentError_InvalidInvoice._() : super._(); +} + +/// @nodoc +abstract class _$$PaymentError_InvalidPreimageImplCopyWith<$Res> { + factory _$$PaymentError_InvalidPreimageImplCopyWith( + _$PaymentError_InvalidPreimageImpl value, + $Res Function(_$PaymentError_InvalidPreimageImpl) then) = + __$$PaymentError_InvalidPreimageImplCopyWithImpl<$Res>; +} + +/// @nodoc +class __$$PaymentError_InvalidPreimageImplCopyWithImpl<$Res> + extends _$PaymentErrorCopyWithImpl<$Res, _$PaymentError_InvalidPreimageImpl> + implements _$$PaymentError_InvalidPreimageImplCopyWith<$Res> { + __$$PaymentError_InvalidPreimageImplCopyWithImpl( + _$PaymentError_InvalidPreimageImpl _value, + $Res Function(_$PaymentError_InvalidPreimageImpl) _then) + : super(_value, _then); +} + +/// @nodoc + +class _$PaymentError_InvalidPreimageImpl extends PaymentError_InvalidPreimage { + const _$PaymentError_InvalidPreimageImpl() : super._(); + + @override + String toString() { + return 'PaymentError.invalidPreimage()'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$PaymentError_InvalidPreimageImpl); + } + + @override + int get hashCode => runtimeType.hashCode; +} + +abstract class PaymentError_InvalidPreimage extends PaymentError { + const factory PaymentError_InvalidPreimage() = + _$PaymentError_InvalidPreimageImpl; + const PaymentError_InvalidPreimage._() : super._(); +} + +/// @nodoc +abstract class _$$PaymentError_LwkErrorImplCopyWith<$Res> { + factory _$$PaymentError_LwkErrorImplCopyWith( + _$PaymentError_LwkErrorImpl value, + $Res Function(_$PaymentError_LwkErrorImpl) then) = + __$$PaymentError_LwkErrorImplCopyWithImpl<$Res>; + @useResult + $Res call({String err}); +} + +/// @nodoc +class __$$PaymentError_LwkErrorImplCopyWithImpl<$Res> + extends _$PaymentErrorCopyWithImpl<$Res, _$PaymentError_LwkErrorImpl> + implements _$$PaymentError_LwkErrorImplCopyWith<$Res> { + __$$PaymentError_LwkErrorImplCopyWithImpl(_$PaymentError_LwkErrorImpl _value, + $Res Function(_$PaymentError_LwkErrorImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? err = null, + }) { + return _then(_$PaymentError_LwkErrorImpl( + err: null == err + ? _value.err + : err // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +/// @nodoc + +class _$PaymentError_LwkErrorImpl extends PaymentError_LwkError { + const _$PaymentError_LwkErrorImpl({required this.err}) : super._(); + + @override + final String err; + + @override + String toString() { + return 'PaymentError.lwkError(err: $err)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$PaymentError_LwkErrorImpl && + (identical(other.err, err) || other.err == err)); + } + + @override + int get hashCode => Object.hash(runtimeType, err); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$PaymentError_LwkErrorImplCopyWith<_$PaymentError_LwkErrorImpl> + get copyWith => __$$PaymentError_LwkErrorImplCopyWithImpl< + _$PaymentError_LwkErrorImpl>(this, _$identity); +} + +abstract class PaymentError_LwkError extends PaymentError { + const factory PaymentError_LwkError({required final String err}) = + _$PaymentError_LwkErrorImpl; + const PaymentError_LwkError._() : super._(); + + String get err; + @JsonKey(ignore: true) + _$$PaymentError_LwkErrorImplCopyWith<_$PaymentError_LwkErrorImpl> + get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$PaymentError_PairsNotFoundImplCopyWith<$Res> { + factory _$$PaymentError_PairsNotFoundImplCopyWith( + _$PaymentError_PairsNotFoundImpl value, + $Res Function(_$PaymentError_PairsNotFoundImpl) then) = + __$$PaymentError_PairsNotFoundImplCopyWithImpl<$Res>; +} + +/// @nodoc +class __$$PaymentError_PairsNotFoundImplCopyWithImpl<$Res> + extends _$PaymentErrorCopyWithImpl<$Res, _$PaymentError_PairsNotFoundImpl> + implements _$$PaymentError_PairsNotFoundImplCopyWith<$Res> { + __$$PaymentError_PairsNotFoundImplCopyWithImpl( + _$PaymentError_PairsNotFoundImpl _value, + $Res Function(_$PaymentError_PairsNotFoundImpl) _then) + : super(_value, _then); +} + +/// @nodoc + +class _$PaymentError_PairsNotFoundImpl extends PaymentError_PairsNotFound { + const _$PaymentError_PairsNotFoundImpl() : super._(); + + @override + String toString() { + return 'PaymentError.pairsNotFound()'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$PaymentError_PairsNotFoundImpl); + } + + @override + int get hashCode => runtimeType.hashCode; +} + +abstract class PaymentError_PairsNotFound extends PaymentError { + const factory PaymentError_PairsNotFound() = _$PaymentError_PairsNotFoundImpl; + const PaymentError_PairsNotFound._() : super._(); +} + +/// @nodoc +abstract class _$$PaymentError_PersistErrorImplCopyWith<$Res> { + factory _$$PaymentError_PersistErrorImplCopyWith( + _$PaymentError_PersistErrorImpl value, + $Res Function(_$PaymentError_PersistErrorImpl) then) = + __$$PaymentError_PersistErrorImplCopyWithImpl<$Res>; +} + +/// @nodoc +class __$$PaymentError_PersistErrorImplCopyWithImpl<$Res> + extends _$PaymentErrorCopyWithImpl<$Res, _$PaymentError_PersistErrorImpl> + implements _$$PaymentError_PersistErrorImplCopyWith<$Res> { + __$$PaymentError_PersistErrorImplCopyWithImpl( + _$PaymentError_PersistErrorImpl _value, + $Res Function(_$PaymentError_PersistErrorImpl) _then) + : super(_value, _then); +} + +/// @nodoc + +class _$PaymentError_PersistErrorImpl extends PaymentError_PersistError { + const _$PaymentError_PersistErrorImpl() : super._(); + + @override + String toString() { + return 'PaymentError.persistError()'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$PaymentError_PersistErrorImpl); + } + + @override + int get hashCode => runtimeType.hashCode; +} + +abstract class PaymentError_PersistError extends PaymentError { + const factory PaymentError_PersistError() = _$PaymentError_PersistErrorImpl; + const PaymentError_PersistError._() : super._(); +} + +/// @nodoc +abstract class _$$PaymentError_SendErrorImplCopyWith<$Res> { + factory _$$PaymentError_SendErrorImplCopyWith( + _$PaymentError_SendErrorImpl value, + $Res Function(_$PaymentError_SendErrorImpl) then) = + __$$PaymentError_SendErrorImplCopyWithImpl<$Res>; + @useResult + $Res call({String err}); +} + +/// @nodoc +class __$$PaymentError_SendErrorImplCopyWithImpl<$Res> + extends _$PaymentErrorCopyWithImpl<$Res, _$PaymentError_SendErrorImpl> + implements _$$PaymentError_SendErrorImplCopyWith<$Res> { + __$$PaymentError_SendErrorImplCopyWithImpl( + _$PaymentError_SendErrorImpl _value, + $Res Function(_$PaymentError_SendErrorImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? err = null, + }) { + return _then(_$PaymentError_SendErrorImpl( + err: null == err + ? _value.err + : err // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +/// @nodoc + +class _$PaymentError_SendErrorImpl extends PaymentError_SendError { + const _$PaymentError_SendErrorImpl({required this.err}) : super._(); + + @override + final String err; + + @override + String toString() { + return 'PaymentError.sendError(err: $err)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$PaymentError_SendErrorImpl && + (identical(other.err, err) || other.err == err)); + } + + @override + int get hashCode => Object.hash(runtimeType, err); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$PaymentError_SendErrorImplCopyWith<_$PaymentError_SendErrorImpl> + get copyWith => __$$PaymentError_SendErrorImplCopyWithImpl< + _$PaymentError_SendErrorImpl>(this, _$identity); +} + +abstract class PaymentError_SendError extends PaymentError { + const factory PaymentError_SendError({required final String err}) = + _$PaymentError_SendErrorImpl; + const PaymentError_SendError._() : super._(); + + String get err; + @JsonKey(ignore: true) + _$$PaymentError_SendErrorImplCopyWith<_$PaymentError_SendErrorImpl> + get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$PaymentError_SignerErrorImplCopyWith<$Res> { + factory _$$PaymentError_SignerErrorImplCopyWith( + _$PaymentError_SignerErrorImpl value, + $Res Function(_$PaymentError_SignerErrorImpl) then) = + __$$PaymentError_SignerErrorImplCopyWithImpl<$Res>; + @useResult + $Res call({String err}); +} + +/// @nodoc +class __$$PaymentError_SignerErrorImplCopyWithImpl<$Res> + extends _$PaymentErrorCopyWithImpl<$Res, _$PaymentError_SignerErrorImpl> + implements _$$PaymentError_SignerErrorImplCopyWith<$Res> { + __$$PaymentError_SignerErrorImplCopyWithImpl( + _$PaymentError_SignerErrorImpl _value, + $Res Function(_$PaymentError_SignerErrorImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? err = null, + }) { + return _then(_$PaymentError_SignerErrorImpl( + err: null == err + ? _value.err + : err // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +/// @nodoc + +class _$PaymentError_SignerErrorImpl extends PaymentError_SignerError { + const _$PaymentError_SignerErrorImpl({required this.err}) : super._(); + + @override + final String err; + + @override + String toString() { + return 'PaymentError.signerError(err: $err)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$PaymentError_SignerErrorImpl && + (identical(other.err, err) || other.err == err)); + } + + @override + int get hashCode => Object.hash(runtimeType, err); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$PaymentError_SignerErrorImplCopyWith<_$PaymentError_SignerErrorImpl> + get copyWith => __$$PaymentError_SignerErrorImplCopyWithImpl< + _$PaymentError_SignerErrorImpl>(this, _$identity); +} + +abstract class PaymentError_SignerError extends PaymentError { + const factory PaymentError_SignerError({required final String err}) = + _$PaymentError_SignerErrorImpl; + const PaymentError_SignerError._() : super._(); + + String get err; + @JsonKey(ignore: true) + _$$PaymentError_SignerErrorImplCopyWith<_$PaymentError_SignerErrorImpl> + get copyWith => throw _privateConstructorUsedError; +} diff --git a/lib/ls-sdk-flutter/packages/breez_liquid/lib/src/frb_generated.dart b/lib/ls-sdk-flutter/packages/breez_liquid/lib/src/frb_generated.dart new file mode 100644 index 0000000..851ae55 --- /dev/null +++ b/lib/ls-sdk-flutter/packages/breez_liquid/lib/src/frb_generated.dart @@ -0,0 +1,1279 @@ +// This file is automatically generated, so please do not edit it. +// Generated by `flutter_rust_bridge`@ 2.0.0-dev.32. + +// ignore_for_file: unused_import, unused_element, unnecessary_import, duplicate_ignore, invalid_use_of_internal_member, annotate_overrides, non_constant_identifier_names, curly_braces_in_flow_control_structures, prefer_const_literals_to_create_immutables, unused_field + +import 'bindings.dart'; +import 'dart:async'; +import 'dart:convert'; +import 'error.dart'; +import 'frb_generated.io.dart' if (dart.library.html) 'frb_generated.web.dart'; +import 'model.dart'; +import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart'; + +/// Main entrypoint of the Rust API +class RustLib extends BaseEntrypoint { + @internal + static final instance = RustLib._(); + + RustLib._(); + + /// Initialize flutter_rust_bridge + static Future init({ + RustLibApi? api, + BaseHandler? handler, + ExternalLibrary? externalLibrary, + }) async { + await instance.initImpl( + api: api, + handler: handler, + externalLibrary: externalLibrary, + ); + } + + /// Dispose flutter_rust_bridge + /// + /// The call to this function is optional, since flutter_rust_bridge (and everything else) + /// is automatically disposed when the app stops. + static void dispose() => instance.disposeImpl(); + + @override + ApiImplConstructor get apiImplConstructor => + RustLibApiImpl.new; + + @override + WireConstructor get wireConstructor => + RustLibWire.fromExternalLibrary; + + @override + Future executeRustInitializers() async {} + + @override + ExternalLibraryLoaderConfig get defaultExternalLibraryLoaderConfig => + kDefaultExternalLibraryLoaderConfig; + + @override + String get codegenVersion => '2.0.0-dev.32'; + + @override + int get rustContentHash => -1225779344; + + static const kDefaultExternalLibraryLoaderConfig = + ExternalLibraryLoaderConfig( + stem: 'ls_sdk', + ioDirectory: '../../../ls-sdk-core/target/release/', + webPrefix: 'pkg/', + ); +} + +abstract class RustLibApi extends BaseApi { + Future backup({dynamic hint}); + + Future connect( + {required String mnemonic, + String? dataDir, + required Network network, + dynamic hint}); + + Future emptyWalletCache({dynamic hint}); + + Future getInfo({required bool withScan, dynamic hint}); + + Future> listPayments( + {required bool withScan, required bool includePending, dynamic hint}); + + Future prepareReceivePayment( + {required PrepareReceiveRequest req, dynamic hint}); + + Future prepareSendPayment( + {required String invoice, dynamic hint}); + + Future receivePayment( + {required PrepareReceiveResponse req, dynamic hint}); + + Future recoverFunds( + {required LBtcReverseRecovery recovery, dynamic hint}); + + Future restore({String? backupPath, dynamic hint}); + + Future sendPayment( + {required PrepareSendResponse req, dynamic hint}); + + RustArcIncrementStrongCountFnType + get rust_arc_increment_strong_count_LBtcReverseRecovery; + + RustArcDecrementStrongCountFnType + get rust_arc_decrement_strong_count_LBtcReverseRecovery; + + CrossPlatformFinalizerArg + get rust_arc_decrement_strong_count_LBtcReverseRecoveryPtr; +} + +class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { + RustLibApiImpl({ + required super.handler, + required super.wire, + required super.generalizedFrbRustBinding, + required super.portManager, + }); + + @override + Future backup({dynamic hint}) { + return handler.executeNormal(NormalTask( + callFfi: (port_) { + return wire.wire_backup(port_); + }, + codec: DcoCodec( + decodeSuccessData: dco_decode_unit, + decodeErrorData: dco_decode_AnyhowException, + ), + constMeta: kBackupConstMeta, + argValues: [], + apiImpl: this, + hint: hint, + )); + } + + TaskConstMeta get kBackupConstMeta => const TaskConstMeta( + debugName: "backup", + argNames: [], + ); + + @override + Future connect( + {required String mnemonic, + String? dataDir, + required Network network, + dynamic hint}) { + return handler.executeNormal(NormalTask( + callFfi: (port_) { + var arg0 = cst_encode_String(mnemonic); + var arg1 = cst_encode_opt_String(dataDir); + var arg2 = cst_encode_network(network); + return wire.wire_connect(port_, arg0, arg1, arg2); + }, + codec: DcoCodec( + decodeSuccessData: dco_decode_unit, + decodeErrorData: dco_decode_AnyhowException, + ), + constMeta: kConnectConstMeta, + argValues: [mnemonic, dataDir, network], + apiImpl: this, + hint: hint, + )); + } + + TaskConstMeta get kConnectConstMeta => const TaskConstMeta( + debugName: "connect", + argNames: ["mnemonic", "dataDir", "network"], + ); + + @override + Future emptyWalletCache({dynamic hint}) { + return handler.executeNormal(NormalTask( + callFfi: (port_) { + return wire.wire_empty_wallet_cache(port_); + }, + codec: DcoCodec( + decodeSuccessData: dco_decode_unit, + decodeErrorData: dco_decode_AnyhowException, + ), + constMeta: kEmptyWalletCacheConstMeta, + argValues: [], + apiImpl: this, + hint: hint, + )); + } + + TaskConstMeta get kEmptyWalletCacheConstMeta => const TaskConstMeta( + debugName: "empty_wallet_cache", + argNames: [], + ); + + @override + Future getInfo({required bool withScan, dynamic hint}) { + return handler.executeNormal(NormalTask( + callFfi: (port_) { + var arg0 = cst_encode_bool(withScan); + return wire.wire_get_info(port_, arg0); + }, + codec: DcoCodec( + decodeSuccessData: dco_decode_wallet_info, + decodeErrorData: dco_decode_AnyhowException, + ), + constMeta: kGetInfoConstMeta, + argValues: [withScan], + apiImpl: this, + hint: hint, + )); + } + + TaskConstMeta get kGetInfoConstMeta => const TaskConstMeta( + debugName: "get_info", + argNames: ["withScan"], + ); + + @override + Future> listPayments( + {required bool withScan, required bool includePending, dynamic hint}) { + return handler.executeNormal(NormalTask( + callFfi: (port_) { + var arg0 = cst_encode_bool(withScan); + var arg1 = cst_encode_bool(includePending); + return wire.wire_list_payments(port_, arg0, arg1); + }, + codec: DcoCodec( + decodeSuccessData: dco_decode_list_payment, + decodeErrorData: dco_decode_AnyhowException, + ), + constMeta: kListPaymentsConstMeta, + argValues: [withScan, includePending], + apiImpl: this, + hint: hint, + )); + } + + TaskConstMeta get kListPaymentsConstMeta => const TaskConstMeta( + debugName: "list_payments", + argNames: ["withScan", "includePending"], + ); + + @override + Future prepareReceivePayment( + {required PrepareReceiveRequest req, dynamic hint}) { + return handler.executeNormal(NormalTask( + callFfi: (port_) { + var arg0 = cst_encode_box_autoadd_prepare_receive_request(req); + return wire.wire_prepare_receive_payment(port_, arg0); + }, + codec: DcoCodec( + decodeSuccessData: dco_decode_prepare_receive_response, + decodeErrorData: dco_decode_payment_error, + ), + constMeta: kPrepareReceivePaymentConstMeta, + argValues: [req], + apiImpl: this, + hint: hint, + )); + } + + TaskConstMeta get kPrepareReceivePaymentConstMeta => const TaskConstMeta( + debugName: "prepare_receive_payment", + argNames: ["req"], + ); + + @override + Future prepareSendPayment( + {required String invoice, dynamic hint}) { + return handler.executeNormal(NormalTask( + callFfi: (port_) { + var arg0 = cst_encode_String(invoice); + return wire.wire_prepare_send_payment(port_, arg0); + }, + codec: DcoCodec( + decodeSuccessData: dco_decode_prepare_send_response, + decodeErrorData: dco_decode_payment_error, + ), + constMeta: kPrepareSendPaymentConstMeta, + argValues: [invoice], + apiImpl: this, + hint: hint, + )); + } + + TaskConstMeta get kPrepareSendPaymentConstMeta => const TaskConstMeta( + debugName: "prepare_send_payment", + argNames: ["invoice"], + ); + + @override + Future receivePayment( + {required PrepareReceiveResponse req, dynamic hint}) { + return handler.executeNormal(NormalTask( + callFfi: (port_) { + var arg0 = cst_encode_box_autoadd_prepare_receive_response(req); + return wire.wire_receive_payment(port_, arg0); + }, + codec: DcoCodec( + decodeSuccessData: dco_decode_receive_payment_response, + decodeErrorData: dco_decode_payment_error, + ), + constMeta: kReceivePaymentConstMeta, + argValues: [req], + apiImpl: this, + hint: hint, + )); + } + + TaskConstMeta get kReceivePaymentConstMeta => const TaskConstMeta( + debugName: "receive_payment", + argNames: ["req"], + ); + + @override + Future recoverFunds( + {required LBtcReverseRecovery recovery, dynamic hint}) { + return handler.executeNormal(NormalTask( + callFfi: (port_) { + var arg0 = + cst_encode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockLBtcReverseRecovery( + recovery); + return wire.wire_recover_funds(port_, arg0); + }, + codec: DcoCodec( + decodeSuccessData: dco_decode_String, + decodeErrorData: dco_decode_AnyhowException, + ), + constMeta: kRecoverFundsConstMeta, + argValues: [recovery], + apiImpl: this, + hint: hint, + )); + } + + TaskConstMeta get kRecoverFundsConstMeta => const TaskConstMeta( + debugName: "recover_funds", + argNames: ["recovery"], + ); + + @override + Future restore({String? backupPath, dynamic hint}) { + return handler.executeNormal(NormalTask( + callFfi: (port_) { + var arg0 = cst_encode_opt_String(backupPath); + return wire.wire_restore(port_, arg0); + }, + codec: DcoCodec( + decodeSuccessData: dco_decode_unit, + decodeErrorData: dco_decode_AnyhowException, + ), + constMeta: kRestoreConstMeta, + argValues: [backupPath], + apiImpl: this, + hint: hint, + )); + } + + TaskConstMeta get kRestoreConstMeta => const TaskConstMeta( + debugName: "restore", + argNames: ["backupPath"], + ); + + @override + Future sendPayment( + {required PrepareSendResponse req, dynamic hint}) { + return handler.executeNormal(NormalTask( + callFfi: (port_) { + var arg0 = cst_encode_box_autoadd_prepare_send_response(req); + return wire.wire_send_payment(port_, arg0); + }, + codec: DcoCodec( + decodeSuccessData: dco_decode_send_payment_response, + decodeErrorData: dco_decode_payment_error, + ), + constMeta: kSendPaymentConstMeta, + argValues: [req], + apiImpl: this, + hint: hint, + )); + } + + TaskConstMeta get kSendPaymentConstMeta => const TaskConstMeta( + debugName: "send_payment", + argNames: ["req"], + ); + + RustArcIncrementStrongCountFnType + get rust_arc_increment_strong_count_LBtcReverseRecovery => wire + .rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockLBtcReverseRecovery; + + RustArcDecrementStrongCountFnType + get rust_arc_decrement_strong_count_LBtcReverseRecovery => wire + .rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockLBtcReverseRecovery; + + @protected + AnyhowException dco_decode_AnyhowException(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return AnyhowException(raw as String); + } + + @protected + LBtcReverseRecovery + dco_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockLBtcReverseRecovery( + dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return LBtcReverseRecovery.dcoDecode(raw as List); + } + + @protected + LBtcReverseRecovery + dco_decode_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockLBtcReverseRecovery( + dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return LBtcReverseRecovery.dcoDecode(raw as List); + } + + @protected + String dco_decode_String(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return raw as String; + } + + @protected + bool dco_decode_bool(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return raw as bool; + } + + @protected + PrepareReceiveRequest dco_decode_box_autoadd_prepare_receive_request( + dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return dco_decode_prepare_receive_request(raw); + } + + @protected + PrepareReceiveResponse dco_decode_box_autoadd_prepare_receive_response( + dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return dco_decode_prepare_receive_response(raw); + } + + @protected + PrepareSendResponse dco_decode_box_autoadd_prepare_send_response( + dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return dco_decode_prepare_send_response(raw); + } + + @protected + int dco_decode_box_autoadd_u_32(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return raw as int; + } + + @protected + int dco_decode_box_autoadd_u_64(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return dco_decode_u_64(raw); + } + + @protected + int dco_decode_i_32(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return raw as int; + } + + @protected + List dco_decode_list_payment(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return (raw as List).map(dco_decode_payment).toList(); + } + + @protected + Uint8List dco_decode_list_prim_u_8_strict(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return raw as Uint8List; + } + + @protected + Network dco_decode_network(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return Network.values[raw as int]; + } + + @protected + String? dco_decode_opt_String(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return raw == null ? null : dco_decode_String(raw); + } + + @protected + int? dco_decode_opt_box_autoadd_u_32(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return raw == null ? null : dco_decode_box_autoadd_u_32(raw); + } + + @protected + int? dco_decode_opt_box_autoadd_u_64(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return raw == null ? null : dco_decode_box_autoadd_u_64(raw); + } + + @protected + Payment dco_decode_payment(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + final arr = raw as List; + if (arr.length != 6) + throw Exception('unexpected arr length: expect 6 but see ${arr.length}'); + return Payment( + id: dco_decode_opt_String(arr[0]), + timestamp: dco_decode_opt_box_autoadd_u_32(arr[1]), + amountSat: dco_decode_u_64(arr[2]), + feesSat: dco_decode_opt_box_autoadd_u_64(arr[3]), + paymentType: dco_decode_payment_type(arr[4]), + invoice: dco_decode_opt_String(arr[5]), + ); + } + + @protected + PaymentError dco_decode_payment_error(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + switch (raw[0]) { + case 0: + return PaymentError_AmountOutOfRange(); + case 1: + return PaymentError_AlreadyClaimed(); + case 2: + return PaymentError_Generic( + err: dco_decode_String(raw[1]), + ); + case 3: + return PaymentError_InvalidInvoice(); + case 4: + return PaymentError_InvalidPreimage(); + case 5: + return PaymentError_LwkError( + err: dco_decode_String(raw[1]), + ); + case 6: + return PaymentError_PairsNotFound(); + case 7: + return PaymentError_PersistError(); + case 8: + return PaymentError_SendError( + err: dco_decode_String(raw[1]), + ); + case 9: + return PaymentError_SignerError( + err: dco_decode_String(raw[1]), + ); + default: + throw Exception("unreachable"); + } + } + + @protected + PaymentType dco_decode_payment_type(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return PaymentType.values[raw as int]; + } + + @protected + PrepareReceiveRequest dco_decode_prepare_receive_request(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + final arr = raw as List; + if (arr.length != 2) + throw Exception('unexpected arr length: expect 2 but see ${arr.length}'); + return PrepareReceiveRequest( + payerAmountSat: dco_decode_opt_box_autoadd_u_64(arr[0]), + receiverAmountSat: dco_decode_opt_box_autoadd_u_64(arr[1]), + ); + } + + @protected + PrepareReceiveResponse dco_decode_prepare_receive_response(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + final arr = raw as List; + if (arr.length != 3) + throw Exception('unexpected arr length: expect 3 but see ${arr.length}'); + return PrepareReceiveResponse( + pairHash: dco_decode_String(arr[0]), + payerAmountSat: dco_decode_u_64(arr[1]), + feesSat: dco_decode_u_64(arr[2]), + ); + } + + @protected + PrepareSendResponse dco_decode_prepare_send_response(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + final arr = raw as List; + if (arr.length != 6) + throw Exception('unexpected arr length: expect 6 but see ${arr.length}'); + return PrepareSendResponse( + id: dco_decode_String(arr[0]), + payerAmountSat: dco_decode_u_64(arr[1]), + receiverAmountSat: dco_decode_u_64(arr[2]), + totalFees: dco_decode_u_64(arr[3]), + fundingAddress: dco_decode_String(arr[4]), + invoice: dco_decode_String(arr[5]), + ); + } + + @protected + ReceivePaymentResponse dco_decode_receive_payment_response(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + final arr = raw as List; + if (arr.length != 2) + throw Exception('unexpected arr length: expect 2 but see ${arr.length}'); + return ReceivePaymentResponse( + id: dco_decode_String(arr[0]), + invoice: dco_decode_String(arr[1]), + ); + } + + @protected + SendPaymentResponse dco_decode_send_payment_response(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + final arr = raw as List; + if (arr.length != 1) + throw Exception('unexpected arr length: expect 1 but see ${arr.length}'); + return SendPaymentResponse( + txid: dco_decode_String(arr[0]), + ); + } + + @protected + int dco_decode_u_32(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return raw as int; + } + + @protected + int dco_decode_u_64(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return dcoDecodeI64OrU64(raw); + } + + @protected + int dco_decode_u_8(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return raw as int; + } + + @protected + void dco_decode_unit(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return; + } + + @protected + int dco_decode_usize(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return dcoDecodeI64OrU64(raw); + } + + @protected + WalletInfo dco_decode_wallet_info(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + final arr = raw as List; + if (arr.length != 2) + throw Exception('unexpected arr length: expect 2 but see ${arr.length}'); + return WalletInfo( + balanceSat: dco_decode_u_64(arr[0]), + pubkey: dco_decode_String(arr[1]), + ); + } + + @protected + AnyhowException sse_decode_AnyhowException(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + var inner = sse_decode_String(deserializer); + return AnyhowException(inner); + } + + @protected + LBtcReverseRecovery + sse_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockLBtcReverseRecovery( + SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return LBtcReverseRecovery.sseDecode( + sse_decode_usize(deserializer), sse_decode_i_32(deserializer)); + } + + @protected + LBtcReverseRecovery + sse_decode_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockLBtcReverseRecovery( + SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return LBtcReverseRecovery.sseDecode( + sse_decode_usize(deserializer), sse_decode_i_32(deserializer)); + } + + @protected + String sse_decode_String(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + var inner = sse_decode_list_prim_u_8_strict(deserializer); + return utf8.decoder.convert(inner); + } + + @protected + bool sse_decode_bool(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return deserializer.buffer.getUint8() != 0; + } + + @protected + PrepareReceiveRequest sse_decode_box_autoadd_prepare_receive_request( + SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return (sse_decode_prepare_receive_request(deserializer)); + } + + @protected + PrepareReceiveResponse sse_decode_box_autoadd_prepare_receive_response( + SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return (sse_decode_prepare_receive_response(deserializer)); + } + + @protected + PrepareSendResponse sse_decode_box_autoadd_prepare_send_response( + SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return (sse_decode_prepare_send_response(deserializer)); + } + + @protected + int sse_decode_box_autoadd_u_32(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return (sse_decode_u_32(deserializer)); + } + + @protected + int sse_decode_box_autoadd_u_64(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return (sse_decode_u_64(deserializer)); + } + + @protected + int sse_decode_i_32(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return deserializer.buffer.getInt32(); + } + + @protected + List sse_decode_list_payment(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + + var len_ = sse_decode_i_32(deserializer); + var ans_ = []; + for (var idx_ = 0; idx_ < len_; ++idx_) { + ans_.add(sse_decode_payment(deserializer)); + } + return ans_; + } + + @protected + Uint8List sse_decode_list_prim_u_8_strict(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + var len_ = sse_decode_i_32(deserializer); + return deserializer.buffer.getUint8List(len_); + } + + @protected + Network sse_decode_network(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + var inner = sse_decode_i_32(deserializer); + return Network.values[inner]; + } + + @protected + String? sse_decode_opt_String(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + + if (sse_decode_bool(deserializer)) { + return (sse_decode_String(deserializer)); + } else { + return null; + } + } + + @protected + int? sse_decode_opt_box_autoadd_u_32(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + + if (sse_decode_bool(deserializer)) { + return (sse_decode_box_autoadd_u_32(deserializer)); + } else { + return null; + } + } + + @protected + int? sse_decode_opt_box_autoadd_u_64(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + + if (sse_decode_bool(deserializer)) { + return (sse_decode_box_autoadd_u_64(deserializer)); + } else { + return null; + } + } + + @protected + Payment sse_decode_payment(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + var var_id = sse_decode_opt_String(deserializer); + var var_timestamp = sse_decode_opt_box_autoadd_u_32(deserializer); + var var_amountSat = sse_decode_u_64(deserializer); + var var_feesSat = sse_decode_opt_box_autoadd_u_64(deserializer); + var var_paymentType = sse_decode_payment_type(deserializer); + var var_invoice = sse_decode_opt_String(deserializer); + return Payment( + id: var_id, + timestamp: var_timestamp, + amountSat: var_amountSat, + feesSat: var_feesSat, + paymentType: var_paymentType, + invoice: var_invoice); + } + + @protected + PaymentError sse_decode_payment_error(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + + var tag_ = sse_decode_i_32(deserializer); + switch (tag_) { + case 0: + return PaymentError_AmountOutOfRange(); + case 1: + return PaymentError_AlreadyClaimed(); + case 2: + var var_err = sse_decode_String(deserializer); + return PaymentError_Generic(err: var_err); + case 3: + return PaymentError_InvalidInvoice(); + case 4: + return PaymentError_InvalidPreimage(); + case 5: + var var_err = sse_decode_String(deserializer); + return PaymentError_LwkError(err: var_err); + case 6: + return PaymentError_PairsNotFound(); + case 7: + return PaymentError_PersistError(); + case 8: + var var_err = sse_decode_String(deserializer); + return PaymentError_SendError(err: var_err); + case 9: + var var_err = sse_decode_String(deserializer); + return PaymentError_SignerError(err: var_err); + default: + throw UnimplementedError(''); + } + } + + @protected + PaymentType sse_decode_payment_type(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + var inner = sse_decode_i_32(deserializer); + return PaymentType.values[inner]; + } + + @protected + PrepareReceiveRequest sse_decode_prepare_receive_request( + SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + var var_payerAmountSat = sse_decode_opt_box_autoadd_u_64(deserializer); + var var_receiverAmountSat = sse_decode_opt_box_autoadd_u_64(deserializer); + return PrepareReceiveRequest( + payerAmountSat: var_payerAmountSat, + receiverAmountSat: var_receiverAmountSat); + } + + @protected + PrepareReceiveResponse sse_decode_prepare_receive_response( + SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + var var_pairHash = sse_decode_String(deserializer); + var var_payerAmountSat = sse_decode_u_64(deserializer); + var var_feesSat = sse_decode_u_64(deserializer); + return PrepareReceiveResponse( + pairHash: var_pairHash, + payerAmountSat: var_payerAmountSat, + feesSat: var_feesSat); + } + + @protected + PrepareSendResponse sse_decode_prepare_send_response( + SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + var var_id = sse_decode_String(deserializer); + var var_payerAmountSat = sse_decode_u_64(deserializer); + var var_receiverAmountSat = sse_decode_u_64(deserializer); + var var_totalFees = sse_decode_u_64(deserializer); + var var_fundingAddress = sse_decode_String(deserializer); + var var_invoice = sse_decode_String(deserializer); + return PrepareSendResponse( + id: var_id, + payerAmountSat: var_payerAmountSat, + receiverAmountSat: var_receiverAmountSat, + totalFees: var_totalFees, + fundingAddress: var_fundingAddress, + invoice: var_invoice); + } + + @protected + ReceivePaymentResponse sse_decode_receive_payment_response( + SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + var var_id = sse_decode_String(deserializer); + var var_invoice = sse_decode_String(deserializer); + return ReceivePaymentResponse(id: var_id, invoice: var_invoice); + } + + @protected + SendPaymentResponse sse_decode_send_payment_response( + SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + var var_txid = sse_decode_String(deserializer); + return SendPaymentResponse(txid: var_txid); + } + + @protected + int sse_decode_u_32(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return deserializer.buffer.getUint32(); + } + + @protected + int sse_decode_u_64(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return deserializer.buffer.getUint64(); + } + + @protected + int sse_decode_u_8(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return deserializer.buffer.getUint8(); + } + + @protected + void sse_decode_unit(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + } + + @protected + int sse_decode_usize(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return deserializer.buffer.getUint64(); + } + + @protected + WalletInfo sse_decode_wallet_info(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + var var_balanceSat = sse_decode_u_64(deserializer); + var var_pubkey = sse_decode_String(deserializer); + return WalletInfo(balanceSat: var_balanceSat, pubkey: var_pubkey); + } + + @protected + int cst_encode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockLBtcReverseRecovery( + LBtcReverseRecovery raw) { + // Codec=Cst (C-struct based), see doc to use other codecs +// ignore: invalid_use_of_internal_member + return raw.cstEncode(move: true); + } + + @protected + int cst_encode_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockLBtcReverseRecovery( + LBtcReverseRecovery raw) { + // Codec=Cst (C-struct based), see doc to use other codecs +// ignore: invalid_use_of_internal_member + return raw.cstEncode(); + } + + @protected + bool cst_encode_bool(bool raw) { + // Codec=Cst (C-struct based), see doc to use other codecs + return raw; + } + + @protected + int cst_encode_i_32(int raw) { + // Codec=Cst (C-struct based), see doc to use other codecs + return raw; + } + + @protected + int cst_encode_network(Network raw) { + // Codec=Cst (C-struct based), see doc to use other codecs + return cst_encode_i_32(raw.index); + } + + @protected + int cst_encode_payment_type(PaymentType raw) { + // Codec=Cst (C-struct based), see doc to use other codecs + return cst_encode_i_32(raw.index); + } + + @protected + int cst_encode_u_32(int raw) { + // Codec=Cst (C-struct based), see doc to use other codecs + return raw; + } + + @protected + int cst_encode_u_8(int raw) { + // Codec=Cst (C-struct based), see doc to use other codecs + return raw; + } + + @protected + void cst_encode_unit(void raw) { + // Codec=Cst (C-struct based), see doc to use other codecs + return raw; + } + + @protected + int cst_encode_usize(int raw) { + // Codec=Cst (C-struct based), see doc to use other codecs + return raw; + } + + @protected + void sse_encode_AnyhowException( + AnyhowException self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + throw UnimplementedError('Unreachable ()'); + } + + @protected + void + sse_encode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockLBtcReverseRecovery( + LBtcReverseRecovery self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_usize(self.sseEncode(move: true), serializer); + } + + @protected + void + sse_encode_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockLBtcReverseRecovery( + LBtcReverseRecovery self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_usize(self.sseEncode(move: null), serializer); + } + + @protected + void sse_encode_String(String self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_list_prim_u_8_strict(utf8.encoder.convert(self), serializer); + } + + @protected + void sse_encode_bool(bool self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + serializer.buffer.putUint8(self ? 1 : 0); + } + + @protected + void sse_encode_box_autoadd_prepare_receive_request( + PrepareReceiveRequest self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_prepare_receive_request(self, serializer); + } + + @protected + void sse_encode_box_autoadd_prepare_receive_response( + PrepareReceiveResponse self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_prepare_receive_response(self, serializer); + } + + @protected + void sse_encode_box_autoadd_prepare_send_response( + PrepareSendResponse self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_prepare_send_response(self, serializer); + } + + @protected + void sse_encode_box_autoadd_u_32(int self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_u_32(self, serializer); + } + + @protected + void sse_encode_box_autoadd_u_64(int self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_u_64(self, serializer); + } + + @protected + void sse_encode_i_32(int self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + serializer.buffer.putInt32(self); + } + + @protected + void sse_encode_list_payment(List self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_i_32(self.length, serializer); + for (final item in self) { + sse_encode_payment(item, serializer); + } + } + + @protected + void sse_encode_list_prim_u_8_strict( + Uint8List self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_i_32(self.length, serializer); + serializer.buffer.putUint8List(self); + } + + @protected + void sse_encode_network(Network self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_i_32(self.index, serializer); + } + + @protected + void sse_encode_opt_String(String? self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + + sse_encode_bool(self != null, serializer); + if (self != null) { + sse_encode_String(self, serializer); + } + } + + @protected + void sse_encode_opt_box_autoadd_u_32(int? self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + + sse_encode_bool(self != null, serializer); + if (self != null) { + sse_encode_box_autoadd_u_32(self, serializer); + } + } + + @protected + void sse_encode_opt_box_autoadd_u_64(int? self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + + sse_encode_bool(self != null, serializer); + if (self != null) { + sse_encode_box_autoadd_u_64(self, serializer); + } + } + + @protected + void sse_encode_payment(Payment self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_opt_String(self.id, serializer); + sse_encode_opt_box_autoadd_u_32(self.timestamp, serializer); + sse_encode_u_64(self.amountSat, serializer); + sse_encode_opt_box_autoadd_u_64(self.feesSat, serializer); + sse_encode_payment_type(self.paymentType, serializer); + sse_encode_opt_String(self.invoice, serializer); + } + + @protected + void sse_encode_payment_error(PaymentError self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + switch (self) { + case PaymentError_AmountOutOfRange(): + sse_encode_i_32(0, serializer); + case PaymentError_AlreadyClaimed(): + sse_encode_i_32(1, serializer); + case PaymentError_Generic(err: final err): + sse_encode_i_32(2, serializer); + sse_encode_String(err, serializer); + case PaymentError_InvalidInvoice(): + sse_encode_i_32(3, serializer); + case PaymentError_InvalidPreimage(): + sse_encode_i_32(4, serializer); + case PaymentError_LwkError(err: final err): + sse_encode_i_32(5, serializer); + sse_encode_String(err, serializer); + case PaymentError_PairsNotFound(): + sse_encode_i_32(6, serializer); + case PaymentError_PersistError(): + sse_encode_i_32(7, serializer); + case PaymentError_SendError(err: final err): + sse_encode_i_32(8, serializer); + sse_encode_String(err, serializer); + case PaymentError_SignerError(err: final err): + sse_encode_i_32(9, serializer); + sse_encode_String(err, serializer); + } + } + + @protected + void sse_encode_payment_type(PaymentType self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_i_32(self.index, serializer); + } + + @protected + void sse_encode_prepare_receive_request( + PrepareReceiveRequest self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_opt_box_autoadd_u_64(self.payerAmountSat, serializer); + sse_encode_opt_box_autoadd_u_64(self.receiverAmountSat, serializer); + } + + @protected + void sse_encode_prepare_receive_response( + PrepareReceiveResponse self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_String(self.pairHash, serializer); + sse_encode_u_64(self.payerAmountSat, serializer); + sse_encode_u_64(self.feesSat, serializer); + } + + @protected + void sse_encode_prepare_send_response( + PrepareSendResponse self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_String(self.id, serializer); + sse_encode_u_64(self.payerAmountSat, serializer); + sse_encode_u_64(self.receiverAmountSat, serializer); + sse_encode_u_64(self.totalFees, serializer); + sse_encode_String(self.fundingAddress, serializer); + sse_encode_String(self.invoice, serializer); + } + + @protected + void sse_encode_receive_payment_response( + ReceivePaymentResponse self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_String(self.id, serializer); + sse_encode_String(self.invoice, serializer); + } + + @protected + void sse_encode_send_payment_response( + SendPaymentResponse self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_String(self.txid, serializer); + } + + @protected + void sse_encode_u_32(int self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + serializer.buffer.putUint32(self); + } + + @protected + void sse_encode_u_64(int self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + serializer.buffer.putUint64(self); + } + + @protected + void sse_encode_u_8(int self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + serializer.buffer.putUint8(self); + } + + @protected + void sse_encode_unit(void self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + } + + @protected + void sse_encode_usize(int self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + serializer.buffer.putUint64(self); + } + + @protected + void sse_encode_wallet_info(WalletInfo self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_u_64(self.balanceSat, serializer); + sse_encode_String(self.pubkey, serializer); + } +} diff --git a/lib/ls-sdk-flutter/packages/breez_liquid/lib/src/frb_generated.io.dart b/lib/ls-sdk-flutter/packages/breez_liquid/lib/src/frb_generated.io.dart new file mode 100644 index 0000000..93818ab --- /dev/null +++ b/lib/ls-sdk-flutter/packages/breez_liquid/lib/src/frb_generated.io.dart @@ -0,0 +1,1097 @@ +// This file is automatically generated, so please do not edit it. +// Generated by `flutter_rust_bridge`@ 2.0.0-dev.32. + +// ignore_for_file: unused_import, unused_element, unnecessary_import, duplicate_ignore, invalid_use_of_internal_member, annotate_overrides, non_constant_identifier_names, curly_braces_in_flow_control_structures, prefer_const_literals_to_create_immutables, unused_field + +import 'bindings.dart'; +import 'dart:async'; +import 'dart:convert'; +import 'dart:ffi' as ffi; +import 'error.dart'; +import 'frb_generated.dart'; +import 'model.dart'; +import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated_io.dart'; + +abstract class RustLibApiImplPlatform extends BaseApiImpl { + RustLibApiImplPlatform({ + required super.handler, + required super.wire, + required super.generalizedFrbRustBinding, + required super.portManager, + }); + + CrossPlatformFinalizerArg + get rust_arc_decrement_strong_count_LBtcReverseRecoveryPtr => wire + ._rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockLBtcReverseRecoveryPtr; + + @protected + AnyhowException dco_decode_AnyhowException(dynamic raw); + + @protected + LBtcReverseRecovery + dco_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockLBtcReverseRecovery( + dynamic raw); + + @protected + LBtcReverseRecovery + dco_decode_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockLBtcReverseRecovery( + dynamic raw); + + @protected + String dco_decode_String(dynamic raw); + + @protected + bool dco_decode_bool(dynamic raw); + + @protected + PrepareReceiveRequest dco_decode_box_autoadd_prepare_receive_request( + dynamic raw); + + @protected + PrepareReceiveResponse dco_decode_box_autoadd_prepare_receive_response( + dynamic raw); + + @protected + PrepareSendResponse dco_decode_box_autoadd_prepare_send_response(dynamic raw); + + @protected + int dco_decode_box_autoadd_u_32(dynamic raw); + + @protected + int dco_decode_box_autoadd_u_64(dynamic raw); + + @protected + int dco_decode_i_32(dynamic raw); + + @protected + List dco_decode_list_payment(dynamic raw); + + @protected + Uint8List dco_decode_list_prim_u_8_strict(dynamic raw); + + @protected + Network dco_decode_network(dynamic raw); + + @protected + String? dco_decode_opt_String(dynamic raw); + + @protected + int? dco_decode_opt_box_autoadd_u_32(dynamic raw); + + @protected + int? dco_decode_opt_box_autoadd_u_64(dynamic raw); + + @protected + Payment dco_decode_payment(dynamic raw); + + @protected + PaymentError dco_decode_payment_error(dynamic raw); + + @protected + PaymentType dco_decode_payment_type(dynamic raw); + + @protected + PrepareReceiveRequest dco_decode_prepare_receive_request(dynamic raw); + + @protected + PrepareReceiveResponse dco_decode_prepare_receive_response(dynamic raw); + + @protected + PrepareSendResponse dco_decode_prepare_send_response(dynamic raw); + + @protected + ReceivePaymentResponse dco_decode_receive_payment_response(dynamic raw); + + @protected + SendPaymentResponse dco_decode_send_payment_response(dynamic raw); + + @protected + int dco_decode_u_32(dynamic raw); + + @protected + int dco_decode_u_64(dynamic raw); + + @protected + int dco_decode_u_8(dynamic raw); + + @protected + void dco_decode_unit(dynamic raw); + + @protected + int dco_decode_usize(dynamic raw); + + @protected + WalletInfo dco_decode_wallet_info(dynamic raw); + + @protected + AnyhowException sse_decode_AnyhowException(SseDeserializer deserializer); + + @protected + LBtcReverseRecovery + sse_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockLBtcReverseRecovery( + SseDeserializer deserializer); + + @protected + LBtcReverseRecovery + sse_decode_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockLBtcReverseRecovery( + SseDeserializer deserializer); + + @protected + String sse_decode_String(SseDeserializer deserializer); + + @protected + bool sse_decode_bool(SseDeserializer deserializer); + + @protected + PrepareReceiveRequest sse_decode_box_autoadd_prepare_receive_request( + SseDeserializer deserializer); + + @protected + PrepareReceiveResponse sse_decode_box_autoadd_prepare_receive_response( + SseDeserializer deserializer); + + @protected + PrepareSendResponse sse_decode_box_autoadd_prepare_send_response( + SseDeserializer deserializer); + + @protected + int sse_decode_box_autoadd_u_32(SseDeserializer deserializer); + + @protected + int sse_decode_box_autoadd_u_64(SseDeserializer deserializer); + + @protected + int sse_decode_i_32(SseDeserializer deserializer); + + @protected + List sse_decode_list_payment(SseDeserializer deserializer); + + @protected + Uint8List sse_decode_list_prim_u_8_strict(SseDeserializer deserializer); + + @protected + Network sse_decode_network(SseDeserializer deserializer); + + @protected + String? sse_decode_opt_String(SseDeserializer deserializer); + + @protected + int? sse_decode_opt_box_autoadd_u_32(SseDeserializer deserializer); + + @protected + int? sse_decode_opt_box_autoadd_u_64(SseDeserializer deserializer); + + @protected + Payment sse_decode_payment(SseDeserializer deserializer); + + @protected + PaymentError sse_decode_payment_error(SseDeserializer deserializer); + + @protected + PaymentType sse_decode_payment_type(SseDeserializer deserializer); + + @protected + PrepareReceiveRequest sse_decode_prepare_receive_request( + SseDeserializer deserializer); + + @protected + PrepareReceiveResponse sse_decode_prepare_receive_response( + SseDeserializer deserializer); + + @protected + PrepareSendResponse sse_decode_prepare_send_response( + SseDeserializer deserializer); + + @protected + ReceivePaymentResponse sse_decode_receive_payment_response( + SseDeserializer deserializer); + + @protected + SendPaymentResponse sse_decode_send_payment_response( + SseDeserializer deserializer); + + @protected + int sse_decode_u_32(SseDeserializer deserializer); + + @protected + int sse_decode_u_64(SseDeserializer deserializer); + + @protected + int sse_decode_u_8(SseDeserializer deserializer); + + @protected + void sse_decode_unit(SseDeserializer deserializer); + + @protected + int sse_decode_usize(SseDeserializer deserializer); + + @protected + WalletInfo sse_decode_wallet_info(SseDeserializer deserializer); + + @protected + ffi.Pointer cst_encode_AnyhowException( + AnyhowException raw) { + // Codec=Cst (C-struct based), see doc to use other codecs + throw UnimplementedError(); + } + + @protected + ffi.Pointer cst_encode_String(String raw) { + // Codec=Cst (C-struct based), see doc to use other codecs + return cst_encode_list_prim_u_8_strict(utf8.encoder.convert(raw)); + } + + @protected + ffi.Pointer + cst_encode_box_autoadd_prepare_receive_request( + PrepareReceiveRequest raw) { + // Codec=Cst (C-struct based), see doc to use other codecs + final ptr = wire.cst_new_box_autoadd_prepare_receive_request(); + cst_api_fill_to_wire_prepare_receive_request(raw, ptr.ref); + return ptr; + } + + @protected + ffi.Pointer + cst_encode_box_autoadd_prepare_receive_response( + PrepareReceiveResponse raw) { + // Codec=Cst (C-struct based), see doc to use other codecs + final ptr = wire.cst_new_box_autoadd_prepare_receive_response(); + cst_api_fill_to_wire_prepare_receive_response(raw, ptr.ref); + return ptr; + } + + @protected + ffi.Pointer + cst_encode_box_autoadd_prepare_send_response(PrepareSendResponse raw) { + // Codec=Cst (C-struct based), see doc to use other codecs + final ptr = wire.cst_new_box_autoadd_prepare_send_response(); + cst_api_fill_to_wire_prepare_send_response(raw, ptr.ref); + return ptr; + } + + @protected + ffi.Pointer cst_encode_box_autoadd_u_32(int raw) { + // Codec=Cst (C-struct based), see doc to use other codecs + return wire.cst_new_box_autoadd_u_32(cst_encode_u_32(raw)); + } + + @protected + ffi.Pointer cst_encode_box_autoadd_u_64(int raw) { + // Codec=Cst (C-struct based), see doc to use other codecs + return wire.cst_new_box_autoadd_u_64(cst_encode_u_64(raw)); + } + + @protected + ffi.Pointer cst_encode_list_payment( + List raw) { + // Codec=Cst (C-struct based), see doc to use other codecs + final ans = wire.cst_new_list_payment(raw.length); + for (var i = 0; i < raw.length; ++i) { + cst_api_fill_to_wire_payment(raw[i], ans.ref.ptr[i]); + } + return ans; + } + + @protected + ffi.Pointer cst_encode_list_prim_u_8_strict( + Uint8List raw) { + // Codec=Cst (C-struct based), see doc to use other codecs + final ans = wire.cst_new_list_prim_u_8_strict(raw.length); + ans.ref.ptr.asTypedList(raw.length).setAll(0, raw); + return ans; + } + + @protected + ffi.Pointer cst_encode_opt_String( + String? raw) { + // Codec=Cst (C-struct based), see doc to use other codecs + return raw == null ? ffi.nullptr : cst_encode_String(raw); + } + + @protected + ffi.Pointer cst_encode_opt_box_autoadd_u_32(int? raw) { + // Codec=Cst (C-struct based), see doc to use other codecs + return raw == null ? ffi.nullptr : cst_encode_box_autoadd_u_32(raw); + } + + @protected + ffi.Pointer cst_encode_opt_box_autoadd_u_64(int? raw) { + // Codec=Cst (C-struct based), see doc to use other codecs + return raw == null ? ffi.nullptr : cst_encode_box_autoadd_u_64(raw); + } + + @protected + int cst_encode_u_64(int raw) { + // Codec=Cst (C-struct based), see doc to use other codecs + return raw.toInt(); + } + + @protected + void cst_api_fill_to_wire_box_autoadd_prepare_receive_request( + PrepareReceiveRequest apiObj, + ffi.Pointer wireObj) { + cst_api_fill_to_wire_prepare_receive_request(apiObj, wireObj.ref); + } + + @protected + void cst_api_fill_to_wire_box_autoadd_prepare_receive_response( + PrepareReceiveResponse apiObj, + ffi.Pointer wireObj) { + cst_api_fill_to_wire_prepare_receive_response(apiObj, wireObj.ref); + } + + @protected + void cst_api_fill_to_wire_box_autoadd_prepare_send_response( + PrepareSendResponse apiObj, + ffi.Pointer wireObj) { + cst_api_fill_to_wire_prepare_send_response(apiObj, wireObj.ref); + } + + @protected + void cst_api_fill_to_wire_payment(Payment apiObj, wire_cst_payment wireObj) { + wireObj.id = cst_encode_opt_String(apiObj.id); + wireObj.timestamp = cst_encode_opt_box_autoadd_u_32(apiObj.timestamp); + wireObj.amount_sat = cst_encode_u_64(apiObj.amountSat); + wireObj.fees_sat = cst_encode_opt_box_autoadd_u_64(apiObj.feesSat); + wireObj.payment_type = cst_encode_payment_type(apiObj.paymentType); + wireObj.invoice = cst_encode_opt_String(apiObj.invoice); + } + + @protected + void cst_api_fill_to_wire_payment_error( + PaymentError apiObj, wire_cst_payment_error wireObj) { + if (apiObj is PaymentError_AmountOutOfRange) { + wireObj.tag = 0; + return; + } + if (apiObj is PaymentError_AlreadyClaimed) { + wireObj.tag = 1; + return; + } + if (apiObj is PaymentError_Generic) { + var pre_err = cst_encode_String(apiObj.err); + wireObj.tag = 2; + wireObj.kind.Generic.err = pre_err; + return; + } + if (apiObj is PaymentError_InvalidInvoice) { + wireObj.tag = 3; + return; + } + if (apiObj is PaymentError_InvalidPreimage) { + wireObj.tag = 4; + return; + } + if (apiObj is PaymentError_LwkError) { + var pre_err = cst_encode_String(apiObj.err); + wireObj.tag = 5; + wireObj.kind.LwkError.err = pre_err; + return; + } + if (apiObj is PaymentError_PairsNotFound) { + wireObj.tag = 6; + return; + } + if (apiObj is PaymentError_PersistError) { + wireObj.tag = 7; + return; + } + if (apiObj is PaymentError_SendError) { + var pre_err = cst_encode_String(apiObj.err); + wireObj.tag = 8; + wireObj.kind.SendError.err = pre_err; + return; + } + if (apiObj is PaymentError_SignerError) { + var pre_err = cst_encode_String(apiObj.err); + wireObj.tag = 9; + wireObj.kind.SignerError.err = pre_err; + return; + } + } + + @protected + void cst_api_fill_to_wire_prepare_receive_request( + PrepareReceiveRequest apiObj, wire_cst_prepare_receive_request wireObj) { + wireObj.payer_amount_sat = + cst_encode_opt_box_autoadd_u_64(apiObj.payerAmountSat); + wireObj.receiver_amount_sat = + cst_encode_opt_box_autoadd_u_64(apiObj.receiverAmountSat); + } + + @protected + void cst_api_fill_to_wire_prepare_receive_response( + PrepareReceiveResponse apiObj, + wire_cst_prepare_receive_response wireObj) { + wireObj.pair_hash = cst_encode_String(apiObj.pairHash); + wireObj.payer_amount_sat = cst_encode_u_64(apiObj.payerAmountSat); + wireObj.fees_sat = cst_encode_u_64(apiObj.feesSat); + } + + @protected + void cst_api_fill_to_wire_prepare_send_response( + PrepareSendResponse apiObj, wire_cst_prepare_send_response wireObj) { + wireObj.id = cst_encode_String(apiObj.id); + wireObj.payer_amount_sat = cst_encode_u_64(apiObj.payerAmountSat); + wireObj.receiver_amount_sat = cst_encode_u_64(apiObj.receiverAmountSat); + wireObj.total_fees = cst_encode_u_64(apiObj.totalFees); + wireObj.funding_address = cst_encode_String(apiObj.fundingAddress); + wireObj.invoice = cst_encode_String(apiObj.invoice); + } + + @protected + void cst_api_fill_to_wire_receive_payment_response( + ReceivePaymentResponse apiObj, + wire_cst_receive_payment_response wireObj) { + wireObj.id = cst_encode_String(apiObj.id); + wireObj.invoice = cst_encode_String(apiObj.invoice); + } + + @protected + void cst_api_fill_to_wire_send_payment_response( + SendPaymentResponse apiObj, wire_cst_send_payment_response wireObj) { + wireObj.txid = cst_encode_String(apiObj.txid); + } + + @protected + void cst_api_fill_to_wire_wallet_info( + WalletInfo apiObj, wire_cst_wallet_info wireObj) { + wireObj.balance_sat = cst_encode_u_64(apiObj.balanceSat); + wireObj.pubkey = cst_encode_String(apiObj.pubkey); + } + + @protected + int cst_encode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockLBtcReverseRecovery( + LBtcReverseRecovery raw); + + @protected + int cst_encode_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockLBtcReverseRecovery( + LBtcReverseRecovery raw); + + @protected + bool cst_encode_bool(bool raw); + + @protected + int cst_encode_i_32(int raw); + + @protected + int cst_encode_network(Network raw); + + @protected + int cst_encode_payment_type(PaymentType raw); + + @protected + int cst_encode_u_32(int raw); + + @protected + int cst_encode_u_8(int raw); + + @protected + void cst_encode_unit(void raw); + + @protected + int cst_encode_usize(int raw); + + @protected + void sse_encode_AnyhowException( + AnyhowException self, SseSerializer serializer); + + @protected + void + sse_encode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockLBtcReverseRecovery( + LBtcReverseRecovery self, SseSerializer serializer); + + @protected + void + sse_encode_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockLBtcReverseRecovery( + LBtcReverseRecovery self, SseSerializer serializer); + + @protected + void sse_encode_String(String self, SseSerializer serializer); + + @protected + void sse_encode_bool(bool self, SseSerializer serializer); + + @protected + void sse_encode_box_autoadd_prepare_receive_request( + PrepareReceiveRequest self, SseSerializer serializer); + + @protected + void sse_encode_box_autoadd_prepare_receive_response( + PrepareReceiveResponse self, SseSerializer serializer); + + @protected + void sse_encode_box_autoadd_prepare_send_response( + PrepareSendResponse self, SseSerializer serializer); + + @protected + void sse_encode_box_autoadd_u_32(int self, SseSerializer serializer); + + @protected + void sse_encode_box_autoadd_u_64(int self, SseSerializer serializer); + + @protected + void sse_encode_i_32(int self, SseSerializer serializer); + + @protected + void sse_encode_list_payment(List self, SseSerializer serializer); + + @protected + void sse_encode_list_prim_u_8_strict( + Uint8List self, SseSerializer serializer); + + @protected + void sse_encode_network(Network self, SseSerializer serializer); + + @protected + void sse_encode_opt_String(String? self, SseSerializer serializer); + + @protected + void sse_encode_opt_box_autoadd_u_32(int? self, SseSerializer serializer); + + @protected + void sse_encode_opt_box_autoadd_u_64(int? self, SseSerializer serializer); + + @protected + void sse_encode_payment(Payment self, SseSerializer serializer); + + @protected + void sse_encode_payment_error(PaymentError self, SseSerializer serializer); + + @protected + void sse_encode_payment_type(PaymentType self, SseSerializer serializer); + + @protected + void sse_encode_prepare_receive_request( + PrepareReceiveRequest self, SseSerializer serializer); + + @protected + void sse_encode_prepare_receive_response( + PrepareReceiveResponse self, SseSerializer serializer); + + @protected + void sse_encode_prepare_send_response( + PrepareSendResponse self, SseSerializer serializer); + + @protected + void sse_encode_receive_payment_response( + ReceivePaymentResponse self, SseSerializer serializer); + + @protected + void sse_encode_send_payment_response( + SendPaymentResponse self, SseSerializer serializer); + + @protected + void sse_encode_u_32(int self, SseSerializer serializer); + + @protected + void sse_encode_u_64(int self, SseSerializer serializer); + + @protected + void sse_encode_u_8(int self, SseSerializer serializer); + + @protected + void sse_encode_unit(void self, SseSerializer serializer); + + @protected + void sse_encode_usize(int self, SseSerializer serializer); + + @protected + void sse_encode_wallet_info(WalletInfo self, SseSerializer serializer); +} + +// Section: wire_class + +// ignore_for_file: camel_case_types, non_constant_identifier_names, avoid_positional_boolean_parameters, annotate_overrides, constant_identifier_names +// AUTO GENERATED FILE, DO NOT EDIT. +// +// Generated by `package:ffigen`. +// ignore_for_file: type=lint + +/// generated by flutter_rust_bridge +class RustLibWire implements BaseWire { + factory RustLibWire.fromExternalLibrary(ExternalLibrary lib) => + RustLibWire(lib.ffiDynamicLibrary); + + /// Holds the symbol lookup function. + final ffi.Pointer Function(String symbolName) + _lookup; + + /// The symbols are looked up in [dynamicLibrary]. + RustLibWire(ffi.DynamicLibrary dynamicLibrary) + : _lookup = dynamicLibrary.lookup; + + /// The symbols are looked up with [lookup]. + RustLibWire.fromLookup( + ffi.Pointer Function(String symbolName) + lookup) + : _lookup = lookup; + + void store_dart_post_cobject( + DartPostCObjectFnType ptr, + ) { + return _store_dart_post_cobject( + ptr, + ); + } + + late final _store_dart_post_cobjectPtr = + _lookup>( + 'store_dart_post_cobject'); + late final _store_dart_post_cobject = _store_dart_post_cobjectPtr + .asFunction(); + + void wire_backup( + int port_, + ) { + return _wire_backup( + port_, + ); + } + + late final _wire_backupPtr = + _lookup>( + 'frbgen_breez_liquid_wire_backup'); + late final _wire_backup = _wire_backupPtr.asFunction(); + + void wire_connect( + int port_, + ffi.Pointer mnemonic, + ffi.Pointer data_dir, + int network, + ) { + return _wire_connect( + port_, + mnemonic, + data_dir, + network, + ); + } + + late final _wire_connectPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Int64, + ffi.Pointer, + ffi.Pointer, + ffi.Int32)>>('frbgen_breez_liquid_wire_connect'); + late final _wire_connect = _wire_connectPtr.asFunction< + void Function(int, ffi.Pointer, + ffi.Pointer, int)>(); + + void wire_empty_wallet_cache( + int port_, + ) { + return _wire_empty_wallet_cache( + port_, + ); + } + + late final _wire_empty_wallet_cachePtr = + _lookup>( + 'frbgen_breez_liquid_wire_empty_wallet_cache'); + late final _wire_empty_wallet_cache = + _wire_empty_wallet_cachePtr.asFunction(); + + void wire_get_info( + int port_, + bool with_scan, + ) { + return _wire_get_info( + port_, + with_scan, + ); + } + + late final _wire_get_infoPtr = + _lookup>( + 'frbgen_breez_liquid_wire_get_info'); + late final _wire_get_info = + _wire_get_infoPtr.asFunction(); + + void wire_list_payments( + int port_, + bool with_scan, + bool include_pending, + ) { + return _wire_list_payments( + port_, + with_scan, + include_pending, + ); + } + + late final _wire_list_paymentsPtr = _lookup< + ffi.NativeFunction>( + 'frbgen_breez_liquid_wire_list_payments'); + late final _wire_list_payments = + _wire_list_paymentsPtr.asFunction(); + + void wire_prepare_receive_payment( + int port_, + ffi.Pointer req, + ) { + return _wire_prepare_receive_payment( + port_, + req, + ); + } + + late final _wire_prepare_receive_paymentPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Int64, ffi.Pointer)>>( + 'frbgen_breez_liquid_wire_prepare_receive_payment'); + late final _wire_prepare_receive_payment = + _wire_prepare_receive_paymentPtr.asFunction< + void Function(int, ffi.Pointer)>(); + + void wire_prepare_send_payment( + int port_, + ffi.Pointer invoice, + ) { + return _wire_prepare_send_payment( + port_, + invoice, + ); + } + + late final _wire_prepare_send_paymentPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Int64, ffi.Pointer)>>( + 'frbgen_breez_liquid_wire_prepare_send_payment'); + late final _wire_prepare_send_payment = + _wire_prepare_send_paymentPtr.asFunction< + void Function(int, ffi.Pointer)>(); + + void wire_receive_payment( + int port_, + ffi.Pointer req, + ) { + return _wire_receive_payment( + port_, + req, + ); + } + + late final _wire_receive_paymentPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Int64, ffi.Pointer)>>( + 'frbgen_breez_liquid_wire_receive_payment'); + late final _wire_receive_payment = _wire_receive_paymentPtr.asFunction< + void Function(int, ffi.Pointer)>(); + + void wire_recover_funds( + int port_, + int recovery, + ) { + return _wire_recover_funds( + port_, + recovery, + ); + } + + late final _wire_recover_fundsPtr = + _lookup>( + 'frbgen_breez_liquid_wire_recover_funds'); + late final _wire_recover_funds = + _wire_recover_fundsPtr.asFunction(); + + void wire_restore( + int port_, + ffi.Pointer backup_path, + ) { + return _wire_restore( + port_, + backup_path, + ); + } + + late final _wire_restorePtr = _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Int64, ffi.Pointer)>>( + 'frbgen_breez_liquid_wire_restore'); + late final _wire_restore = _wire_restorePtr.asFunction< + void Function(int, ffi.Pointer)>(); + + void wire_send_payment( + int port_, + ffi.Pointer req, + ) { + return _wire_send_payment( + port_, + req, + ); + } + + late final _wire_send_paymentPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Int64, ffi.Pointer)>>( + 'frbgen_breez_liquid_wire_send_payment'); + late final _wire_send_payment = _wire_send_paymentPtr.asFunction< + void Function(int, ffi.Pointer)>(); + + void + rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockLBtcReverseRecovery( + ffi.Pointer ptr, + ) { + return _rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockLBtcReverseRecovery( + ptr, + ); + } + + late final _rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockLBtcReverseRecoveryPtr = + _lookup)>>( + 'frbgen_breez_liquid_rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockLBtcReverseRecovery'); + late final _rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockLBtcReverseRecovery = + _rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockLBtcReverseRecoveryPtr + .asFunction)>(); + + void + rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockLBtcReverseRecovery( + ffi.Pointer ptr, + ) { + return _rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockLBtcReverseRecovery( + ptr, + ); + } + + late final _rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockLBtcReverseRecoveryPtr = + _lookup)>>( + 'frbgen_breez_liquid_rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockLBtcReverseRecovery'); + late final _rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockLBtcReverseRecovery = + _rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockLBtcReverseRecoveryPtr + .asFunction)>(); + + ffi.Pointer + cst_new_box_autoadd_prepare_receive_request() { + return _cst_new_box_autoadd_prepare_receive_request(); + } + + late final _cst_new_box_autoadd_prepare_receive_requestPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function()>>( + 'frbgen_breez_liquid_cst_new_box_autoadd_prepare_receive_request'); + late final _cst_new_box_autoadd_prepare_receive_request = + _cst_new_box_autoadd_prepare_receive_requestPtr.asFunction< + ffi.Pointer Function()>(); + + ffi.Pointer + cst_new_box_autoadd_prepare_receive_response() { + return _cst_new_box_autoadd_prepare_receive_response(); + } + + late final _cst_new_box_autoadd_prepare_receive_responsePtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function()>>( + 'frbgen_breez_liquid_cst_new_box_autoadd_prepare_receive_response'); + late final _cst_new_box_autoadd_prepare_receive_response = + _cst_new_box_autoadd_prepare_receive_responsePtr.asFunction< + ffi.Pointer Function()>(); + + ffi.Pointer + cst_new_box_autoadd_prepare_send_response() { + return _cst_new_box_autoadd_prepare_send_response(); + } + + late final _cst_new_box_autoadd_prepare_send_responsePtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function()>>( + 'frbgen_breez_liquid_cst_new_box_autoadd_prepare_send_response'); + late final _cst_new_box_autoadd_prepare_send_response = + _cst_new_box_autoadd_prepare_send_responsePtr + .asFunction Function()>(); + + ffi.Pointer cst_new_box_autoadd_u_32( + int value, + ) { + return _cst_new_box_autoadd_u_32( + value, + ); + } + + late final _cst_new_box_autoadd_u_32Ptr = + _lookup Function(ffi.Uint32)>>( + 'frbgen_breez_liquid_cst_new_box_autoadd_u_32'); + late final _cst_new_box_autoadd_u_32 = _cst_new_box_autoadd_u_32Ptr + .asFunction Function(int)>(); + + ffi.Pointer cst_new_box_autoadd_u_64( + int value, + ) { + return _cst_new_box_autoadd_u_64( + value, + ); + } + + late final _cst_new_box_autoadd_u_64Ptr = + _lookup Function(ffi.Uint64)>>( + 'frbgen_breez_liquid_cst_new_box_autoadd_u_64'); + late final _cst_new_box_autoadd_u_64 = _cst_new_box_autoadd_u_64Ptr + .asFunction Function(int)>(); + + ffi.Pointer cst_new_list_payment( + int len, + ) { + return _cst_new_list_payment( + len, + ); + } + + late final _cst_new_list_paymentPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Int32)>>('frbgen_breez_liquid_cst_new_list_payment'); + late final _cst_new_list_payment = _cst_new_list_paymentPtr + .asFunction Function(int)>(); + + ffi.Pointer cst_new_list_prim_u_8_strict( + int len, + ) { + return _cst_new_list_prim_u_8_strict( + len, + ); + } + + late final _cst_new_list_prim_u_8_strictPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Int32)>>('frbgen_breez_liquid_cst_new_list_prim_u_8_strict'); + late final _cst_new_list_prim_u_8_strict = _cst_new_list_prim_u_8_strictPtr + .asFunction Function(int)>(); + + int dummy_method_to_enforce_bundling() { + return _dummy_method_to_enforce_bundling(); + } + + late final _dummy_method_to_enforce_bundlingPtr = + _lookup>( + 'dummy_method_to_enforce_bundling'); + late final _dummy_method_to_enforce_bundling = + _dummy_method_to_enforce_bundlingPtr.asFunction(); +} + +typedef DartPostCObjectFnType = ffi.Pointer< + ffi.NativeFunction< + ffi.Bool Function(DartPort port_id, ffi.Pointer message)>>; +typedef DartPort = ffi.Int64; + +final class wire_cst_list_prim_u_8_strict extends ffi.Struct { + external ffi.Pointer ptr; + + @ffi.Int32() + external int len; +} + +final class wire_cst_prepare_receive_request extends ffi.Struct { + external ffi.Pointer payer_amount_sat; + + external ffi.Pointer receiver_amount_sat; +} + +final class wire_cst_prepare_receive_response extends ffi.Struct { + external ffi.Pointer pair_hash; + + @ffi.Uint64() + external int payer_amount_sat; + + @ffi.Uint64() + external int fees_sat; +} + +final class wire_cst_prepare_send_response extends ffi.Struct { + external ffi.Pointer id; + + @ffi.Uint64() + external int payer_amount_sat; + + @ffi.Uint64() + external int receiver_amount_sat; + + @ffi.Uint64() + external int total_fees; + + external ffi.Pointer funding_address; + + external ffi.Pointer invoice; +} + +final class wire_cst_payment extends ffi.Struct { + external ffi.Pointer id; + + external ffi.Pointer timestamp; + + @ffi.Uint64() + external int amount_sat; + + external ffi.Pointer fees_sat; + + @ffi.Int32() + external int payment_type; + + external ffi.Pointer invoice; +} + +final class wire_cst_list_payment extends ffi.Struct { + external ffi.Pointer ptr; + + @ffi.Int32() + external int len; +} + +final class wire_cst_PaymentError_Generic extends ffi.Struct { + external ffi.Pointer err; +} + +final class wire_cst_PaymentError_LwkError extends ffi.Struct { + external ffi.Pointer err; +} + +final class wire_cst_PaymentError_SendError extends ffi.Struct { + external ffi.Pointer err; +} + +final class wire_cst_PaymentError_SignerError extends ffi.Struct { + external ffi.Pointer err; +} + +final class PaymentErrorKind extends ffi.Union { + external wire_cst_PaymentError_Generic Generic; + + external wire_cst_PaymentError_LwkError LwkError; + + external wire_cst_PaymentError_SendError SendError; + + external wire_cst_PaymentError_SignerError SignerError; +} + +final class wire_cst_payment_error extends ffi.Struct { + @ffi.Int32() + external int tag; + + external PaymentErrorKind kind; +} + +final class wire_cst_receive_payment_response extends ffi.Struct { + external ffi.Pointer id; + + external ffi.Pointer invoice; +} + +final class wire_cst_send_payment_response extends ffi.Struct { + external ffi.Pointer txid; +} + +final class wire_cst_wallet_info extends ffi.Struct { + @ffi.Uint64() + external int balance_sat; + + external ffi.Pointer pubkey; +} + +const double LIQUID_CLAIM_TX_FEERATE = 0.1; diff --git a/lib/ls-sdk-flutter/packages/breez_liquid/lib/src/model.dart b/lib/ls-sdk-flutter/packages/breez_liquid/lib/src/model.dart new file mode 100644 index 0000000..c222d76 --- /dev/null +++ b/lib/ls-sdk-flutter/packages/breez_liquid/lib/src/model.dart @@ -0,0 +1,207 @@ +// This file is automatically generated, so please do not edit it. +// Generated by `flutter_rust_bridge`@ 2.0.0-dev.32. + +// ignore_for_file: invalid_use_of_internal_member, unused_import, unnecessary_import + +import 'frb_generated.dart'; +import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart'; + +enum Network { + liquid, + liquidTestnet, + ; +} + +class Payment { + final String? id; + final int? timestamp; + final int amountSat; + final int? feesSat; + final PaymentType paymentType; + + /// Only for [PaymentType::PendingReceive] + final String? invoice; + + const Payment({ + this.id, + this.timestamp, + required this.amountSat, + this.feesSat, + required this.paymentType, + this.invoice, + }); + + @override + int get hashCode => + id.hashCode ^ + timestamp.hashCode ^ + amountSat.hashCode ^ + feesSat.hashCode ^ + paymentType.hashCode ^ + invoice.hashCode; + + @override + bool operator ==(Object other) => + identical(this, other) || + other is Payment && + runtimeType == other.runtimeType && + id == other.id && + timestamp == other.timestamp && + amountSat == other.amountSat && + feesSat == other.feesSat && + paymentType == other.paymentType && + invoice == other.invoice; +} + +enum PaymentType { + sent, + received, + pendingReceive, + pendingSend, + ; +} + +class PrepareReceiveRequest { + final int? payerAmountSat; + final int? receiverAmountSat; + + const PrepareReceiveRequest({ + this.payerAmountSat, + this.receiverAmountSat, + }); + + @override + int get hashCode => payerAmountSat.hashCode ^ receiverAmountSat.hashCode; + + @override + bool operator ==(Object other) => + identical(this, other) || + other is PrepareReceiveRequest && + runtimeType == other.runtimeType && + payerAmountSat == other.payerAmountSat && + receiverAmountSat == other.receiverAmountSat; +} + +class PrepareReceiveResponse { + final String pairHash; + final int payerAmountSat; + final int feesSat; + + const PrepareReceiveResponse({ + required this.pairHash, + required this.payerAmountSat, + required this.feesSat, + }); + + @override + int get hashCode => + pairHash.hashCode ^ payerAmountSat.hashCode ^ feesSat.hashCode; + + @override + bool operator ==(Object other) => + identical(this, other) || + other is PrepareReceiveResponse && + runtimeType == other.runtimeType && + pairHash == other.pairHash && + payerAmountSat == other.payerAmountSat && + feesSat == other.feesSat; +} + +class PrepareSendResponse { + final String id; + final int payerAmountSat; + final int receiverAmountSat; + final int totalFees; + final String fundingAddress; + final String invoice; + + const PrepareSendResponse({ + required this.id, + required this.payerAmountSat, + required this.receiverAmountSat, + required this.totalFees, + required this.fundingAddress, + required this.invoice, + }); + + @override + int get hashCode => + id.hashCode ^ + payerAmountSat.hashCode ^ + receiverAmountSat.hashCode ^ + totalFees.hashCode ^ + fundingAddress.hashCode ^ + invoice.hashCode; + + @override + bool operator ==(Object other) => + identical(this, other) || + other is PrepareSendResponse && + runtimeType == other.runtimeType && + id == other.id && + payerAmountSat == other.payerAmountSat && + receiverAmountSat == other.receiverAmountSat && + totalFees == other.totalFees && + fundingAddress == other.fundingAddress && + invoice == other.invoice; +} + +class ReceivePaymentResponse { + final String id; + final String invoice; + + const ReceivePaymentResponse({ + required this.id, + required this.invoice, + }); + + @override + int get hashCode => id.hashCode ^ invoice.hashCode; + + @override + bool operator ==(Object other) => + identical(this, other) || + other is ReceivePaymentResponse && + runtimeType == other.runtimeType && + id == other.id && + invoice == other.invoice; +} + +class SendPaymentResponse { + final String txid; + + const SendPaymentResponse({ + required this.txid, + }); + + @override + int get hashCode => txid.hashCode; + + @override + bool operator ==(Object other) => + identical(this, other) || + other is SendPaymentResponse && + runtimeType == other.runtimeType && + txid == other.txid; +} + +class WalletInfo { + final int balanceSat; + final String pubkey; + + const WalletInfo({ + required this.balanceSat, + required this.pubkey, + }); + + @override + int get hashCode => balanceSat.hashCode ^ pubkey.hashCode; + + @override + bool operator ==(Object other) => + identical(this, other) || + other is WalletInfo && + runtimeType == other.runtimeType && + balanceSat == other.balanceSat && + pubkey == other.pubkey; +} diff --git a/lib/ls-sdk-flutter/packages/flutter_breez_liquid/ios/Classes/ls_sdk.h b/lib/ls-sdk-flutter/packages/flutter_breez_liquid/ios/Classes/ls_sdk.h new file mode 100644 index 0000000..d59f50a --- /dev/null +++ b/lib/ls-sdk-flutter/packages/flutter_breez_liquid/ios/Classes/ls_sdk.h @@ -0,0 +1,175 @@ +#include +#include +#include +// EXTRA BEGIN +typedef struct DartCObject *WireSyncRust2DartDco; +typedef struct WireSyncRust2DartSse { + uint8_t *ptr; + int32_t len; +} WireSyncRust2DartSse; + +typedef int64_t DartPort; +typedef bool (*DartPostCObjectFnType)(DartPort port_id, void *message); +void store_dart_post_cobject(DartPostCObjectFnType ptr); +// EXTRA END +typedef struct _Dart_Handle* Dart_Handle; + +/** + * Claim tx feerate for Receive, in sats per vbyte. + * Since the Liquid blocks are consistently empty for now, we hardcode the minimum feerate. + */ +#define LIQUID_CLAIM_TX_FEERATE 0.1 + +typedef struct wire_cst_list_prim_u_8_strict { + uint8_t *ptr; + int32_t len; +} wire_cst_list_prim_u_8_strict; + +typedef struct wire_cst_prepare_receive_request { + uint64_t *payer_amount_sat; + uint64_t *receiver_amount_sat; +} wire_cst_prepare_receive_request; + +typedef struct wire_cst_prepare_receive_response { + struct wire_cst_list_prim_u_8_strict *pair_hash; + uint64_t payer_amount_sat; + uint64_t fees_sat; +} wire_cst_prepare_receive_response; + +typedef struct wire_cst_prepare_send_response { + struct wire_cst_list_prim_u_8_strict *id; + uint64_t payer_amount_sat; + uint64_t receiver_amount_sat; + uint64_t total_fees; + struct wire_cst_list_prim_u_8_strict *funding_address; + struct wire_cst_list_prim_u_8_strict *invoice; +} wire_cst_prepare_send_response; + +typedef struct wire_cst_payment { + struct wire_cst_list_prim_u_8_strict *id; + uint32_t *timestamp; + uint64_t amount_sat; + uint64_t *fees_sat; + int32_t payment_type; + struct wire_cst_list_prim_u_8_strict *invoice; +} wire_cst_payment; + +typedef struct wire_cst_list_payment { + struct wire_cst_payment *ptr; + int32_t len; +} wire_cst_list_payment; + +typedef struct wire_cst_PaymentError_Generic { + struct wire_cst_list_prim_u_8_strict *err; +} wire_cst_PaymentError_Generic; + +typedef struct wire_cst_PaymentError_LwkError { + struct wire_cst_list_prim_u_8_strict *err; +} wire_cst_PaymentError_LwkError; + +typedef struct wire_cst_PaymentError_SendError { + struct wire_cst_list_prim_u_8_strict *err; +} wire_cst_PaymentError_SendError; + +typedef struct wire_cst_PaymentError_SignerError { + struct wire_cst_list_prim_u_8_strict *err; +} wire_cst_PaymentError_SignerError; + +typedef union PaymentErrorKind { + struct wire_cst_PaymentError_Generic Generic; + struct wire_cst_PaymentError_LwkError LwkError; + struct wire_cst_PaymentError_SendError SendError; + struct wire_cst_PaymentError_SignerError SignerError; +} PaymentErrorKind; + +typedef struct wire_cst_payment_error { + int32_t tag; + union PaymentErrorKind kind; +} wire_cst_payment_error; + +typedef struct wire_cst_receive_payment_response { + struct wire_cst_list_prim_u_8_strict *id; + struct wire_cst_list_prim_u_8_strict *invoice; +} wire_cst_receive_payment_response; + +typedef struct wire_cst_send_payment_response { + struct wire_cst_list_prim_u_8_strict *txid; +} wire_cst_send_payment_response; + +typedef struct wire_cst_wallet_info { + uint64_t balance_sat; + struct wire_cst_list_prim_u_8_strict *pubkey; +} wire_cst_wallet_info; + +void frbgen_breez_liquid_wire_backup(int64_t port_); + +void frbgen_breez_liquid_wire_connect(int64_t port_, + struct wire_cst_list_prim_u_8_strict *mnemonic, + struct wire_cst_list_prim_u_8_strict *data_dir, + int32_t network); + +void frbgen_breez_liquid_wire_empty_wallet_cache(int64_t port_); + +void frbgen_breez_liquid_wire_get_info(int64_t port_, bool with_scan); + +void frbgen_breez_liquid_wire_list_payments(int64_t port_, bool with_scan, bool include_pending); + +void frbgen_breez_liquid_wire_prepare_receive_payment(int64_t port_, + struct wire_cst_prepare_receive_request *req); + +void frbgen_breez_liquid_wire_prepare_send_payment(int64_t port_, + struct wire_cst_list_prim_u_8_strict *invoice); + +void frbgen_breez_liquid_wire_receive_payment(int64_t port_, + struct wire_cst_prepare_receive_response *req); + +void frbgen_breez_liquid_wire_recover_funds(int64_t port_, uintptr_t recovery); + +void frbgen_breez_liquid_wire_restore(int64_t port_, + struct wire_cst_list_prim_u_8_strict *backup_path); + +void frbgen_breez_liquid_wire_send_payment(int64_t port_, + struct wire_cst_prepare_send_response *req); + +void frbgen_breez_liquid_rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockLBtcReverseRecovery(const void *ptr); + +void frbgen_breez_liquid_rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockLBtcReverseRecovery(const void *ptr); + +struct wire_cst_prepare_receive_request *frbgen_breez_liquid_cst_new_box_autoadd_prepare_receive_request(void); + +struct wire_cst_prepare_receive_response *frbgen_breez_liquid_cst_new_box_autoadd_prepare_receive_response(void); + +struct wire_cst_prepare_send_response *frbgen_breez_liquid_cst_new_box_autoadd_prepare_send_response(void); + +uint32_t *frbgen_breez_liquid_cst_new_box_autoadd_u_32(uint32_t value); + +uint64_t *frbgen_breez_liquid_cst_new_box_autoadd_u_64(uint64_t value); + +struct wire_cst_list_payment *frbgen_breez_liquid_cst_new_list_payment(int32_t len); + +struct wire_cst_list_prim_u_8_strict *frbgen_breez_liquid_cst_new_list_prim_u_8_strict(int32_t len); +static int64_t dummy_method_to_enforce_bundling(void) { + int64_t dummy_var = 0; + dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_prepare_receive_request); + dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_prepare_receive_response); + dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_prepare_send_response); + dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_u_32); + dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_u_64); + dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_list_payment); + dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_list_prim_u_8_strict); + dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockLBtcReverseRecovery); + dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockLBtcReverseRecovery); + dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_wire_backup); + dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_wire_connect); + dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_wire_empty_wallet_cache); + dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_wire_get_info); + dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_wire_list_payments); + dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_wire_prepare_receive_payment); + dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_wire_prepare_send_payment); + dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_wire_receive_payment); + dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_wire_recover_funds); + dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_wire_restore); + dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_wire_send_payment); + dummy_var ^= ((int64_t) (void*) store_dart_post_cobject); + return dummy_var; +} diff --git a/lib/ls-sdk-flutter/packages/flutter_breez_liquid/lib/flutter_breez_liquid_bindings_generated.dart b/lib/ls-sdk-flutter/packages/flutter_breez_liquid/lib/flutter_breez_liquid_bindings_generated.dart new file mode 100644 index 0000000..7e62574 --- /dev/null +++ b/lib/ls-sdk-flutter/packages/flutter_breez_liquid/lib/flutter_breez_liquid_bindings_generated.dart @@ -0,0 +1,530 @@ +// ignore_for_file: always_specify_types +// ignore_for_file: camel_case_types +// ignore_for_file: non_constant_identifier_names + +// AUTO GENERATED FILE, DO NOT EDIT. +// +// Generated by `package:ffigen`. +// ignore_for_file: type=lint +import 'dart:ffi' as ffi; + +/// Bindings for `src/flutter_breez_liquid.h`. +/// +/// Regenerate bindings with `flutter pub run ffigen --config ffigen.yaml`. +/// +class FlutterBreezLiquidBindings { + /// Holds the symbol lookup function. + final ffi.Pointer Function(String symbolName) + _lookup; + + /// The symbols are looked up in [dynamicLibrary]. + FlutterBreezLiquidBindings(ffi.DynamicLibrary dynamicLibrary) + : _lookup = dynamicLibrary.lookup; + + /// The symbols are looked up with [lookup]. + FlutterBreezLiquidBindings.fromLookup( + ffi.Pointer Function(String symbolName) + lookup) + : _lookup = lookup; + + void store_dart_post_cobject( + DartPostCObjectFnType ptr, + ) { + return _store_dart_post_cobject( + ptr, + ); + } + + late final _store_dart_post_cobjectPtr = + _lookup>( + 'store_dart_post_cobject'); + late final _store_dart_post_cobject = _store_dart_post_cobjectPtr + .asFunction(); + + void frbgen_breez_liquid_wire_backup( + int port_, + ) { + return _frbgen_breez_liquid_wire_backup( + port_, + ); + } + + late final _frbgen_breez_liquid_wire_backupPtr = + _lookup>( + 'frbgen_breez_liquid_wire_backup'); + late final _frbgen_breez_liquid_wire_backup = + _frbgen_breez_liquid_wire_backupPtr.asFunction(); + + void frbgen_breez_liquid_wire_connect( + int port_, + ffi.Pointer mnemonic, + ffi.Pointer data_dir, + int network, + ) { + return _frbgen_breez_liquid_wire_connect( + port_, + mnemonic, + data_dir, + network, + ); + } + + late final _frbgen_breez_liquid_wire_connectPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Int64, + ffi.Pointer, + ffi.Pointer, + ffi.Int32)>>('frbgen_breez_liquid_wire_connect'); + late final _frbgen_breez_liquid_wire_connect = + _frbgen_breez_liquid_wire_connectPtr.asFunction< + void Function(int, ffi.Pointer, + ffi.Pointer, int)>(); + + void frbgen_breez_liquid_wire_empty_wallet_cache( + int port_, + ) { + return _frbgen_breez_liquid_wire_empty_wallet_cache( + port_, + ); + } + + late final _frbgen_breez_liquid_wire_empty_wallet_cachePtr = + _lookup>( + 'frbgen_breez_liquid_wire_empty_wallet_cache'); + late final _frbgen_breez_liquid_wire_empty_wallet_cache = + _frbgen_breez_liquid_wire_empty_wallet_cachePtr + .asFunction(); + + void frbgen_breez_liquid_wire_get_info( + int port_, + bool with_scan, + ) { + return _frbgen_breez_liquid_wire_get_info( + port_, + with_scan, + ); + } + + late final _frbgen_breez_liquid_wire_get_infoPtr = + _lookup>( + 'frbgen_breez_liquid_wire_get_info'); + late final _frbgen_breez_liquid_wire_get_info = + _frbgen_breez_liquid_wire_get_infoPtr + .asFunction(); + + void frbgen_breez_liquid_wire_list_payments( + int port_, + bool with_scan, + bool include_pending, + ) { + return _frbgen_breez_liquid_wire_list_payments( + port_, + with_scan, + include_pending, + ); + } + + late final _frbgen_breez_liquid_wire_list_paymentsPtr = _lookup< + ffi.NativeFunction>( + 'frbgen_breez_liquid_wire_list_payments'); + late final _frbgen_breez_liquid_wire_list_payments = + _frbgen_breez_liquid_wire_list_paymentsPtr + .asFunction(); + + void frbgen_breez_liquid_wire_prepare_receive_payment( + int port_, + ffi.Pointer req, + ) { + return _frbgen_breez_liquid_wire_prepare_receive_payment( + port_, + req, + ); + } + + late final _frbgen_breez_liquid_wire_prepare_receive_paymentPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Int64, ffi.Pointer)>>( + 'frbgen_breez_liquid_wire_prepare_receive_payment'); + late final _frbgen_breez_liquid_wire_prepare_receive_payment = + _frbgen_breez_liquid_wire_prepare_receive_paymentPtr.asFunction< + void Function(int, ffi.Pointer)>(); + + void frbgen_breez_liquid_wire_prepare_send_payment( + int port_, + ffi.Pointer invoice, + ) { + return _frbgen_breez_liquid_wire_prepare_send_payment( + port_, + invoice, + ); + } + + late final _frbgen_breez_liquid_wire_prepare_send_paymentPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Int64, ffi.Pointer)>>( + 'frbgen_breez_liquid_wire_prepare_send_payment'); + late final _frbgen_breez_liquid_wire_prepare_send_payment = + _frbgen_breez_liquid_wire_prepare_send_paymentPtr.asFunction< + void Function(int, ffi.Pointer)>(); + + void frbgen_breez_liquid_wire_receive_payment( + int port_, + ffi.Pointer req, + ) { + return _frbgen_breez_liquid_wire_receive_payment( + port_, + req, + ); + } + + late final _frbgen_breez_liquid_wire_receive_paymentPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Int64, ffi.Pointer)>>( + 'frbgen_breez_liquid_wire_receive_payment'); + late final _frbgen_breez_liquid_wire_receive_payment = + _frbgen_breez_liquid_wire_receive_paymentPtr.asFunction< + void Function(int, ffi.Pointer)>(); + + void frbgen_breez_liquid_wire_recover_funds( + int port_, + int recovery, + ) { + return _frbgen_breez_liquid_wire_recover_funds( + port_, + recovery, + ); + } + + late final _frbgen_breez_liquid_wire_recover_fundsPtr = + _lookup>( + 'frbgen_breez_liquid_wire_recover_funds'); + late final _frbgen_breez_liquid_wire_recover_funds = + _frbgen_breez_liquid_wire_recover_fundsPtr + .asFunction(); + + void frbgen_breez_liquid_wire_restore( + int port_, + ffi.Pointer backup_path, + ) { + return _frbgen_breez_liquid_wire_restore( + port_, + backup_path, + ); + } + + late final _frbgen_breez_liquid_wire_restorePtr = _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Int64, ffi.Pointer)>>( + 'frbgen_breez_liquid_wire_restore'); + late final _frbgen_breez_liquid_wire_restore = + _frbgen_breez_liquid_wire_restorePtr.asFunction< + void Function(int, ffi.Pointer)>(); + + void frbgen_breez_liquid_wire_send_payment( + int port_, + ffi.Pointer req, + ) { + return _frbgen_breez_liquid_wire_send_payment( + port_, + req, + ); + } + + late final _frbgen_breez_liquid_wire_send_paymentPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Int64, ffi.Pointer)>>( + 'frbgen_breez_liquid_wire_send_payment'); + late final _frbgen_breez_liquid_wire_send_payment = + _frbgen_breez_liquid_wire_send_paymentPtr.asFunction< + void Function(int, ffi.Pointer)>(); + + void + frbgen_breez_liquid_rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockLBtcReverseRecovery( + ffi.Pointer ptr, + ) { + return _frbgen_breez_liquid_rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockLBtcReverseRecovery( + ptr, + ); + } + + late final _frbgen_breez_liquid_rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockLBtcReverseRecoveryPtr = + _lookup)>>( + 'frbgen_breez_liquid_rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockLBtcReverseRecovery'); + late final _frbgen_breez_liquid_rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockLBtcReverseRecovery = + _frbgen_breez_liquid_rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockLBtcReverseRecoveryPtr + .asFunction)>(); + + void + frbgen_breez_liquid_rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockLBtcReverseRecovery( + ffi.Pointer ptr, + ) { + return _frbgen_breez_liquid_rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockLBtcReverseRecovery( + ptr, + ); + } + + late final _frbgen_breez_liquid_rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockLBtcReverseRecoveryPtr = + _lookup)>>( + 'frbgen_breez_liquid_rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockLBtcReverseRecovery'); + late final _frbgen_breez_liquid_rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockLBtcReverseRecovery = + _frbgen_breez_liquid_rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockLBtcReverseRecoveryPtr + .asFunction)>(); + + ffi.Pointer + frbgen_breez_liquid_cst_new_box_autoadd_prepare_receive_request() { + return _frbgen_breez_liquid_cst_new_box_autoadd_prepare_receive_request(); + } + + late final _frbgen_breez_liquid_cst_new_box_autoadd_prepare_receive_requestPtr = + _lookup< + ffi.NativeFunction< + ffi.Pointer Function()>>( + 'frbgen_breez_liquid_cst_new_box_autoadd_prepare_receive_request'); + late final _frbgen_breez_liquid_cst_new_box_autoadd_prepare_receive_request = + _frbgen_breez_liquid_cst_new_box_autoadd_prepare_receive_requestPtr + .asFunction< + ffi.Pointer Function()>(); + + ffi.Pointer + frbgen_breez_liquid_cst_new_box_autoadd_prepare_receive_response() { + return _frbgen_breez_liquid_cst_new_box_autoadd_prepare_receive_response(); + } + + late final _frbgen_breez_liquid_cst_new_box_autoadd_prepare_receive_responsePtr = + _lookup< + ffi.NativeFunction< + ffi.Pointer Function()>>( + 'frbgen_breez_liquid_cst_new_box_autoadd_prepare_receive_response'); + late final _frbgen_breez_liquid_cst_new_box_autoadd_prepare_receive_response = + _frbgen_breez_liquid_cst_new_box_autoadd_prepare_receive_responsePtr + .asFunction< + ffi.Pointer Function()>(); + + ffi.Pointer + frbgen_breez_liquid_cst_new_box_autoadd_prepare_send_response() { + return _frbgen_breez_liquid_cst_new_box_autoadd_prepare_send_response(); + } + + late final _frbgen_breez_liquid_cst_new_box_autoadd_prepare_send_responsePtr = + _lookup< + ffi.NativeFunction< + ffi.Pointer Function()>>( + 'frbgen_breez_liquid_cst_new_box_autoadd_prepare_send_response'); + late final _frbgen_breez_liquid_cst_new_box_autoadd_prepare_send_response = + _frbgen_breez_liquid_cst_new_box_autoadd_prepare_send_responsePtr + .asFunction Function()>(); + + ffi.Pointer frbgen_breez_liquid_cst_new_box_autoadd_u_32( + int value, + ) { + return _frbgen_breez_liquid_cst_new_box_autoadd_u_32( + value, + ); + } + + late final _frbgen_breez_liquid_cst_new_box_autoadd_u_32Ptr = + _lookup Function(ffi.Uint32)>>( + 'frbgen_breez_liquid_cst_new_box_autoadd_u_32'); + late final _frbgen_breez_liquid_cst_new_box_autoadd_u_32 = + _frbgen_breez_liquid_cst_new_box_autoadd_u_32Ptr + .asFunction Function(int)>(); + + ffi.Pointer frbgen_breez_liquid_cst_new_box_autoadd_u_64( + int value, + ) { + return _frbgen_breez_liquid_cst_new_box_autoadd_u_64( + value, + ); + } + + late final _frbgen_breez_liquid_cst_new_box_autoadd_u_64Ptr = + _lookup Function(ffi.Uint64)>>( + 'frbgen_breez_liquid_cst_new_box_autoadd_u_64'); + late final _frbgen_breez_liquid_cst_new_box_autoadd_u_64 = + _frbgen_breez_liquid_cst_new_box_autoadd_u_64Ptr + .asFunction Function(int)>(); + + ffi.Pointer frbgen_breez_liquid_cst_new_list_payment( + int len, + ) { + return _frbgen_breez_liquid_cst_new_list_payment( + len, + ); + } + + late final _frbgen_breez_liquid_cst_new_list_paymentPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Int32)>>('frbgen_breez_liquid_cst_new_list_payment'); + late final _frbgen_breez_liquid_cst_new_list_payment = + _frbgen_breez_liquid_cst_new_list_paymentPtr + .asFunction Function(int)>(); + + ffi.Pointer + frbgen_breez_liquid_cst_new_list_prim_u_8_strict( + int len, + ) { + return _frbgen_breez_liquid_cst_new_list_prim_u_8_strict( + len, + ); + } + + late final _frbgen_breez_liquid_cst_new_list_prim_u_8_strictPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Int32)>>('frbgen_breez_liquid_cst_new_list_prim_u_8_strict'); + late final _frbgen_breez_liquid_cst_new_list_prim_u_8_strict = + _frbgen_breez_liquid_cst_new_list_prim_u_8_strictPtr.asFunction< + ffi.Pointer Function(int)>(); + + int dummy_method_to_enforce_bundling() { + return _dummy_method_to_enforce_bundling(); + } + + late final _dummy_method_to_enforce_bundlingPtr = + _lookup>( + 'dummy_method_to_enforce_bundling'); + late final _dummy_method_to_enforce_bundling = + _dummy_method_to_enforce_bundlingPtr.asFunction(); +} + +final class DartCObject extends ffi.Opaque {} + +final class WireSyncRust2DartSse extends ffi.Struct { + external ffi.Pointer ptr; + + @ffi.Int32() + external int len; +} + +typedef DartPostCObjectFnType + = ffi.Pointer>; +typedef DartPostCObjectFnTypeFunction = ffi.Bool Function( + DartPort port_id, ffi.Pointer message); +typedef DartDartPostCObjectFnTypeFunction = bool Function( + DartDartPort port_id, ffi.Pointer message); +typedef DartPort = ffi.Int64; +typedef DartDartPort = int; + +final class _Dart_Handle extends ffi.Opaque {} + +final class wire_cst_list_prim_u_8_strict extends ffi.Struct { + external ffi.Pointer ptr; + + @ffi.Int32() + external int len; +} + +final class wire_cst_prepare_receive_request extends ffi.Struct { + external ffi.Pointer payer_amount_sat; + + external ffi.Pointer receiver_amount_sat; +} + +final class wire_cst_prepare_receive_response extends ffi.Struct { + external ffi.Pointer pair_hash; + + @ffi.Uint64() + external int payer_amount_sat; + + @ffi.Uint64() + external int fees_sat; +} + +final class wire_cst_prepare_send_response extends ffi.Struct { + external ffi.Pointer id; + + @ffi.Uint64() + external int payer_amount_sat; + + @ffi.Uint64() + external int receiver_amount_sat; + + @ffi.Uint64() + external int total_fees; + + external ffi.Pointer funding_address; + + external ffi.Pointer invoice; +} + +final class wire_cst_payment extends ffi.Struct { + external ffi.Pointer id; + + external ffi.Pointer timestamp; + + @ffi.Uint64() + external int amount_sat; + + external ffi.Pointer fees_sat; + + @ffi.Int32() + external int payment_type; + + external ffi.Pointer invoice; +} + +final class wire_cst_list_payment extends ffi.Struct { + external ffi.Pointer ptr; + + @ffi.Int32() + external int len; +} + +final class wire_cst_PaymentError_Generic extends ffi.Struct { + external ffi.Pointer err; +} + +final class wire_cst_PaymentError_LwkError extends ffi.Struct { + external ffi.Pointer err; +} + +final class wire_cst_PaymentError_SendError extends ffi.Struct { + external ffi.Pointer err; +} + +final class wire_cst_PaymentError_SignerError extends ffi.Struct { + external ffi.Pointer err; +} + +final class PaymentErrorKind extends ffi.Union { + external wire_cst_PaymentError_Generic Generic; + + external wire_cst_PaymentError_LwkError LwkError; + + external wire_cst_PaymentError_SendError SendError; + + external wire_cst_PaymentError_SignerError SignerError; +} + +final class wire_cst_payment_error extends ffi.Struct { + @ffi.Int32() + external int tag; + + external PaymentErrorKind kind; +} + +final class wire_cst_receive_payment_response extends ffi.Struct { + external ffi.Pointer id; + + external ffi.Pointer invoice; +} + +final class wire_cst_send_payment_response extends ffi.Struct { + external ffi.Pointer txid; +} + +final class wire_cst_wallet_info extends ffi.Struct { + @ffi.Uint64() + external int balance_sat; + + external ffi.Pointer pubkey; +} + +const double LIQUID_CLAIM_TX_FEERATE = 0.1; diff --git a/lib/ls-sdk-flutter/packages/flutter_breez_liquid/macos/Classes/ls_sdk.h b/lib/ls-sdk-flutter/packages/flutter_breez_liquid/macos/Classes/ls_sdk.h new file mode 100644 index 0000000..d59f50a --- /dev/null +++ b/lib/ls-sdk-flutter/packages/flutter_breez_liquid/macos/Classes/ls_sdk.h @@ -0,0 +1,175 @@ +#include +#include +#include +// EXTRA BEGIN +typedef struct DartCObject *WireSyncRust2DartDco; +typedef struct WireSyncRust2DartSse { + uint8_t *ptr; + int32_t len; +} WireSyncRust2DartSse; + +typedef int64_t DartPort; +typedef bool (*DartPostCObjectFnType)(DartPort port_id, void *message); +void store_dart_post_cobject(DartPostCObjectFnType ptr); +// EXTRA END +typedef struct _Dart_Handle* Dart_Handle; + +/** + * Claim tx feerate for Receive, in sats per vbyte. + * Since the Liquid blocks are consistently empty for now, we hardcode the minimum feerate. + */ +#define LIQUID_CLAIM_TX_FEERATE 0.1 + +typedef struct wire_cst_list_prim_u_8_strict { + uint8_t *ptr; + int32_t len; +} wire_cst_list_prim_u_8_strict; + +typedef struct wire_cst_prepare_receive_request { + uint64_t *payer_amount_sat; + uint64_t *receiver_amount_sat; +} wire_cst_prepare_receive_request; + +typedef struct wire_cst_prepare_receive_response { + struct wire_cst_list_prim_u_8_strict *pair_hash; + uint64_t payer_amount_sat; + uint64_t fees_sat; +} wire_cst_prepare_receive_response; + +typedef struct wire_cst_prepare_send_response { + struct wire_cst_list_prim_u_8_strict *id; + uint64_t payer_amount_sat; + uint64_t receiver_amount_sat; + uint64_t total_fees; + struct wire_cst_list_prim_u_8_strict *funding_address; + struct wire_cst_list_prim_u_8_strict *invoice; +} wire_cst_prepare_send_response; + +typedef struct wire_cst_payment { + struct wire_cst_list_prim_u_8_strict *id; + uint32_t *timestamp; + uint64_t amount_sat; + uint64_t *fees_sat; + int32_t payment_type; + struct wire_cst_list_prim_u_8_strict *invoice; +} wire_cst_payment; + +typedef struct wire_cst_list_payment { + struct wire_cst_payment *ptr; + int32_t len; +} wire_cst_list_payment; + +typedef struct wire_cst_PaymentError_Generic { + struct wire_cst_list_prim_u_8_strict *err; +} wire_cst_PaymentError_Generic; + +typedef struct wire_cst_PaymentError_LwkError { + struct wire_cst_list_prim_u_8_strict *err; +} wire_cst_PaymentError_LwkError; + +typedef struct wire_cst_PaymentError_SendError { + struct wire_cst_list_prim_u_8_strict *err; +} wire_cst_PaymentError_SendError; + +typedef struct wire_cst_PaymentError_SignerError { + struct wire_cst_list_prim_u_8_strict *err; +} wire_cst_PaymentError_SignerError; + +typedef union PaymentErrorKind { + struct wire_cst_PaymentError_Generic Generic; + struct wire_cst_PaymentError_LwkError LwkError; + struct wire_cst_PaymentError_SendError SendError; + struct wire_cst_PaymentError_SignerError SignerError; +} PaymentErrorKind; + +typedef struct wire_cst_payment_error { + int32_t tag; + union PaymentErrorKind kind; +} wire_cst_payment_error; + +typedef struct wire_cst_receive_payment_response { + struct wire_cst_list_prim_u_8_strict *id; + struct wire_cst_list_prim_u_8_strict *invoice; +} wire_cst_receive_payment_response; + +typedef struct wire_cst_send_payment_response { + struct wire_cst_list_prim_u_8_strict *txid; +} wire_cst_send_payment_response; + +typedef struct wire_cst_wallet_info { + uint64_t balance_sat; + struct wire_cst_list_prim_u_8_strict *pubkey; +} wire_cst_wallet_info; + +void frbgen_breez_liquid_wire_backup(int64_t port_); + +void frbgen_breez_liquid_wire_connect(int64_t port_, + struct wire_cst_list_prim_u_8_strict *mnemonic, + struct wire_cst_list_prim_u_8_strict *data_dir, + int32_t network); + +void frbgen_breez_liquid_wire_empty_wallet_cache(int64_t port_); + +void frbgen_breez_liquid_wire_get_info(int64_t port_, bool with_scan); + +void frbgen_breez_liquid_wire_list_payments(int64_t port_, bool with_scan, bool include_pending); + +void frbgen_breez_liquid_wire_prepare_receive_payment(int64_t port_, + struct wire_cst_prepare_receive_request *req); + +void frbgen_breez_liquid_wire_prepare_send_payment(int64_t port_, + struct wire_cst_list_prim_u_8_strict *invoice); + +void frbgen_breez_liquid_wire_receive_payment(int64_t port_, + struct wire_cst_prepare_receive_response *req); + +void frbgen_breez_liquid_wire_recover_funds(int64_t port_, uintptr_t recovery); + +void frbgen_breez_liquid_wire_restore(int64_t port_, + struct wire_cst_list_prim_u_8_strict *backup_path); + +void frbgen_breez_liquid_wire_send_payment(int64_t port_, + struct wire_cst_prepare_send_response *req); + +void frbgen_breez_liquid_rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockLBtcReverseRecovery(const void *ptr); + +void frbgen_breez_liquid_rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockLBtcReverseRecovery(const void *ptr); + +struct wire_cst_prepare_receive_request *frbgen_breez_liquid_cst_new_box_autoadd_prepare_receive_request(void); + +struct wire_cst_prepare_receive_response *frbgen_breez_liquid_cst_new_box_autoadd_prepare_receive_response(void); + +struct wire_cst_prepare_send_response *frbgen_breez_liquid_cst_new_box_autoadd_prepare_send_response(void); + +uint32_t *frbgen_breez_liquid_cst_new_box_autoadd_u_32(uint32_t value); + +uint64_t *frbgen_breez_liquid_cst_new_box_autoadd_u_64(uint64_t value); + +struct wire_cst_list_payment *frbgen_breez_liquid_cst_new_list_payment(int32_t len); + +struct wire_cst_list_prim_u_8_strict *frbgen_breez_liquid_cst_new_list_prim_u_8_strict(int32_t len); +static int64_t dummy_method_to_enforce_bundling(void) { + int64_t dummy_var = 0; + dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_prepare_receive_request); + dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_prepare_receive_response); + dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_prepare_send_response); + dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_u_32); + dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_u_64); + dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_list_payment); + dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_list_prim_u_8_strict); + dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockLBtcReverseRecovery); + dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockLBtcReverseRecovery); + dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_wire_backup); + dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_wire_connect); + dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_wire_empty_wallet_cache); + dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_wire_get_info); + dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_wire_list_payments); + dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_wire_prepare_receive_payment); + dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_wire_prepare_send_payment); + dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_wire_receive_payment); + dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_wire_recover_funds); + dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_wire_restore); + dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_wire_send_payment); + dummy_var ^= ((int64_t) (void*) store_dart_post_cobject); + return dummy_var; +}