Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: esplora client #12

Merged
merged 32 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
5e35616
workflows
darioAnongba Dec 9, 2024
026d8f2
use commits in actions and not tags
darioAnongba Dec 9, 2024
3b0e9cf
CI only when targeting main
darioAnongba Dec 9, 2024
ab0d7e6
Merge branch 'main' into chore/gh-workflows
darioAnongba Dec 9, 2024
89311d0
change MSRV to 1.73
darioAnongba Dec 9, 2024
0a7795e
remove prepare and merge fmt and clippy
darioAnongba Dec 9, 2024
b56dafc
remove prepare and merge fmt and clippy
darioAnongba Dec 9, 2024
96fad7a
use cargo to install wasm-pack
darioAnongba Dec 10, 2024
bc61cae
msrv 1.74
darioAnongba Dec 10, 2024
6c87c10
msrv 1.73 and locked
darioAnongba Dec 10, 2024
91dc5e8
new types
darioAnongba Dec 11, 2024
b01b410
merge main
darioAnongba Dec 11, 2024
188a6ee
typo in messagePack
darioAnongba Dec 11, 2024
8977894
typo in messagePack
darioAnongba Dec 11, 2024
22037da
add to wallet as well
darioAnongba Dec 11, 2024
39f0657
add block_height in tests
darioAnongba Dec 11, 2024
edab32d
remove comments in Denomination
darioAnongba Dec 11, 2024
29fbb65
remove on exhaustive and add p2wsh
darioAnongba Dec 11, 2024
e37cda6
before merge
darioAnongba Dec 11, 2024
b31a54a
replace esplora wallet by esplora client
darioAnongba Dec 11, 2024
0fade28
tests
darioAnongba Dec 11, 2024
ffe8a13
reveal addresses for sync
darioAnongba Dec 11, 2024
3fe0686
remove from snap wallet
darioAnongba Dec 12, 2024
d92ecca
apply_update
darioAnongba Dec 12, 2024
4cd23ef
try using --locked
darioAnongba Dec 12, 2024
7b8210b
add locked
darioAnongba Dec 12, 2024
ed33bbe
move locked
darioAnongba Dec 12, 2024
42b43a4
push the .lock file
darioAnongba Dec 12, 2024
33652d1
test by removing locked
darioAnongba Dec 12, 2024
285239d
Merge branch 'fix/ci' into feat/esplora-client
darioAnongba Dec 12, 2024
d9d7197
Merge branch 'main' into feat/esplora-client
darioAnongba Dec 12, 2024
aa6a412
improve test
darioAnongba Dec 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ crate-type = ["cdylib", "rlib"]
default = []
esplora = ["bdk_esplora"]
debug = ["console_error_panic_hook"]
snap = ["esplora"]
snap = ["default"]

[dependencies]
wasm-bindgen = "0.2.95"
Expand Down
43 changes: 43 additions & 0 deletions src/bitcoin/esplora_client.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
use bdk_core::spk_client::{FullScanRequest as BdkFullScanRequest, SyncRequest as BdkSyncRequest};
use bdk_esplora::{
esplora_client::{AsyncClient, Builder},
EsploraAsyncExt,
};
use bdk_wallet::KeychainKind;
use wasm_bindgen::prelude::wasm_bindgen;

use crate::{
result::JsResult,
types::{FullScanRequest, SyncRequest, Update},
};

#[wasm_bindgen]
pub struct EsploraClient {
client: AsyncClient,
}

#[wasm_bindgen]
impl EsploraClient {
#[wasm_bindgen(constructor)]
pub fn new(url: &str) -> JsResult<EsploraClient> {
let client = Builder::new(url).build_async()?;
Ok(EsploraClient { client })
}

pub async fn full_scan(
&mut self,
request: FullScanRequest,
stop_gap: usize,
parallel_requests: usize,
) -> JsResult<Update> {
let request: BdkFullScanRequest<KeychainKind> = request.into();
let result = self.client.full_scan(request, stop_gap, parallel_requests).await?;
Ok(result.into())
}

pub async fn sync(&mut self, request: SyncRequest, parallel_requests: usize) -> JsResult<Update> {
let request: BdkSyncRequest<(KeychainKind, u32)> = request.into();
let result = self.client.sync(request, parallel_requests).await?;
Ok(result.into())
}
}
198 changes: 0 additions & 198 deletions src/bitcoin/esplora_wallet.rs

This file was deleted.

4 changes: 2 additions & 2 deletions src/bitcoin/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ pub use descriptor::*;
pub use wallet::*;

#[cfg(feature = "esplora")]
mod esplora_wallet;
mod esplora_client;

#[cfg(feature = "snap")]
mod snap_wallet;

#[cfg(feature = "esplora")]
pub use esplora_wallet::EsploraWallet;
pub use esplora_client::EsploraClient;

#[cfg(feature = "snap")]
pub use snap_wallet::SnapWallet;
Loading
Loading