Skip to main content

bip353/
monitoring.rs

1//! This is useful in monitoring backend events
2
3use bitcoin::Address;
4use async_trait::async_trait;
5
6/// (lets users plug in their own)
7#[async_trait]
8pub trait ChainBackend: Send + Sync {
9    /// Check if an address has been used
10    async fn is_address_used(&self, address: &Address) -> Result<bool, Box<dyn std::error::Error + Send + Sync>>;
11    
12    /// Get transaction history for an address
13    async fn get_address_history(&self, address: &Address) -> Result<Vec<String>, Box<dyn std::error::Error + Send + Sync>>;
14}
15
16/// Simple event when an address is detected as used
17#[derive(Debug, Clone)]
18pub struct AddressUsedEvent {
19    pub hrn: String,
20    pub address: Address,
21    pub tx_id: String,
22}
23
24/// Simple chain monitor(placeholder)
25pub struct ChainMonitor {
26    // This is a placeholder(your true chain impl would go here)
27    _placeholder: (),
28}
29
30impl ChainMonitor {
31    pub fn new() -> Self {
32        Self { _placeholder: () }
33    }
34    
35    /// Check if an address has been used (placeholder)
36    pub async fn check_address_usage(&self, _address: &Address) -> Result<bool, Box<dyn std::error::Error + Send + Sync>> {
37        // Placeholder - always return false for now
38        Ok(false)
39    }
40}