Add Wallet.balance()
This commit is contained in:
parent
6361b41f33
commit
a33a09f2a3
@ -27,6 +27,11 @@ fn free_void_result(void_result: FfiResultVoid) {
|
|||||||
drop(void_result)
|
drop(void_result)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[ffi_export]
|
||||||
|
fn free_uint64_result(void_result: FfiResult<u64>) {
|
||||||
|
drop(void_result)
|
||||||
|
}
|
||||||
|
|
||||||
// TODO do we need this? remove?
|
// TODO do we need this? remove?
|
||||||
/// Free a Rust-allocated string
|
/// Free a Rust-allocated string
|
||||||
#[ffi_export]
|
#[ffi_export]
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
use std::convert::TryFrom;
|
use std::convert::TryFrom;
|
||||||
|
use std::ffi::CString;
|
||||||
|
|
||||||
use ::safer_ffi::prelude::*;
|
use ::safer_ffi::prelude::*;
|
||||||
use bdk::bitcoin::network::constants::Network::Testnet;
|
use bdk::bitcoin::network::constants::Network::Testnet;
|
||||||
@ -14,7 +15,6 @@ use database::DatabaseConfig;
|
|||||||
|
|
||||||
use crate::error::FfiError;
|
use crate::error::FfiError;
|
||||||
use crate::types::{FfiResult, FfiResultVoid};
|
use crate::types::{FfiResult, FfiResultVoid};
|
||||||
use std::ffi::CString;
|
|
||||||
|
|
||||||
mod blockchain;
|
mod blockchain;
|
||||||
mod database;
|
mod database;
|
||||||
@ -125,10 +125,26 @@ fn list_unspent(opaque_wallet: &OpaqueWallet) -> FfiResult<repr_c::Vec<LocalUtxo
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[ffi_export]
|
#[ffi_export]
|
||||||
fn free_unspent_result(unspent_result: FfiResult<repr_c::Vec<LocalUtxo>>) {
|
fn free_veclocalutxo_result(unspent_result: FfiResult<repr_c::Vec<LocalUtxo>>) {
|
||||||
drop(unspent_result)
|
drop(unspent_result)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[ffi_export]
|
||||||
|
fn balance(opaque_wallet: &OpaqueWallet) -> FfiResult<u64> {
|
||||||
|
let balance_result = opaque_wallet.raw.get_balance();
|
||||||
|
|
||||||
|
match balance_result {
|
||||||
|
Ok(b) => FfiResult {
|
||||||
|
ok: b,
|
||||||
|
err: FfiError::None,
|
||||||
|
},
|
||||||
|
Err(e) => FfiResult {
|
||||||
|
ok: u64::MIN,
|
||||||
|
err: FfiError::from(&e),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Non-opaque returned values
|
// Non-opaque returned values
|
||||||
|
|
||||||
#[derive_ReprC]
|
#[derive_ReprC]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user