Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
23 changes: 19 additions & 4 deletions backends/blindbit-v1/src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ use std::pin::Pin;
use anyhow::{Result, bail};
use async_trait::async_trait;
use bitcoin::absolute::Height;
use bitcoin::{Amount, BlockHash, OutPoint};
use bitcoin::{Amount, BlockHash, OutPoint, Txid};
use futures::{Stream, StreamExt as _, stream};
use spdk_core::chain::{BoxedBlockData, ChainBackend, SpentIndexData, UtxoData};

use crate::BlindbitClient;
use crate::BackendInfo;
use crate::client::BlindbitClient;
use crate::structs::BlindbitV1BlockData;
use crate::utils::input_hashes_map;

Expand All @@ -21,8 +22,22 @@ pub struct BlindbitBackend {
}

impl BlindbitBackend {
pub const fn new(client: BlindbitClient) -> Self {
Self { client }
pub fn new(host_url: &str) -> Result<Self> {
Ok(Self {
client: BlindbitClient::new(host_url)?,
})
}

pub async fn info(&self) -> Result<BackendInfo> {
self.client.info().await
}

pub async fn block_height(&self) -> Result<Height> {
self.client.block_height().await
}

pub async fn forward_tx(&self, tx_hex: String) -> Result<Txid> {
self.client.forward_tx(tx_hex).await
}
}

Expand Down
2 changes: 1 addition & 1 deletion backends/blindbit-v1/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ mod client;
pub mod structs;
pub mod utils;

pub use api_structs::InfoResponse as BackendInfo;
pub use backend::BlindbitBackend;
pub use client::BlindbitClient;
4 changes: 2 additions & 2 deletions scanners/local/examples/simple_scanner.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::collections::{HashMap, HashSet};
use std::sync::atomic::AtomicBool;

use backend_blindbit_v1::{BlindbitBackend, BlindbitClient};
use backend_blindbit_v1::BlindbitBackend;
use bitcoin::absolute::Height;
use bitcoin::secp256k1::SecretKey;
use bitcoin::{Amount, BlockHash, Network, OutPoint};
Expand Down Expand Up @@ -40,7 +40,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let scan_sk = SecretKey::from_slice(&SCAN_SK_BYTES)?;
let spend_sk = SecretKey::from_slice(&SPEND_SK_BYTES)?;

let backend = BlindbitBackend::new(BlindbitClient::new(BLINDBIT_BACKEND_URL)?);
let backend = BlindbitBackend::new(BLINDBIT_BACKEND_URL)?;

let client = SpClient::new(scan_sk, SpendKey::Secret(spend_sk), NETWORK)?;
let sp_receiver = client.receiver();
Expand Down
Loading