use bitcoin::hash_types::Txid; use bitcoin::util::bip32::{ChildNumber, DerivationPath}; use bitcoin::{OutPoint, Script, Transaction}; use crate::error::Error; use crate::types::*; #[cfg(any(feature = "key-value-db", feature = "default"))] pub mod keyvalue; pub trait BatchOperations { fn set_script_pubkey>( &mut self, script: &Script, script_type: ScriptType, path: &P, ) -> Result<(), Error>; fn set_utxo(&mut self, utxo: &UTXO) -> Result<(), Error>; fn set_raw_tx(&mut self, transaction: &Transaction) -> Result<(), Error>; fn set_tx(&mut self, transaction: &TransactionDetails) -> Result<(), Error>; fn set_last_index(&mut self, script_type: ScriptType, value: u32) -> Result<(), Error>; fn del_script_pubkey_from_path>( &mut self, script_type: ScriptType, path: &P, ) -> Result, Error>; fn del_path_from_script_pubkey( &mut self, script: &Script, ) -> Result, Error>; fn del_utxo(&mut self, outpoint: &OutPoint) -> Result, Error>; fn del_raw_tx(&mut self, txid: &Txid) -> Result, Error>; fn del_tx( &mut self, txid: &Txid, include_raw: bool, ) -> Result, Error>; fn del_last_index(&mut self, script_type: ScriptType) -> Result, Error>; } pub trait Database: BatchOperations { fn check_descriptor_checksum>( &mut self, script_type: ScriptType, bytes: B, ) -> Result<(), Error>; fn iter_script_pubkeys(&self, script_type: Option) -> Result, Error>; fn iter_utxos(&self) -> Result, Error>; fn iter_raw_txs(&self) -> Result, Error>; fn iter_txs(&self, include_raw: bool) -> Result, Error>; fn get_script_pubkey_from_path>( &self, script_type: ScriptType, path: &P, ) -> Result, Error>; fn get_path_from_script_pubkey( &self, script: &Script, ) -> Result, Error>; fn get_utxo(&self, outpoint: &OutPoint) -> Result, Error>; fn get_raw_tx(&self, txid: &Txid) -> Result, Error>; fn get_tx(&self, txid: &Txid, include_raw: bool) -> Result, Error>; fn get_last_index(&self, script_type: ScriptType) -> Result, Error>; // inserts 0 if not present fn increment_last_index(&mut self, script_type: ScriptType) -> Result; } pub trait BatchDatabase: Database { type Batch: BatchOperations; fn begin_batch(&self) -> Self::Batch; fn commit_batch(&mut self, batch: Self::Batch) -> Result<(), Error>; }