Skip to content

Commit c9a0d88

Browse files
fix
1 parent 12bdb50 commit c9a0d88

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

key-wallet-ffi/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub mod bip38;
2828

2929
// Re-export main types for convenience
3030
pub use error::{FFIError, FFIErrorCode};
31-
pub use types::{FFINetwork, FFIWallet};
31+
pub use types::{FFIBalance, FFINetwork, FFIWallet};
3232
pub use utxo::FFIUTXO;
3333

3434
// ============================================================================

key-wallet-ffi/src/types.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,32 @@ impl From<Network> for FFINetwork {
8888
}
8989
}
9090

91+
/// FFI Balance type for representing wallet balances
92+
#[repr(C)]
93+
#[derive(Debug, Clone, Copy, Default)]
94+
pub struct FFIBalance {
95+
/// Confirmed balance in satoshis
96+
pub confirmed: u64,
97+
/// Unconfirmed balance in satoshis
98+
pub unconfirmed: u64,
99+
/// Immature balance in satoshis (e.g., mining rewards)
100+
pub immature: u64,
101+
/// Total balance (confirmed + unconfirmed) in satoshis
102+
pub total: u64,
103+
}
104+
105+
106+
impl From<key_wallet::WalletBalance> for FFIBalance {
107+
fn from(balance: key_wallet::WalletBalance) -> Self {
108+
FFIBalance {
109+
confirmed: balance.confirmed,
110+
unconfirmed: balance.unconfirmed,
111+
immature: balance.locked, // Map locked to immature for now
112+
total: balance.total,
113+
}
114+
}
115+
}
116+
91117
/// Opaque wallet handle
92118
pub struct FFIWallet {
93119
pub(crate) wallet: Arc<Wallet>,

0 commit comments

Comments
 (0)