wip compiles now

This commit is contained in:
Steve Myers 2021-10-12 11:53:11 -07:00
parent aa63457d9c
commit cdb90aa35c

View File

@ -2,9 +2,13 @@ use bdk::Wallet;
use bdk::database::MemoryDatabase; use bdk::database::MemoryDatabase;
use bdk::bitcoin::Network; use bdk::bitcoin::Network;
// use crate::error::FfiError; // use crate::error::FfiError;
use std::sync::RwLock; use std::sync::{RwLock, Mutex};
use std::vec::Vec; use std::vec::Vec;
use bdk::database::BatchDatabase;
use bdk::sled;
use bdk::sled::Tree;
//mod error; //mod error;
//mod types; //mod types;
//mod wallet; //mod wallet;
@ -12,21 +16,24 @@ use std::vec::Vec;
uniffi_macros::include_scaffolding!("bdk"); uniffi_macros::include_scaffolding!("bdk");
struct OfflineWallet { struct OfflineWallet {
wallet: Wallet<(), MemoryDatabase>, wallet: Mutex<Wallet<(), Tree>>,
//wallet: RwLock<Vec<String>> //wallet: RwLock<Vec<String>>
} }
impl OfflineWallet { impl OfflineWallet {
fn new(descriptor: String) -> Self { fn new(descriptor: String) -> Self {
let database = sled::open("testdb").unwrap();
let tree = database.open_tree("test").unwrap();
let wallet = Wallet::new_offline( let wallet = Wallet::new_offline(
&descriptor, &descriptor,
None, None,
Network::Regtest, Network::Regtest,
MemoryDatabase::new(), tree,
).unwrap(); ).unwrap();
OfflineWallet { OfflineWallet {
wallet wallet: Mutex::new(wallet)
} }
// OfflineWallet { // OfflineWallet {
@ -35,3 +42,6 @@ impl OfflineWallet {
} }
} }
uniffi::deps::static_assertions::assert_impl_all!(OfflineWallet: Sync, Send);