[WIP] Add get new address API to Wallet

This commit is contained in:
Sudarsan Balaji 2021-10-13 01:45:22 +05:30
parent 8faba58cd4
commit 784f754cd9
2 changed files with 13 additions and 2 deletions

View File

@ -4,4 +4,5 @@ namespace bdk {
interface OfflineWallet { interface OfflineWallet {
constructor(string descriptor); constructor(string descriptor);
string get_new_address();
}; };

View File

@ -1,14 +1,13 @@
use bdk::Wallet; use bdk::Wallet;
use bdk::wallet::AddressIndex;
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, Mutex}; use std::sync::{RwLock, Mutex};
use std::vec::Vec; use std::vec::Vec;
use bdk::database::BatchDatabase; use bdk::database::BatchDatabase;
use bdk::sled; use bdk::sled;
use bdk::sled::Tree; use bdk::sled::Tree;
//mod error; //mod error;
//mod types; //mod types;
//mod wallet; //mod wallet;
@ -40,6 +39,17 @@ impl OfflineWallet {
// wallet: RwLock::new(Vec::new()) // wallet: RwLock::new(Vec::new())
// } // }
} }
fn get_new_address(&self) -> String {
self
.wallet
.lock()
.unwrap()
.get_address(AddressIndex::New)
.unwrap()
.address
.to_string()
}
} }
uniffi::deps::static_assertions::assert_impl_all!(OfflineWallet: Sync, Send); uniffi::deps::static_assertions::assert_impl_all!(OfflineWallet: Sync, Send);