-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
89 additions
and
5 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "bdk-ffi" | ||
version = "1.0.0-alpha.1" | ||
version = "1.0.0-alpha.2" | ||
authors = ["Steve Myers <[email protected]>", "Sudarsan Balaji <[email protected]>"] | ||
edition = "2018" | ||
license = "MIT OR Apache-2.0" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
use crate::wallet::Update; | ||
use crate::wallet::Wallet; | ||
use bdk::wallet::Update as BdkUpdate; | ||
use bdk::Error as BdkError; | ||
use bdk_esplora::esplora_client::{BlockingClient, Builder}; | ||
use bdk_esplora::EsploraExt; | ||
use std::sync::Arc; | ||
|
||
pub struct EsploraClient(BlockingClient); | ||
|
||
impl EsploraClient { | ||
pub fn new(url: String) -> Self { | ||
let client = Builder::new(url.as_str()).build_blocking().unwrap(); | ||
Self(client) | ||
} | ||
|
||
pub fn scan( | ||
&self, | ||
wallet: Arc<Wallet>, | ||
stop_gap: u64, | ||
parallel_requests: u64, | ||
) -> Result<Arc<Update>, BdkError> { | ||
let wallet = wallet.get_wallet(); | ||
|
||
let previous_tip = wallet.latest_checkpoint(); | ||
let keychain_spks = wallet.spks_of_all_keychains().into_iter().collect(); | ||
|
||
let (update_graph, last_active_indices) = self | ||
.0 | ||
.scan_txs_with_keychains( | ||
keychain_spks, | ||
None, | ||
None, | ||
stop_gap as usize, | ||
parallel_requests as usize, | ||
) | ||
.unwrap(); | ||
|
||
let missing_heights = update_graph.missing_heights(wallet.local_chain()); | ||
let chain_update = self | ||
.0 | ||
.update_local_chain(previous_tip, missing_heights) | ||
.unwrap(); | ||
|
||
let update = BdkUpdate { | ||
last_active_indices, | ||
graph: update_graph, | ||
chain: Some(chain_update), | ||
}; | ||
|
||
Ok(Arc::new(Update(update))) | ||
} | ||
|
||
// pub fn sync(); | ||
|
||
// pub fn broadcast(); | ||
|
||
// pub fn estimate_fee(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters