Skip to content

Commit

Permalink
Add electrum impl
Browse files Browse the repository at this point in the history
  • Loading branch information
22388o committed Oct 14, 2024
1 parent 7d6e312 commit 2296570
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/on-chain/electrum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,39 @@ fn main() {
println!("Transaction: {}", tx);
let address = client.get_address("address").unwrap();
println!("Address: {}", address);
}

impl ElectrumClient {
pub fn new(url: &str) -> Result<Self, Error> {
let client = Client::new(url)?;
Ok(Self { client })
}
pub fn get_block_height(&self) -> Result<u64, Error> {
let block_height = self.client.get_block_height()?;
Ok(block_height)
}
pub fn get_block_hash(&self, block_height: u64) -> Result<String, Error> {
let block_hash = self.client.get_block_hash(block_height)?;
Ok(block_hash)
}
pub fn get_block(&self, block_hash: &str) -> Result<String, Error> {
let block = self.client.get_block(block_hash)?;
Ok(block)
}
pub fn get_transaction(&self, tx_hash: &str) -> Result<String, Error> {
let tx = self.client.get_transaction(tx_hash)?;
Ok(tx)
}
pub fn get_address(&self, address: &str) -> Result<String, Error> {
let address = self.client.get_address(address)?;
Ok(address)
}
pub fn get_balance(&self, address: &str) -> Result<u64, Error> {
let balance = self.client.get_balance(address)?;
Ok(balance)
}
pub fn get_utxos(&self, address: &str) -> Result<Vec<Utxo>, Error> {
let utxos = self.client.get_utxos(address)?;
Ok(utxos)
}
}

0 comments on commit 2296570

Please sign in to comment.